* [PATCHv3 00/20] dvb core: add basic support for the media controller
@ 2015-01-06 21:08 Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 01/20] media: add new types for DVB devnodes Mauro Carvalho Chehab
` (19 more replies)
0 siblings, 20 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
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 3:
- Added the second series of patches ("add link graph to cx231xx
using the media controller")
- tuner-core and cx25840: add proper error handling as suggested by
Sakari Ailus and pointed by Joe Perches;
- dvb core: move the media_dev struct to be inside the DVB adapter. That
allowed to simplify the changes for the dvbdev clients;
- Add logic to setup the pipelines when analog or digital TV stream starts.
- Renamed some patches to better describe its contents.
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:
- Update media API docbook for the DVB media controller changes
- Solve the issues pointed by a separate e-mail
Those patches are also available at my experimental tree:
http://git.linuxtv.org/cgit.cgi/mchehab/experimental-v4l-utils.git/log/?h=dvb-media-ctl
Mauro Carvalho Chehab (20):
media: add new types for DVB devnodes
dvbdev: add support for media controller
cx231xx: add media controller support
dvb_frontend: add media controller support for DVB frontend
dmxdev: add support for demux/dvr nodes at media controller
dvb_ca_en50221: add support for CA node at the media controller
dvb_net: add support for DVB net node at the media controller
dvbdev: add pad for the DVB devnodes
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
dvbdev: enable DVB-specific links
dvb-frontend: enable tuner link when the FE thread starts
cx231xx: enable tuner->decoder link at videobuf start
cx231xx: create a streaming pipeline at VB start
dvb_frontend: start media pipeline while thread is running
drivers/media/dvb-core/dmxdev.c | 11 ++-
drivers/media/dvb-core/dvb_ca_en50221.c | 6 +-
drivers/media/dvb-core/dvb_frontend.c | 121 ++++++++++++++++++++++++-
drivers/media/dvb-core/dvb_net.c | 6 +-
drivers/media/dvb-core/dvbdev.c | 143 +++++++++++++++++++++++++++++-
drivers/media/dvb-core/dvbdev.h | 15 ++++
drivers/media/i2c/cx25840/cx25840-core.c | 18 ++++
drivers/media/i2c/cx25840/cx25840-core.h | 3 +
drivers/media/usb/cx231xx/cx231xx-cards.c | 98 ++++++++++++++++++--
drivers/media/usb/cx231xx/cx231xx-dvb.c | 4 +
drivers/media/usb/cx231xx/cx231xx-video.c | 101 ++++++++++++++++++++-
drivers/media/usb/cx231xx/cx231xx.h | 7 ++
drivers/media/v4l2-core/tuner-core.c | 20 +++++
include/uapi/linux/media.h | 11 ++-
14 files changed, 547 insertions(+), 17 deletions(-)
--
2.1.0
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCHv3 01/20] media: add new types for DVB devnodes
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-07 14:09 ` Sakari Ailus
2015-01-06 21:08 ` [PATCHv3 02/20] dvbdev: add support for media controller Mauro Carvalho Chehab
` (18 subsequent siblings)
19 siblings, 1 reply; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, linux-api
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 <mchehab@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_DVB MEDIA_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
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 02/20] dvbdev: add support for media controller
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 01/20] media: add new types for DVB devnodes Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 03/20] cx231xx: add media controller support Mauro Carvalho Chehab
` (17 subsequent siblings)
19 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
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 <mchehab@osg.samsung.com>
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 983db75de350..d975cbb29705 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->adapter->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->adapter->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..ace8575975d8 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
@@ -71,6 +72,10 @@ struct dvb_adapter {
int mfe_shared; /* indicates mutually exclusive frontends */
struct dvb_device *mfe_dvbdev; /* frontend device in use */
struct mutex mfe_lock; /* access lock for thread creation */
+
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ struct media_device *mdev;
+#endif
};
@@ -92,6 +97,14 @@ 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)
+ const char *name;
+
+ /* Filled inside dvbdev.c */
+ struct media_entity *entity;
+#endif
+
void *priv;
};
--
2.1.0
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 03/20] cx231xx: add media controller support
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 01/20] media: add new types for DVB devnodes Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 02/20] dvbdev: add support for media controller Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-08 1:44 ` Shuah Khan
2015-01-06 21:08 ` [PATCHv3 04/20] dvb_frontend: add media controller support for DVB frontend Mauro Carvalho Chehab
` (16 subsequent siblings)
19 siblings, 1 reply; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Matthias Schwarzott, Antti Palosaari,
Hans Verkuil
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 <mchehab@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..05d21b9f30d8 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -455,6 +455,7 @@ static int register_dvb(struct cx231xx_dvb *dvb,
mutex_init(&dvb->lock);
+
/* register adapter */
result = dvb_register_adapter(&dvb->adapter, dev->name, module, device,
adapter_nr);
@@ -465,6 +466,8 @@ static int register_dvb(struct cx231xx_dvb *dvb,
goto fail_adapter;
}
+ dvb->adapter.mdev = dev->media_dev;
+
/* Ensure all frontends negotiate bus access */
dvb->frontend->ops.ts_bus_ctrl = cx231xx_dvb_bus_ctrl;
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
index 6d6f3ee812f6..af9d6c4041dc 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -658,6 +658,10 @@ struct cx231xx {
struct video_device *vbi_dev;
struct video_device *radio_dev;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ struct media_device *media_dev;
+#endif
+
unsigned char eedata[256];
struct cx231xx_video_mode video_mode;
--
2.1.0
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 04/20] dvb_frontend: add media controller support for DVB frontend
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (2 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 03/20] cx231xx: add media controller support Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 05/20] dmxdev: add support for demux/dvr nodes at media controller Mauro Carvalho Chehab
` (15 subsequent siblings)
19 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Shuah Khan, Akihiro Tsukada, Ole Ernst
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 <mchehab@osg.samsung.com>
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index 2cf30576bf39..c2c559105f64 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -2612,11 +2612,14 @@ 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,
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ .name = fe->ops.info.name,
+#endif
.kernel_ioctl = dvb_frontend_ioctl
};
--
2.1.0
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 05/20] dmxdev: add support for demux/dvr nodes at media controller
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (3 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 04/20] dvb_frontend: add media controller support for DVB frontend Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 06/20] dvb_ca_en50221: add support for CA node at the " Mauro Carvalho Chehab
` (14 subsequent siblings)
19 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Changbing Xiong
Make the dvb core demux support aware of the media controller and
register the corresponding devices.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
index abff803ad69a..a2ccd8095aed 100644
--- a/drivers/media/dvb-core/dmxdev.c
+++ b/drivers/media/dvb-core/dmxdev.c
@@ -1136,10 +1136,13 @@ static const struct file_operations dvb_demux_fops = {
.llseek = default_llseek,
};
-static struct dvb_device dvbdev_demux = {
+static const struct dvb_device dvbdev_demux = {
.priv = NULL,
.users = 1,
.writers = 1,
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ .name = "demux",
+#endif
.fops = &dvb_demux_fops
};
@@ -1209,13 +1212,15 @@ static const struct file_operations dvb_dvr_fops = {
.llseek = default_llseek,
};
-static struct dvb_device dvbdev_dvr = {
+static const struct dvb_device dvbdev_dvr = {
.priv = NULL,
.readers = 1,
.users = 1,
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ .name = "dvr",
+#endif
.fops = &dvb_dvr_fops
};
-
int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter)
{
int i;
--
2.1.0
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 06/20] dvb_ca_en50221: add support for CA node at the media controller
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (4 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 05/20] dmxdev: add support for demux/dvr nodes at media controller Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 07/20] dvb_net: add support for DVB net " Mauro Carvalho Chehab
` (13 subsequent siblings)
19 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
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 <mchehab@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..22258e15baa9 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -1638,15 +1638,17 @@ static const struct file_operations dvb_ca_fops = {
.llseek = noop_llseek,
};
-static struct dvb_device dvbdev_ca = {
+static const struct dvb_device dvbdev_ca = {
.priv = NULL,
.users = 1,
.readers = 1,
.writers = 1,
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ .name = "ca_en50221",
+#endif
.fops = &dvb_ca_fops,
};
-
/* ******************************************************************************** */
/* Initialisation/shutdown functions */
--
2.1.0
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 07/20] dvb_net: add support for DVB net node at the media controller
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (5 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 06/20] dvb_ca_en50221: add support for CA node at the " Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 08/20] dvbdev: add pad for the DVB devnodes Mauro Carvalho Chehab
` (12 subsequent siblings)
19 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Dan Carpenter, David Herrmann,
David S. Miller, Joe Perches, Tom Gundersen
Make the dvb core network support aware of the media controller and
register the corresponding devices.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
index e4041f074909..bd3c2be80216 100644
--- a/drivers/media/dvb-core/dvb_net.c
+++ b/drivers/media/dvb-core/dvb_net.c
@@ -1498,14 +1498,16 @@ static const struct file_operations dvb_net_fops = {
.llseek = noop_llseek,
};
-static struct dvb_device dvbdev_net = {
+static const struct dvb_device dvbdev_net = {
.priv = NULL,
.users = 1,
.writers = 1,
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ .name = "dvb net",
+#endif
.fops = &dvb_net_fops,
};
-
void dvb_net_release (struct dvb_net *dvbnet)
{
int i;
--
2.1.0
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 08/20] dvbdev: add pad for the DVB devnodes
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (6 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 07/20] dvb_net: add support for DVB net " Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 09/20] tuner-core: properly initialize media controller subdev Mauro Carvalho Chehab
` (11 subsequent siblings)
19 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
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 <mchehab@osg.samsung.com>
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index d975cbb29705..1071d31b7f1d 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->adapter->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->adapter->mdev, dvbdev->entity);
+ if (npads)
+ ret = media_entity_init(dvbdev->entity, npads, dvbdev->pads, 0);
+ if (!ret)
+ ret = media_device_register_entity(dvbdev->adapter->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 ace8575975d8..c037c2ff9f5a 100644
--- a/drivers/media/dvb-core/dvbdev.h
+++ b/drivers/media/dvb-core/dvbdev.h
@@ -101,8 +101,9 @@ struct dvb_device {
#if defined(CONFIG_MEDIA_CONTROLLER)
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
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 09/20] tuner-core: properly initialize media controller subdev
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (7 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 08/20] dvbdev: add pad for the DVB devnodes Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 10/20] cx25840: fill the media controller entity Mauro Carvalho Chehab
` (10 subsequent siblings)
19 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Hans Verkuil, Prabhakar Lad, linux-api
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>
diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index 559f8372e2eb..9a83b27a7e8f 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -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;
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
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 10/20] cx25840: fill the media controller entity
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (8 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 09/20] tuner-core: properly initialize media controller subdev Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-07 11:44 ` Prabhakar Lad
2015-01-06 21:08 ` [PATCHv3 11/20] cx231xx: initialize video/vbi pads Mauro Carvalho Chehab
` (9 subsequent siblings)
19 siblings, 1 reply; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Hans Verkuil, Prabhakar Lad, Joe Perches,
Boris BREZILLON
Instead of keeping the media controller entity not initialized,
fill it and create the pads for cx25840.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index 573e08826b9b..bdb5bb6b58da 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -5137,6 +5137,9 @@ static int cx25840_probe(struct i2c_client *client,
int default_volume;
u32 id;
u16 device_id;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ int ret;
+#endif
/* Check if the adapter supports the needed features */
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
@@ -5178,6 +5181,21 @@ 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");
+ kfree(state);
+ return -ENODEV;
+ }
+#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_pad pads[3];
+#endif
};
static inline struct cx25840_state *to_state(struct v4l2_subdev *sd)
--
2.1.0
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 11/20] cx231xx: initialize video/vbi pads
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (9 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 10/20] cx25840: fill the media controller entity Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 12/20] cx231xx: create media links for analog mode Mauro Carvalho Chehab
` (8 subsequent siblings)
19 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Hans Verkuil, Laurent Pinchart,
Prabhakar Lad, Boris BREZILLON, Ramakrishnan Muthukrishnan,
Matthias Schwarzott, Antti Palosaari
Both video and vbi are sink pads. Initialize them as such.
Signed-off-by: Mauro Carvalho Chehab <mchehab@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
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 12/20] cx231xx: create media links for analog mode
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (10 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 11/20] cx231xx: initialize video/vbi pads Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 13/20] dvbdev: represent frontend with two pads Mauro Carvalho Chehab
` (7 subsequent siblings)
19 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Matthias Schwarzott, Antti Palosaari
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 <mchehab@osg.samsung.com>
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 7e1c73a5172d..5cc4efcf82d6 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1159,6 +1159,42 @@ 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) {
+ 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 +1651,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
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 13/20] dvbdev: represent frontend with two pads
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (11 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 12/20] cx231xx: create media links for analog mode Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 14/20] dvbdev: add a function to create DVB media graph Mauro Carvalho Chehab
` (6 subsequent siblings)
19 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
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 <mchehab@osg.samsung.com>
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 1071d31b7f1d..3aaffb319688 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
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 14/20] dvbdev: add a function to create DVB media graph
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (12 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 13/20] dvbdev: represent frontend with two pads Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 15/20] cx231xx: create DVB graph Mauro Carvalho Chehab
` (5 subsequent siblings)
19 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
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 <mchehab@osg.samsung.com>
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 3aaffb319688..30acf97f4e4b 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -380,6 +380,51 @@ 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) {
+ 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 c037c2ff9f5a..3ee767449fff 100644
--- a/drivers/media/dvb-core/dvbdev.h
+++ b/drivers/media/dvb-core/dvbdev.h
@@ -122,6 +122,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
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 15/20] cx231xx: create DVB graph
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (13 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 14/20] dvbdev: add a function to create DVB media graph Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 16/20] dvbdev: enable DVB-specific links Mauro Carvalho Chehab
` (4 subsequent siblings)
19 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Matthias Schwarzott, Antti Palosaari,
Hans Verkuil
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 <mchehab@osg.samsung.com>
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index 05d21b9f30d8..1d7e9a719caa 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -539,6 +539,7 @@ static int register_dvb(struct cx231xx_dvb *dvb,
/* register network adapter */
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
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 16/20] dvbdev: enable DVB-specific links
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (14 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 15/20] cx231xx: create DVB graph Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 17/20] dvb-frontend: enable tuner link when the FE thread starts Mauro Carvalho Chehab
` (3 subsequent siblings)
19 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab
For now, let's keep the DVB-specific media controller links enabled
by default. On most devices, this is fixed anyway, so no big issue.
Ok, the demux actually have dynamic links based on the filters, but
we don't represent them yet, as the media controller currently lacks
the capability of dynamically create/delete entities.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 30acf97f4e4b..1b99cc17836c 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -414,13 +414,13 @@ void dvb_create_media_graph(struct media_device *mdev)
media_entity_create_link(tuner, 0, fe, 0, 0);
if (fe && demux)
- media_entity_create_link(fe, 1, demux, 0, 0);
+ media_entity_create_link(fe, 1, demux, 0, MEDIA_LNK_FL_ENABLED);
if (demux && dvr)
- media_entity_create_link(demux, 1, dvr, 0, 0);
+ media_entity_create_link(demux, 1, dvr, 0, MEDIA_LNK_FL_ENABLED);
if (demux && ca)
- media_entity_create_link(demux, 1, ca, 0, 0);
+ media_entity_create_link(demux, 1, ca, 0, MEDIA_LNK_FL_ENABLED);
#endif
}
EXPORT_SYMBOL_GPL(dvb_create_media_graph);
--
2.1.0
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 17/20] dvb-frontend: enable tuner link when the FE thread starts
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (15 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 16/20] dvbdev: enable DVB-specific links Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-08 21:11 ` Shuah Khan
2015-01-06 21:08 ` [PATCHv3 18/20] cx231xx: enable tuner->decoder link at videobuf start Mauro Carvalho Chehab
` (2 subsequent siblings)
19 siblings, 1 reply; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Shuah Khan, Ole Ernst, Akihiro Tsukada
If the dvb frontend thread starts, the tuner should be switched
to the frontend. Add a code that ensures that this will happen,
using the media controller.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index c2c559105f64..04e949ad9722 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -590,12 +590,99 @@ static void dvb_frontend_wakeup(struct dvb_frontend *fe)
wake_up_interruptible(&fepriv->wait_queue);
}
+/**
+ * dvb_enable_media_tuner() - tries to enable the DVB tuner
+ *
+ * @fe: struct dvb_frontend pointer
+ *
+ * This function ensures that just one media tuner is enabled for a given
+ * frontend. It has two different behaviors:
+ * - For trivial devices with just one tuner:
+ * it just enables the existing tuner->fe link
+ * - For devices with more than one tuner:
+ * It is up to the driver to implement the logic that will enable one tuner
+ * and disable the other ones. However, if more than one tuner is enabled for
+ * the same frontend, it will print an error message and return -EINVAL.
+ *
+ * At return, it will return the error code returned by media_entity_setup_link,
+ * or 0 if everything is OK, if no tuner is linked to the frontend or if the
+ * mdev is NULL.
+ */
+static int dvb_enable_media_tuner(struct dvb_frontend *fe)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+ struct dvb_frontend_private *fepriv = fe->frontend_priv;
+ struct dvb_adapter *adapter = fe->dvb;
+ struct media_device *mdev = adapter->mdev;
+ struct media_entity *entity, *source;
+ struct media_link *link, *found_link = NULL;
+ int i, ret, n_links = 0, active_links = 0;
+
+ if (!mdev)
+ return 0;
+
+ entity = fepriv->dvbdev->entity;
+ for (i = 0; i < entity->num_links; i++) {
+ link = &entity->links[i];
+ if (link->sink->entity == entity) {
+ found_link = link;
+ n_links++;
+ if (link->flags & MEDIA_LNK_FL_ENABLED)
+ active_links++;
+ }
+ }
+
+ if (!n_links || active_links == 1 || !found_link)
+ return 0;
+
+ /*
+ * If a frontend has more than one tuner linked, it is up to the driver
+ * to select with one will be the active one, as the frontend core can't
+ * guess. If the driver doesn't do that, it is a bug.
+ */
+ if (n_links > 1 && active_links != 1) {
+ dev_err(fe->dvb->device,
+ "WARNING: there are %d active links among %d tuners. This is a driver's bug!\n",
+ active_links, n_links);
+ return -EINVAL;
+ }
+
+ source = found_link->source->entity;
+ for (i = 0; i < source->num_links; i++) {
+ struct media_entity *sink;
+ int flags = 0;
+
+ link = &source->links[i];
+ sink = link->sink->entity;
+
+ if (sink == entity)
+ flags = MEDIA_LNK_FL_ENABLED;
+
+ ret = media_entity_setup_link(link, flags);
+ if (ret) {
+ dev_err(fe->dvb->device,
+ "Couldn't change link %s->%s to %s. Error %d\n",
+ source->name, sink->name,
+ flags ? "enabled" : "disabled",
+ ret);
+ return ret;
+ } else
+ dev_dbg(fe->dvb->device,
+ "link %s->%s was %s\n",
+ source->name, sink->name,
+ flags ? "ENABLED" : "disabled");
+ }
+#endif
+ return 0;
+}
+
static int dvb_frontend_thread(void *data)
{
struct dvb_frontend *fe = data;
struct dvb_frontend_private *fepriv = fe->frontend_priv;
fe_status_t s;
enum dvbfe_algo algo;
+ int ret;
bool re_tune = false;
bool semheld = false;
@@ -609,6 +696,13 @@ static int dvb_frontend_thread(void *data)
fepriv->wakeup = 0;
fepriv->reinitialise = 0;
+ ret = dvb_enable_media_tuner(fe);
+ if (ret) {
+ /* FIXME: return an error if it fails */
+ dev_info(fe->dvb->device,
+ "proceeding with FE task\n");
+ }
+
dvb_frontend_init(fe);
set_freezable();
--
2.1.0
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 18/20] cx231xx: enable tuner->decoder link at videobuf start
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (16 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 17/20] dvb-frontend: enable tuner link when the FE thread starts Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-08 21:15 ` Shuah Khan
2015-01-06 21:08 ` [PATCHv3 19/20] cx231xx: create a streaming pipeline at VB start Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 20/20] dvb_frontend: start media pipeline while thread is running Mauro Carvalho Chehab
19 siblings, 1 reply; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Hans Verkuil, Laurent Pinchart,
Ramakrishnan Muthukrishnan, Boris BREZILLON, Peter Senna Tschudin
The tuner->decoder needs to be enabled when we're about to
start streaming.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index f3d1a488dfa7..634763535d60 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -703,6 +703,74 @@ static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf)
buf->vb.state = VIDEOBUF_NEEDS_INIT;
}
+static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+ struct media_device *mdev = dev->media_dev;
+ struct media_entity *entity, *decoder = NULL, *source;
+ struct media_link *link, *found_link = NULL;
+ int i, ret, active_links = 0;
+
+ if (!mdev)
+ return 0;
+
+/*
+ * This will find the tuner that it is connected into the decoder.
+ * Technically, this is not 100% correct, as the device may be using an
+ * analog input instead of the tuner. However, we can't use the DVB for dvb
+ * while the DMA engine is being used for V4L2.
+ */
+ media_device_for_each_entity(entity, mdev) {
+ if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
+ decoder = entity;
+ break;
+ }
+ }
+ if (!decoder)
+ return 0;
+
+ for (i = 0; i < decoder->num_links; i++) {
+ link = &decoder->links[i];
+ if (link->sink->entity == decoder) {
+ found_link = link;
+ if (link->flags & MEDIA_LNK_FL_ENABLED)
+ active_links++;
+ break;
+ }
+ }
+
+ if (active_links == 1 || !found_link)
+ return 0;
+
+ source = found_link->source->entity;
+ for (i = 0; i < source->num_links; i++) {
+ struct media_entity *sink;
+ int flags = 0;
+
+ link = &source->links[i];
+ sink = link->sink->entity;
+
+ if (sink == entity)
+ flags = MEDIA_LNK_FL_ENABLED;
+
+ ret = media_entity_setup_link(link, flags);
+ if (ret) {
+ dev_err(dev->dev,
+ "Couldn't change link %s->%s to %s. Error %d\n",
+ source->name, sink->name,
+ flags ? "enabled" : "disabled",
+ ret);
+ return ret;
+ } else
+ dev_dbg(dev->dev,
+ "link %s->%s was %s\n",
+ source->name, sink->name,
+ flags ? "ENABLED" : "disabled");
+ }
+#endif
+ return 0;
+}
+
static int
buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
enum v4l2_field field)
@@ -756,6 +824,9 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
}
buf->vb.state = VIDEOBUF_PREPARED;
+
+ cx231xx_enable_analog_tuner(dev);
+
return 0;
fail:
--
2.1.0
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 19/20] cx231xx: create a streaming pipeline at VB start
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (17 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 18/20] cx231xx: enable tuner->decoder link at videobuf start Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 20/20] dvb_frontend: start media pipeline while thread is running Mauro Carvalho Chehab
19 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Hans Verkuil, Laurent Pinchart,
Ramakrishnan Muthukrishnan, Boris BREZILLON, Matthias Schwarzott,
Antti Palosaari
When videobuf starts, create a streaming pipeline,
destroying it when the stream stops.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index 634763535d60..c5ded52ba7ed 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -705,11 +705,12 @@ static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf)
static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
{
+ int ret = 0;
#ifdef CONFIG_MEDIA_CONTROLLER
struct media_device *mdev = dev->media_dev;
struct media_entity *entity, *decoder = NULL, *source;
struct media_link *link, *found_link = NULL;
- int i, ret, active_links = 0;
+ int i;
if (!mdev)
return 0;
@@ -733,13 +734,11 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
link = &decoder->links[i];
if (link->sink->entity == decoder) {
found_link = link;
- if (link->flags & MEDIA_LNK_FL_ENABLED)
- active_links++;
break;
}
}
- if (active_links == 1 || !found_link)
+ if (!found_link)
return 0;
source = found_link->source->entity;
@@ -767,8 +766,12 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
source->name, sink->name,
flags ? "ENABLED" : "disabled");
}
+
+ dev->pipe_start_entity = source;
+ ret = media_entity_pipeline_start(dev->pipe_start_entity, &dev->pipe);
+
#endif
- return 0;
+ return ret;
}
static int
@@ -804,6 +807,10 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
if (!dev->video_mode.bulk_ctl.num_bufs)
urb_init = 1;
}
+ rc = cx231xx_enable_analog_tuner(dev);
+ if (rc < 0)
+ goto fail;
+
dev_dbg(dev->dev,
"urb_init=%d dev->video_mode.max_pkt_size=%d\n",
urb_init, dev->video_mode.max_pkt_size);
@@ -825,11 +832,15 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
buf->vb.state = VIDEOBUF_PREPARED;
- cx231xx_enable_analog_tuner(dev);
-
return 0;
fail:
+#ifdef CONFIG_MEDIA_CONTROLLER
+ if (dev->pipe_start_entity) {
+ media_entity_pipeline_stop(dev->pipe_start_entity);
+ dev->pipe_start_entity = NULL;
+ }
+#endif
free_buffer(vq, buf);
return rc;
}
@@ -857,6 +868,12 @@ static void buffer_release(struct videobuf_queue *vq,
cx231xx_isocdbg("cx231xx: called buffer_release\n");
+#ifdef CONFIG_MEDIA_CONTROLLER
+ if (dev->pipe_start_entity) {
+ media_entity_pipeline_stop(dev->pipe_start_entity);
+ dev->pipe_start_entity = NULL;
+ }
+#endif
free_buffer(vq, buf);
}
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
index e0d3106f6b44..fa5742801169 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -661,6 +661,8 @@ struct cx231xx {
#if defined(CONFIG_MEDIA_CONTROLLER)
struct media_device *media_dev;
struct media_pad video_pad, vbi_pad;
+ struct media_pipeline pipe;
+ struct media_entity *pipe_start_entity;
#endif
unsigned char eedata[256];
--
2.1.0
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCHv3 20/20] dvb_frontend: start media pipeline while thread is running
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
` (18 preceding siblings ...)
2015-01-06 21:08 ` [PATCHv3 19/20] cx231xx: create a streaming pipeline at VB start Mauro Carvalho Chehab
@ 2015-01-06 21:08 ` Mauro Carvalho Chehab
19 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-06 21:08 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
Mauro Carvalho Chehab, Shuah Khan, Ole Ernst, Akihiro Tsukada
While the DVB thread is running, the media pipeline should be
streaming. This should prevent any attempt of using the analog
TV while digital TV is working, and vice-versa.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index 04e949ad9722..1bee3834e2e1 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -131,6 +131,11 @@ struct dvb_frontend_private {
int quality;
unsigned int check_wrapped;
enum dvbfe_search algo_status;
+
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ struct media_pipeline pipe;
+ struct media_entity *pipe_start_entity;
+#endif
};
static void dvb_frontend_wakeup(struct dvb_frontend *fe);
@@ -608,9 +613,9 @@ static void dvb_frontend_wakeup(struct dvb_frontend *fe)
* or 0 if everything is OK, if no tuner is linked to the frontend or if the
* mdev is NULL.
*/
+#ifdef CONFIG_MEDIA_CONTROLLER
static int dvb_enable_media_tuner(struct dvb_frontend *fe)
{
-#ifdef CONFIG_MEDIA_CONTROLLER
struct dvb_frontend_private *fepriv = fe->frontend_priv;
struct dvb_adapter *adapter = fe->dvb;
struct media_device *mdev = adapter->mdev;
@@ -618,10 +623,14 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
struct media_link *link, *found_link = NULL;
int i, ret, n_links = 0, active_links = 0;
+ fepriv->pipe_start_entity = NULL;
+
if (!mdev)
return 0;
entity = fepriv->dvbdev->entity;
+ fepriv->pipe_start_entity = entity;
+
for (i = 0; i < entity->num_links; i++) {
link = &entity->links[i];
if (link->sink->entity == entity) {
@@ -648,6 +657,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
}
source = found_link->source->entity;
+ fepriv->pipe_start_entity = source;
for (i = 0; i < source->num_links; i++) {
struct media_entity *sink;
int flags = 0;
@@ -672,9 +682,9 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
source->name, sink->name,
flags ? "ENABLED" : "disabled");
}
-#endif
return 0;
}
+#endif
static int dvb_frontend_thread(void *data)
{
@@ -696,12 +706,19 @@ static int dvb_frontend_thread(void *data)
fepriv->wakeup = 0;
fepriv->reinitialise = 0;
+#ifdef CONFIG_MEDIA_CONTROLLER
ret = dvb_enable_media_tuner(fe);
if (ret) {
/* FIXME: return an error if it fails */
dev_info(fe->dvb->device,
"proceeding with FE task\n");
+ } else {
+ ret = media_entity_pipeline_start(fepriv->pipe_start_entity,
+ &fepriv->pipe);
+ if (ret)
+ return ret;
}
+#endif
dvb_frontend_init(fe);
@@ -812,6 +829,11 @@ restart:
}
}
+#ifdef CONFIG_MEDIA_CONTROLLER
+ media_entity_pipeline_stop(fepriv->pipe_start_entity);
+ fepriv->pipe_start_entity = NULL;
+#endif
+
if (dvb_powerdown_on_sleep) {
if (fe->ops.set_voltage)
fe->ops.set_voltage(fe, SEC_VOLTAGE_OFF);
--
2.1.0
^ permalink raw reply related [flat|nested] 33+ messages in thread
* Re: [PATCHv3 10/20] cx25840: fill the media controller entity
2015-01-06 21:08 ` [PATCHv3 10/20] cx25840: fill the media controller entity Mauro Carvalho Chehab
@ 2015-01-07 11:44 ` Prabhakar Lad
2015-01-07 12:14 ` Mauro Carvalho Chehab
0 siblings, 1 reply; 33+ messages in thread
From: Prabhakar Lad @ 2015-01-07 11:44 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Laurent Pinchart, Sakari Ailus, Linux Media Mailing List,
Mauro Carvalho Chehab, Hans Verkuil, Joe Perches, Boris BREZILLON
Hi Mauro,
Thanks for the patch.
On Tue, Jan 6, 2015 at 9:08 PM, Mauro Carvalho Chehab
<mchehab@osg.samsung.com> wrote:
> Instead of keeping the media controller entity not initialized,
> fill it and create the pads for cx25840.
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
>
> diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
> index 573e08826b9b..bdb5bb6b58da 100644
> --- a/drivers/media/i2c/cx25840/cx25840-core.c
> +++ b/drivers/media/i2c/cx25840/cx25840-core.c
> @@ -5137,6 +5137,9 @@ static int cx25840_probe(struct i2c_client *client,
> int default_volume;
> u32 id;
> u16 device_id;
> +#if defined(CONFIG_MEDIA_CONTROLLER)
> + int ret;
> +#endif
>
> /* Check if the adapter supports the needed features */
> if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
> @@ -5178,6 +5181,21 @@ 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 */
| MEDIA_PAD_FL_MUST_CONNECT ?
> + state->pads[1].flags = MEDIA_PAD_FL_SOURCE; /* Video */
> + state->pads[2].flags = MEDIA_PAD_FL_SOURCE; /* VBI */
Macros for 0,1,2, and 3 would make it more readable.
> + 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");
> + kfree(state);
Not required.
> + return -ENODEV;
return ret; instead ?
Thanks,
--Prabhakar Lad
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCHv3 10/20] cx25840: fill the media controller entity
2015-01-07 11:44 ` Prabhakar Lad
@ 2015-01-07 12:14 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-07 12:14 UTC (permalink / raw)
To: Prabhakar Lad
Cc: Laurent Pinchart, Sakari Ailus, Linux Media Mailing List,
Mauro Carvalho Chehab, Hans Verkuil, Joe Perches, Boris BREZILLON
Hi Prabhakar,
Em Wed, 7 Jan 2015 11:44:08 +0000
Prabhakar Lad <prabhakar.csengg@gmail.com> escreveu:
> Hi Mauro,
>
> Thanks for the patch.
Thanks for review.
> On Tue, Jan 6, 2015 at 9:08 PM, Mauro Carvalho Chehab
> <mchehab@osg.samsung.com> wrote:
> > Instead of keeping the media controller entity not initialized,
> > fill it and create the pads for cx25840.
> >
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> >
> > diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
> > index 573e08826b9b..bdb5bb6b58da 100644
> > --- a/drivers/media/i2c/cx25840/cx25840-core.c
> > +++ b/drivers/media/i2c/cx25840/cx25840-core.c
> > @@ -5137,6 +5137,9 @@ static int cx25840_probe(struct i2c_client *client,
> > int default_volume;
> > u32 id;
> > u16 device_id;
> > +#if defined(CONFIG_MEDIA_CONTROLLER)
> > + int ret;
> > +#endif
> >
> > /* Check if the adapter supports the needed features */
> > if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
> > @@ -5178,6 +5181,21 @@ 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 */
>
> | MEDIA_PAD_FL_MUST_CONNECT ?
Maybe. Currently, only omap3 uses this flag. Not sure what difference
it will make.
> > + state->pads[1].flags = MEDIA_PAD_FL_SOURCE; /* Video */
> > + state->pads[2].flags = MEDIA_PAD_FL_SOURCE; /* VBI */
>
> Macros for 0,1,2, and 3 would make it more readable.
Yes, but IMHO the best would be to add those macros on some global place,
as all analog demod PADs will look the same: one sync to connect to the
tuner and two PADs, one for video stream and another one for VBI.
A few decoders may have an additional PAD for sliced-VBI.
Doing such definition globally helps to support drivers like em28xx,
where, depending on the board, there are several different alternatives
for the demod, all providing the very same 3 pads.
> > + 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");
> > + kfree(state);
> Not required.
Why not? state were allocated previously in this function. If we don't free
it, it will have a memory leak.
>
> > + return -ENODEV;
> return ret; instead ?
Yeah, makes sense. I'll fix that on a next spin of the patch.
>
> Thanks,
> --Prabhakar Lad
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCHv3 01/20] media: add new types for DVB devnodes
2015-01-06 21:08 ` [PATCHv3 01/20] media: add new types for DVB devnodes Mauro Carvalho Chehab
@ 2015-01-07 14:09 ` Sakari Ailus
2015-01-07 14:22 ` Mauro Carvalho Chehab
0 siblings, 1 reply; 33+ messages in thread
From: Sakari Ailus @ 2015-01-07 14:09 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Laurent Pinchart
Cc: Linux Media Mailing List, Mauro Carvalho Chehab, linux-api
Hi Mauro,
Mauro Carvalho Chehab wrote:
> 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 <mchehab@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)
I'd create another type for the DVB sub-type devices, as there is for
V4L2 sub-devices. I wonder what Laurent thinks.
> +
> +/* Legacy symbol. Use it to avoid userspace compilation breakages */
> +#define MEDIA_ENT_T_DEVNODE_DVB MEDIA_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)
>
--
Kind regards,
Sakari Ailus
sakari.ailus@linux.intel.com
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCHv3 01/20] media: add new types for DVB devnodes
2015-01-07 14:09 ` Sakari Ailus
@ 2015-01-07 14:22 ` Mauro Carvalho Chehab
2015-01-08 16:10 ` Laurent Pinchart
0 siblings, 1 reply; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-07 14:22 UTC (permalink / raw)
To: Sakari Ailus
Cc: Laurent Pinchart, Linux Media Mailing List, Mauro Carvalho Chehab,
linux-api
Em Wed, 07 Jan 2015 16:09:04 +0200
Sakari Ailus <sakari.ailus@linux.intel.com> escreveu:
> Hi Mauro,
>
> Mauro Carvalho Chehab wrote:
> > 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 <mchehab@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)
>
> I'd create another type for the DVB sub-type devices, as there is for
> V4L2 sub-devices. I wonder what Laurent thinks.
I discussed this quickly with Laurent on IRC.
There are some concept differences between V4L2 and DVB.
At v4l2:
- the spec is one monolitic header (videodev2.h);
- one devnode is used to control everyhing (/dev/video?)
- there is one v4l core for all types of devices
At DVB:
- each different DVB API has its own header;
- each DVB device type has its own core (ok, they're
linked into one module, but internally they're almost independent);
- each different DVB API has its own devnode.
So, using "SUBDEV" for DVB (or at least for the devnodes) don't
make much sense.
Ok, there are still some things at DVB side that could be mapped as
subdev. The clear example is the tuner. However, in this case, the
same tuner can be either V4L, DVB or both. So, we need to define just
one subdev type for the tuner.
Also, each DVB device can be identified via major/minor pairs.
I wrote already (and submitted upstream) the patches for media-ctl to
recognize them. They're also on my experimental v4l-utils tree:
http://git.linuxtv.org/cgit.cgi/mchehab/experimental-v4l-utils.git/log/?h=dvb-media-ctl
Regards,
Mauro
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCHv3 03/20] cx231xx: add media controller support
2015-01-06 21:08 ` [PATCHv3 03/20] cx231xx: add media controller support Mauro Carvalho Chehab
@ 2015-01-08 1:44 ` Shuah Khan
2015-01-08 3:15 ` Mauro Carvalho Chehab
0 siblings, 1 reply; 33+ messages in thread
From: Shuah Khan @ 2015-01-08 1:44 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Laurent Pinchart, Sakari Ailus, Linux Media Mailing List,
Mauro Carvalho Chehab, Matthias Schwarzott, Antti Palosaari,
Hans Verkuil
On Tue, Jan 6, 2015 at 2:08 PM, Mauro Carvalho Chehab
<mchehab@osg.samsung.com> wrote:
> 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 <mchehab@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;
When media_device_register(mdev) fails in cx231xx_media_device_register(),
media_dev is null? The above will simply assign null to dev->v4l2_dev.mdev
Is that correct?
> 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..05d21b9f30d8 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
> @@ -455,6 +455,7 @@ static int register_dvb(struct cx231xx_dvb *dvb,
>
> mutex_init(&dvb->lock);
>
> +
> /* register adapter */
> result = dvb_register_adapter(&dvb->adapter, dev->name, module, device,
> adapter_nr);
> @@ -465,6 +466,8 @@ static int register_dvb(struct cx231xx_dvb *dvb,
> goto fail_adapter;
> }
>
> + dvb->adapter.mdev = dev->media_dev;
> +
> /* Ensure all frontends negotiate bus access */
> dvb->frontend->ops.ts_bus_ctrl = cx231xx_dvb_bus_ctrl;
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
> index 6d6f3ee812f6..af9d6c4041dc 100644
> --- a/drivers/media/usb/cx231xx/cx231xx.h
> +++ b/drivers/media/usb/cx231xx/cx231xx.h
> @@ -658,6 +658,10 @@ struct cx231xx {
> struct video_device *vbi_dev;
> struct video_device *radio_dev;
>
> +#if defined(CONFIG_MEDIA_CONTROLLER)
> + struct media_device *media_dev;
> +#endif
> +
> unsigned char eedata[256];
>
> struct cx231xx_video_mode video_mode;
> --
> 2.1.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCHv3 03/20] cx231xx: add media controller support
2015-01-08 1:44 ` Shuah Khan
@ 2015-01-08 3:15 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-08 3:15 UTC (permalink / raw)
To: Shuah Khan
Cc: Laurent Pinchart, Sakari Ailus, Linux Media Mailing List,
Mauro Carvalho Chehab, Matthias Schwarzott, Antti Palosaari,
Hans Verkuil
Hi Shuah,
Em Wed, 7 Jan 2015 18:44:26 -0700
Shuah Khan <shuahkhan@gmail.com> escreveu:
> > +
> > /* Create v4l2 device */
> > + dev->v4l2_dev.mdev = dev->media_dev;
>
> When media_device_register(mdev) fails in cx231xx_media_device_register(),
> media_dev is null? The above will simply assign null to dev->v4l2_dev.mdev
> Is that correct?
Yes, this is intentional. If the media controls fail to register, everything
will keep working, except for the media controller itself. That sounds better,
IMHO, than to have a complete failure.
Cheers,
Mauro
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCHv3 01/20] media: add new types for DVB devnodes
2015-01-07 14:22 ` Mauro Carvalho Chehab
@ 2015-01-08 16:10 ` Laurent Pinchart
2015-01-08 17:44 ` Mauro Carvalho Chehab
0 siblings, 1 reply; 33+ messages in thread
From: Laurent Pinchart @ 2015-01-08 16:10 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Sakari Ailus, Linux Media Mailing List, Mauro Carvalho Chehab,
linux-api
Hi Mauro,
On Wednesday 07 January 2015 12:22:39 Mauro Carvalho Chehab wrote:
> Em Wed, 07 Jan 2015 16:09:04 +0200 Sakari Ailus escreveu:
> > Mauro Carvalho Chehab wrote:
> > > 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 <mchehab@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)
> >
> > I'd create another type for the DVB sub-type devices, as there is for
> > V4L2 sub-devices. I wonder what Laurent thinks.
>
> I discussed this quickly with Laurent on IRC.
>
> There are some concept differences between V4L2 and DVB.
>
> At v4l2:
> - the spec is one monolitic header (videodev2.h);
> - one devnode is used to control everyhing (/dev/video?)
> - there is one v4l core for all types of devices
>
> At DVB:
> - each different DVB API has its own header;
> - each DVB device type has its own core (ok, they're
> linked into one module, but internally they're almost independent);
> - each different DVB API has its own devnode.
>
> So, using "SUBDEV" for DVB (or at least for the devnodes) don't
> make much sense.
>
> Ok, there are still some things at DVB side that could be mapped as
> subdev. The clear example is the tuner. However, in this case, the
> same tuner can be either V4L, DVB or both. So, we need to define just
> one subdev type for the tuner.
>
> Also, each DVB device can be identified via major/minor pairs.
>
> I wrote already (and submitted upstream) the patches for media-ctl to
> recognize them. They're also on my experimental v4l-utils tree:
> http://git.linuxtv.org/cgit.cgi/mchehab/experimental-v4l-> utils.git/log/?h=dvb-media-ctl
As I've mentioned in a previous discussion, the media_entity type field is too
restrictive. Not only does this use case show that we need a type, sub-type
and sub-sub-type, there are also entities that implement several distinct
types. I thus believe we need a new ioctl is needed to expose detailed
information about entities. This topic has been discussed numerous times in
the past, it "just" requires someone to implement it.
I'm not opposed to a short-term solution like the one proposed here, but maybe
we should instead decide it's time to implement the new ioctl instead.
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCHv3 01/20] media: add new types for DVB devnodes
2015-01-08 16:10 ` Laurent Pinchart
@ 2015-01-08 17:44 ` Mauro Carvalho Chehab
2015-01-11 13:54 ` Laurent Pinchart
0 siblings, 1 reply; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-08 17:44 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Sakari Ailus, Linux Media Mailing List, Mauro Carvalho Chehab,
linux-api
Em Thu, 08 Jan 2015 18:10:13 +0200
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:
> Hi Mauro,
>
> On Wednesday 07 January 2015 12:22:39 Mauro Carvalho Chehab wrote:
> > Em Wed, 07 Jan 2015 16:09:04 +0200 Sakari Ailus escreveu:
> > > Mauro Carvalho Chehab wrote:
> > > > 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 <mchehab@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)
> > >
> > > I'd create another type for the DVB sub-type devices, as there is for
> > > V4L2 sub-devices. I wonder what Laurent thinks.
> >
> > I discussed this quickly with Laurent on IRC.
> >
> > There are some concept differences between V4L2 and DVB.
> >
> > At v4l2:
> > - the spec is one monolitic header (videodev2.h);
> > - one devnode is used to control everyhing (/dev/video?)
> > - there is one v4l core for all types of devices
> >
> > At DVB:
> > - each different DVB API has its own header;
> > - each DVB device type has its own core (ok, they're
> > linked into one module, but internally they're almost independent);
> > - each different DVB API has its own devnode.
> >
> > So, using "SUBDEV" for DVB (or at least for the devnodes) don't
> > make much sense.
> >
> > Ok, there are still some things at DVB side that could be mapped as
> > subdev. The clear example is the tuner. However, in this case, the
> > same tuner can be either V4L, DVB or both. So, we need to define just
> > one subdev type for the tuner.
> >
> > Also, each DVB device can be identified via major/minor pairs.
> >
> > I wrote already (and submitted upstream) the patches for media-ctl to
> > recognize them. They're also on my experimental v4l-utils tree:
> > http://git.linuxtv.org/cgit.cgi/mchehab/experimental-v4l-> utils.git/log/?h=dvb-media-ctl
>
> As I've mentioned in a previous discussion, the media_entity type field is too
> restrictive. Not only does this use case show that we need a type, sub-type
> and sub-sub-type, there are also entities that implement several distinct
> types. I thus believe we need a new ioctl is needed to expose detailed
> information about entities. This topic has been discussed numerous times in
> the past, it "just" requires someone to implement it.
>
> I'm not opposed to a short-term solution like the one proposed here, but maybe
> we should instead decide it's time to implement the new ioctl instead.
>
Ok, so let's stick with it for DVB. At DVB side, I don't see a need for
sub-sub-type, especially since DVB has no subdevs (except for the shared
tuner between DVB and V4L). Everything there are devnodes, with their
functionality strictly following the documentation, as the API is fully
handled inside the DVB core[1].
Also, I don't want to mix adding DVB media controller support with the
addition of a new ioctl.
[1] For the non-deprecated DVB devnodes. DVB have 3 devnode types that
are deprecated because they implement functionality found elsewhere
(video, audio and OSD dvb APIs). Only one legacy driver implements it,
and there's no plan to ever add media controller or expand/accept
new drivers using those legacy APIs.
Regards,
Mauro
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCHv3 17/20] dvb-frontend: enable tuner link when the FE thread starts
2015-01-06 21:08 ` [PATCHv3 17/20] dvb-frontend: enable tuner link when the FE thread starts Mauro Carvalho Chehab
@ 2015-01-08 21:11 ` Shuah Khan
0 siblings, 0 replies; 33+ messages in thread
From: Shuah Khan @ 2015-01-08 21:11 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Laurent Pinchart, Sakari Ailus, Linux Media Mailing List,
Mauro Carvalho Chehab, Shuah Khan, Ole Ernst, Akihiro Tsukada
On Tue, Jan 6, 2015 at 2:08 PM, Mauro Carvalho Chehab
<mchehab@osg.samsung.com> wrote:
> If the dvb frontend thread starts, the tuner should be switched
> to the frontend. Add a code that ensures that this will happen,
> using the media controller.
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
>
> diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
> index c2c559105f64..04e949ad9722 100644
> --- a/drivers/media/dvb-core/dvb_frontend.c
> +++ b/drivers/media/dvb-core/dvb_frontend.c
> @@ -590,12 +590,99 @@ static void dvb_frontend_wakeup(struct dvb_frontend *fe)
> wake_up_interruptible(&fepriv->wait_queue);
> }
>
> +/**
> + * dvb_enable_media_tuner() - tries to enable the DVB tuner
> + *
> + * @fe: struct dvb_frontend pointer
> + *
> + * This function ensures that just one media tuner is enabled for a given
> + * frontend. It has two different behaviors:
> + * - For trivial devices with just one tuner:
> + * it just enables the existing tuner->fe link
> + * - For devices with more than one tuner:
> + * It is up to the driver to implement the logic that will enable one tuner
> + * and disable the other ones. However, if more than one tuner is enabled for
> + * the same frontend, it will print an error message and return -EINVAL.
> + *
> + * At return, it will return the error code returned by media_entity_setup_link,
> + * or 0 if everything is OK, if no tuner is linked to the frontend or if the
> + * mdev is NULL.
> + */
> +static int dvb_enable_media_tuner(struct dvb_frontend *fe)
> +{
> +#ifdef CONFIG_MEDIA_CONTROLLER
> + struct dvb_frontend_private *fepriv = fe->frontend_priv;
> + struct dvb_adapter *adapter = fe->dvb;
> + struct media_device *mdev = adapter->mdev;
> + struct media_entity *entity, *source;
> + struct media_link *link, *found_link = NULL;
> + int i, ret, n_links = 0, active_links = 0;
> +
> + if (!mdev)
> + return 0;
> +
> + entity = fepriv->dvbdev->entity;
> + for (i = 0; i < entity->num_links; i++) {
> + link = &entity->links[i];
> + if (link->sink->entity == entity) {
> + found_link = link;
> + n_links++;
> + if (link->flags & MEDIA_LNK_FL_ENABLED)
> + active_links++;
> + }
> + }
Does this code path need to be protected with a mutex?
> +
> + if (!n_links || active_links == 1 || !found_link)
> + return 0;
> +
> + /*
> + * If a frontend has more than one tuner linked, it is up to the driver
> + * to select with one will be the active one, as the frontend core can't
> + * guess. If the driver doesn't do that, it is a bug.
> + */
> + if (n_links > 1 && active_links != 1) {
> + dev_err(fe->dvb->device,
> + "WARNING: there are %d active links among %d tuners. This is a driver's bug!\n",
> + active_links, n_links);
> + return -EINVAL;
> + }
> +
> + source = found_link->source->entity;
> + for (i = 0; i < source->num_links; i++) {
> + struct media_entity *sink;
> + int flags = 0;
> +
> + link = &source->links[i];
> + sink = link->sink->entity;
> +
> + if (sink == entity)
> + flags = MEDIA_LNK_FL_ENABLED;
> +
> + ret = media_entity_setup_link(link, flags);
> + if (ret) {
> + dev_err(fe->dvb->device,
> + "Couldn't change link %s->%s to %s. Error %d\n",
> + source->name, sink->name,
> + flags ? "enabled" : "disabled",
> + ret);
> + return ret;
> + } else
> + dev_dbg(fe->dvb->device,
> + "link %s->%s was %s\n",
> + source->name, sink->name,
> + flags ? "ENABLED" : "disabled");
> + }
> +#endif
> + return 0;
> +}
> +
> static int dvb_frontend_thread(void *data)
> {
> struct dvb_frontend *fe = data;
> struct dvb_frontend_private *fepriv = fe->frontend_priv;
> fe_status_t s;
> enum dvbfe_algo algo;
> + int ret;
>
> bool re_tune = false;
> bool semheld = false;
> @@ -609,6 +696,13 @@ static int dvb_frontend_thread(void *data)
> fepriv->wakeup = 0;
> fepriv->reinitialise = 0;
>
> + ret = dvb_enable_media_tuner(fe);
> + if (ret) {
> + /* FIXME: return an error if it fails */
> + dev_info(fe->dvb->device,
> + "proceeding with FE task\n");
> + }
> +
> dvb_frontend_init(fe);
>
> set_freezable();
> --
> 2.1.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCHv3 18/20] cx231xx: enable tuner->decoder link at videobuf start
2015-01-06 21:08 ` [PATCHv3 18/20] cx231xx: enable tuner->decoder link at videobuf start Mauro Carvalho Chehab
@ 2015-01-08 21:15 ` Shuah Khan
0 siblings, 0 replies; 33+ messages in thread
From: Shuah Khan @ 2015-01-08 21:15 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Laurent Pinchart, Sakari Ailus, Linux Media Mailing List,
Mauro Carvalho Chehab, Hans Verkuil, Laurent Pinchart,
Ramakrishnan Muthukrishnan, Boris BREZILLON, Peter Senna Tschudin
On Tue, Jan 6, 2015 at 2:08 PM, Mauro Carvalho Chehab
<mchehab@osg.samsung.com> wrote:
> The tuner->decoder needs to be enabled when we're about to
> start streaming.
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
> index f3d1a488dfa7..634763535d60 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-video.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-video.c
> @@ -703,6 +703,74 @@ static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf)
> buf->vb.state = VIDEOBUF_NEEDS_INIT;
> }
>
> +static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
> +{
> +#ifdef CONFIG_MEDIA_CONTROLLER
> + struct media_device *mdev = dev->media_dev;
> + struct media_entity *entity, *decoder = NULL, *source;
> + struct media_link *link, *found_link = NULL;
> + int i, ret, active_links = 0;
> +
> + if (!mdev)
> + return 0;
> +
> +/*
> + * This will find the tuner that it is connected into the decoder.
> + * Technically, this is not 100% correct, as the device may be using an
> + * analog input instead of the tuner. However, we can't use the DVB for dvb
> + * while the DMA engine is being used for V4L2.
> + */
> + media_device_for_each_entity(entity, mdev) {
> + if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
> + decoder = entity;
> + break;
> + }
> + }
> + if (!decoder)
> + return 0;
> +
> + for (i = 0; i < decoder->num_links; i++) {
> + link = &decoder->links[i];
> + if (link->sink->entity == decoder) {
> + found_link = link;
> + if (link->flags & MEDIA_LNK_FL_ENABLED)
> + active_links++;
> + break;
> + }
> + }
Does this code path need to be protected?
> +
> + if (active_links == 1 || !found_link)
> + return 0;
> +
> + source = found_link->source->entity;
> + for (i = 0; i < source->num_links; i++) {
> + struct media_entity *sink;
> + int flags = 0;
> +
> + link = &source->links[i];
> + sink = link->sink->entity;
> +
> + if (sink == entity)
> + flags = MEDIA_LNK_FL_ENABLED;
> +
> + ret = media_entity_setup_link(link, flags);
> + if (ret) {
> + dev_err(dev->dev,
> + "Couldn't change link %s->%s to %s. Error %d\n",
> + source->name, sink->name,
> + flags ? "enabled" : "disabled",
> + ret);
> + return ret;
> + } else
> + dev_dbg(dev->dev,
> + "link %s->%s was %s\n",
> + source->name, sink->name,
> + flags ? "ENABLED" : "disabled");
> + }
> +#endif
> + return 0;
> +}
> +
> static int
> buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
> enum v4l2_field field)
> @@ -756,6 +824,9 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
> }
>
> buf->vb.state = VIDEOBUF_PREPARED;
> +
> + cx231xx_enable_analog_tuner(dev);
> +
> return 0;
>
> fail:
> --
> 2.1.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCHv3 01/20] media: add new types for DVB devnodes
2015-01-08 17:44 ` Mauro Carvalho Chehab
@ 2015-01-11 13:54 ` Laurent Pinchart
2015-01-11 14:09 ` Mauro Carvalho Chehab
0 siblings, 1 reply; 33+ messages in thread
From: Laurent Pinchart @ 2015-01-11 13:54 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Sakari Ailus, Linux Media Mailing List, Mauro Carvalho Chehab,
linux-api
Hi Mauro,
On Thursday 08 January 2015 15:44:50 Mauro Carvalho Chehab wrote:
> Em Thu, 08 Jan 2015 18:10:13 +0200 Laurent Pinchart escreveu:
> > On Wednesday 07 January 2015 12:22:39 Mauro Carvalho Chehab wrote:
> >> Em Wed, 07 Jan 2015 16:09:04 +0200 Sakari Ailus escreveu:
> >>> Mauro Carvalho Chehab wrote:
> >>>> 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 <mchehab@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)
> >>>
> >>> I'd create another type for the DVB sub-type devices, as there is for
> >>> V4L2 sub-devices. I wonder what Laurent thinks.
> >>
> >> I discussed this quickly with Laurent on IRC.
> >>
> >> There are some concept differences between V4L2 and DVB.
> >>
> >> At v4l2:
> >> - the spec is one monolitic header (videodev2.h);
> >> - one devnode is used to control everyhing (/dev/video?)
> >> - there is one v4l core for all types of devices
> >>
> >> At DVB:
> >> - each different DVB API has its own header;
> >> - each DVB device type has its own core (ok, they're
> >> linked into one module, but internally they're almost independent);
> >> - each different DVB API has its own devnode.
> >>
> >> So, using "SUBDEV" for DVB (or at least for the devnodes) don't
> >> make much sense.
> >>
> >> Ok, there are still some things at DVB side that could be mapped as
> >> subdev. The clear example is the tuner. However, in this case, the
> >> same tuner can be either V4L, DVB or both. So, we need to define just
> >> one subdev type for the tuner.
> >>
> >> Also, each DVB device can be identified via major/minor pairs.
> >>
> >> I wrote already (and submitted upstream) the patches for media-ctl to
> >>
> >> recognize them. They're also on my experimental v4l-utils tree:
> >> http://git.linuxtv.org/cgit.cgi/mchehab/experimental-v4l-> >> utils.git/log/?h=dvb-media-ctl>
> >
> > As I've mentioned in a previous discussion, the media_entity type field is
> > too restrictive. Not only does this use case show that we need a type,
> > sub-type and sub-sub-type, there are also entities that implement several
> > distinct types. I thus believe we need a new ioctl is needed to expose
> > detailed information about entities. This topic has been discussed
> > numerous times in the past, it "just" requires someone to implement it.
> >
> > I'm not opposed to a short-term solution like the one proposed here, but
> > maybe we should instead decide it's time to implement the new ioctl
> > instead.
>
> Ok, so let's stick with it for DVB. At DVB side, I don't see a need for
> sub-sub-type, especially since DVB has no subdevs (except for the shared
> tuner between DVB and V4L). Everything there are devnodes, with their
> functionality strictly following the documentation, as the API is fully
> handled inside the DVB core[1].
At the moment the MC API has a devnode type with a DVB devnode subtype.
Splitting DVB devnodes into different categories effectively create sub-
subtypes. That's what bothers mode, the type field is becoming a ragbag.
> Also, I don't want to mix adding DVB media controller support with the
> addition of a new ioctl.
*If* we conclude that a new ioctl is needed to support DVB in a clean way, I
don't see why that new ioctl shouldn't be considered as a prerequisite.
> [1] For the non-deprecated DVB devnodes. DVB have 3 devnode types that
> are deprecated because they implement functionality found elsewhere
> (video, audio and OSD dvb APIs). Only one legacy driver implements it,
> and there's no plan to ever add media controller or expand/accept
> new drivers using those legacy APIs.
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCHv3 01/20] media: add new types for DVB devnodes
2015-01-11 13:54 ` Laurent Pinchart
@ 2015-01-11 14:09 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 33+ messages in thread
From: Mauro Carvalho Chehab @ 2015-01-11 14:09 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Sakari Ailus, Linux Media Mailing List, Mauro Carvalho Chehab,
linux-api
Em Sun, 11 Jan 2015 15:54:14 +0200
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:
> Hi Mauro,
>
> On Thursday 08 January 2015 15:44:50 Mauro Carvalho Chehab wrote:
> > Em Thu, 08 Jan 2015 18:10:13 +0200 Laurent Pinchart escreveu:
> > > On Wednesday 07 January 2015 12:22:39 Mauro Carvalho Chehab wrote:
> > >> Em Wed, 07 Jan 2015 16:09:04 +0200 Sakari Ailus escreveu:
> > >>> Mauro Carvalho Chehab wrote:
> > >>>> 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 <mchehab@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)
> > >>>
> > >>> I'd create another type for the DVB sub-type devices, as there is for
> > >>> V4L2 sub-devices. I wonder what Laurent thinks.
> > >>
> > >> I discussed this quickly with Laurent on IRC.
> > >>
> > >> There are some concept differences between V4L2 and DVB.
> > >>
> > >> At v4l2:
> > >> - the spec is one monolitic header (videodev2.h);
> > >> - one devnode is used to control everyhing (/dev/video?)
> > >> - there is one v4l core for all types of devices
> > >>
> > >> At DVB:
> > >> - each different DVB API has its own header;
> > >> - each DVB device type has its own core (ok, they're
> > >> linked into one module, but internally they're almost independent);
> > >> - each different DVB API has its own devnode.
> > >>
> > >> So, using "SUBDEV" for DVB (or at least for the devnodes) don't
> > >> make much sense.
> > >>
> > >> Ok, there are still some things at DVB side that could be mapped as
> > >> subdev. The clear example is the tuner. However, in this case, the
> > >> same tuner can be either V4L, DVB or both. So, we need to define just
> > >> one subdev type for the tuner.
> > >>
> > >> Also, each DVB device can be identified via major/minor pairs.
> > >>
> > >> I wrote already (and submitted upstream) the patches for media-ctl to
> > >>
> > >> recognize them. They're also on my experimental v4l-utils tree:
> > >> http://git.linuxtv.org/cgit.cgi/mchehab/experimental-v4l-> >> utils.git/log/?h=dvb-media-ctl>
> > >
> > > As I've mentioned in a previous discussion, the media_entity type field is
> > > too restrictive. Not only does this use case show that we need a type,
> > > sub-type and sub-sub-type, there are also entities that implement several
> > > distinct types. I thus believe we need a new ioctl is needed to expose
> > > detailed information about entities. This topic has been discussed
> > > numerous times in the past, it "just" requires someone to implement it.
> > >
> > > I'm not opposed to a short-term solution like the one proposed here, but
> > > maybe we should instead decide it's time to implement the new ioctl
> > > instead.
> >
> > Ok, so let's stick with it for DVB. At DVB side, I don't see a need for
> > sub-sub-type, especially since DVB has no subdevs (except for the shared
> > tuner between DVB and V4L). Everything there are devnodes, with their
> > functionality strictly following the documentation, as the API is fully
> > handled inside the DVB core[1].
>
> At the moment the MC API has a devnode type with a DVB devnode subtype.
> Splitting DVB devnodes into different categories effectively create sub-
> subtypes. That's what bothers mode, the type field is becoming a ragbag.
As I explained before, and more detailed at:
http://www.spinics.net/lists/linux-media/msg85229.html
DVB is actually 3 different APIs (demux, frontend and CA). Those APIs
are independent, and each have an independent devnode. The dvr is a
special case: it is a devnode that doesn't accept ioctl's. It is just
an output devnode, controlled vis the demux API.
The only thing in common to those 3 APIs is that they belong to the same
device type. But some may argue that, on an hybrid device, the input,
remote controller and even V4L2 are also sub-types.
In any case, they're all devnodes, so MEDIA_ENT_T_DEVNODE_foo fits well.
>
> > Also, I don't want to mix adding DVB media controller support with the
> > addition of a new ioctl.
>
> *If* we conclude that a new ioctl is needed to support DVB in a clean way, I
> don't see why that new ioctl shouldn't be considered as a prerequisite.
I don't see the need of a new ioctl for DVB. DVB is even simpler than V4L2,
as it doesn't have subdevs (except for tuner).
>
> > [1] For the non-deprecated DVB devnodes. DVB have 3 devnode types that
> > are deprecated because they implement functionality found elsewhere
> > (video, audio and OSD dvb APIs). Only one legacy driver implements it,
> > and there's no plan to ever add media controller or expand/accept
> > new drivers using those legacy APIs.
>
^ permalink raw reply [flat|nested] 33+ messages in thread
end of thread, other threads:[~2015-01-11 14:09 UTC | newest]
Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-06 21:08 [PATCHv3 00/20] dvb core: add basic support for the media controller Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 01/20] media: add new types for DVB devnodes Mauro Carvalho Chehab
2015-01-07 14:09 ` Sakari Ailus
2015-01-07 14:22 ` Mauro Carvalho Chehab
2015-01-08 16:10 ` Laurent Pinchart
2015-01-08 17:44 ` Mauro Carvalho Chehab
2015-01-11 13:54 ` Laurent Pinchart
2015-01-11 14:09 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 02/20] dvbdev: add support for media controller Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 03/20] cx231xx: add media controller support Mauro Carvalho Chehab
2015-01-08 1:44 ` Shuah Khan
2015-01-08 3:15 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 04/20] dvb_frontend: add media controller support for DVB frontend Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 05/20] dmxdev: add support for demux/dvr nodes at media controller Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 06/20] dvb_ca_en50221: add support for CA node at the " Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 07/20] dvb_net: add support for DVB net " Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 08/20] dvbdev: add pad for the DVB devnodes Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 09/20] tuner-core: properly initialize media controller subdev Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 10/20] cx25840: fill the media controller entity Mauro Carvalho Chehab
2015-01-07 11:44 ` Prabhakar Lad
2015-01-07 12:14 ` Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 11/20] cx231xx: initialize video/vbi pads Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 12/20] cx231xx: create media links for analog mode Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 13/20] dvbdev: represent frontend with two pads Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 14/20] dvbdev: add a function to create DVB media graph Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 15/20] cx231xx: create DVB graph Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 16/20] dvbdev: enable DVB-specific links Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 17/20] dvb-frontend: enable tuner link when the FE thread starts Mauro Carvalho Chehab
2015-01-08 21:11 ` Shuah Khan
2015-01-06 21:08 ` [PATCHv3 18/20] cx231xx: enable tuner->decoder link at videobuf start Mauro Carvalho Chehab
2015-01-08 21:15 ` Shuah Khan
2015-01-06 21:08 ` [PATCHv3 19/20] cx231xx: create a streaming pipeline at VB start Mauro Carvalho Chehab
2015-01-06 21:08 ` [PATCHv3 20/20] dvb_frontend: start media pipeline while thread is running Mauro Carvalho Chehab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).