@@ -452,6 +452,28 @@ static int dvb_register_media_device(struct dvb_device *dvbdev,
return 0;
}
+#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
+static ssize_t media_dev_show(struct device *cd,
+ struct device_attribute *attr, char *buf)
+{
+ struct dvb_device *dvbdev = dev_get_drvdata(cd);
+
+ buf[0] = '\0';
+ if (!dvbdev->adapter->mdev)
+ return 0;
+ return sprintf(buf, "%u:%u\n",
+ MAJOR(dvbdev->adapter->mdev->devnode->dev.devt),
+ MINOR(dvbdev->adapter->mdev->devnode->dev.devt));
+}
+static DEVICE_ATTR_RO(media_dev);
+
+static struct attribute *dvb_device_attrs[] = {
+ &dev_attr_media_dev.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(dvb_device);
+#endif
+
int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
const struct dvb_device *template, void *priv,
enum dvb_device_type type, int demux_sink_pads)
@@ -1056,6 +1078,9 @@ static int __init init_dvbdev(void)
}
dvb_class->dev_uevent = dvb_uevent;
dvb_class->devnode = dvb_devnode;
+#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
+ dvb_class->dev_groups = dvb_device_groups;
+#endif
return 0;
error:
Create a media_dev attribute in /sys for each dvb device which contains the media device major and minor number (or is empty if there is no associated media device). It is not created if the CONFIG_MEDIA_CONTROLLER_DVB is not defined. This makes it possible for applications like v4l2-compliance to find the associated media controller of a dvb device. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> --- drivers/media/dvb-core/dvbdev.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)