* [PATCH RFC] dvb-usb-v2: add support for the media controller at USB driver
@ 2015-02-12 0:04 Rafael Lourenço de Lima Chehab
2015-02-12 0:11 ` Antti Palosaari
2015-02-12 9:42 ` Mauro Carvalho Chehab
0 siblings, 2 replies; 3+ messages in thread
From: Rafael Lourenço de Lima Chehab @ 2015-02-12 0:04 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: Rafael Lourenço de Lima Chehab
Create a struct media_device and add it to the dvb adapter.
Please notice that the tuner is not mapped yet by the dvb core.
Signed-off-by: Rafael Lourenço de Lima Chehab <chehabrafael@gmail.com>
---
drivers/media/usb/dvb-usb-v2/dvb_usb.h | 5 +++
drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 61 +++++++++++++++++++++++++++++
2 files changed, 66 insertions(+)
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb.h b/drivers/media/usb/dvb-usb-v2/dvb_usb.h
index 14e111e13e54..b273250d0e31 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb.h
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb.h
@@ -25,6 +25,7 @@
#include <linux/usb/input.h>
#include <linux/firmware.h>
#include <media/rc-core.h>
+#include <media/media-device.h>
#include "dvb_frontend.h"
#include "dvb_demux.h"
@@ -389,6 +390,10 @@ struct dvb_usb_device {
struct delayed_work rc_query_work;
void *priv;
+
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ struct media_device *media_dev;
+#endif
};
extern int dvb_usbv2_probe(struct usb_interface *,
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
index 1950f37df835..ea4d7bec8fc1 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
@@ -86,6 +86,8 @@ static int dvb_usbv2_i2c_init(struct dvb_usb_device *d)
goto err;
}
+ dvb_create_media_graph(d->media_dev);
+
return 0;
err:
dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
@@ -400,6 +402,55 @@ skip_feed_stop:
return ret;
}
+static void dvb_usbv2_media_device_register(struct dvb_usb_device *d)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+
+ struct media_device *mdev;
+ struct usb_device *udev = d->udev;
+ int ret;
+
+ mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+ if (!mdev)
+ return;
+
+ mdev->dev = &udev->dev;
+ strlcpy(mdev->model, d->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(&d->udev->dev,
+ "Couldn't create a media device. Error: %d\n",
+ ret);
+ kfree(mdev);
+ return;
+ }
+
+ d->media_dev = mdev;
+
+ dev_info(&d->udev->dev, "media controller created\n");
+
+#endif
+}
+
+static void dvb_usbv2_media_device_unregister (struct dvb_usb_device *d)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+ if (!d->media_dev)
+ return;
+
+ media_device_unregister(d->media_dev);
+ kfree(d->media_dev);
+ d->media_dev = NULL;
+
+#endif
+}
+
static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap)
{
int ret;
@@ -416,6 +467,11 @@ static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap)
adap->dvb_adap.priv = adap;
+#ifdef CONFIG_MEDIA_CONTROLLER
+ dvb_usbv2_media_device_register(d);
+ adap->dvb_adap.mdev = d->media_dev;
+#endif
+
if (d->props->read_mac_address) {
ret = d->props->read_mac_address(adap,
adap->dvb_adap.proposed_mac);
@@ -464,6 +520,7 @@ err_dvb_net_init:
err_dvb_dmxdev_init:
dvb_dmx_release(&adap->demux);
err_dvb_dmx_init:
+ dvb_usbv2_media_device_unregister(d);
dvb_unregister_adapter(&adap->dvb_adap);
err_dvb_register_adapter:
adap->dvb_adap.priv = NULL;
@@ -472,6 +529,8 @@ err_dvb_register_adapter:
static int dvb_usbv2_adapter_dvb_exit(struct dvb_usb_adapter *adap)
{
+ struct dvb_usb_device *d = adap_to_d(adap);
+
dev_dbg(&adap_to_d(adap)->udev->dev, "%s: adap=%d\n", __func__,
adap->id);
@@ -480,6 +539,7 @@ static int dvb_usbv2_adapter_dvb_exit(struct dvb_usb_adapter *adap)
adap->demux.dmx.close(&adap->demux.dmx);
dvb_dmxdev_release(&adap->dmxdev);
dvb_dmx_release(&adap->demux);
+ dvb_usbv2_media_device_unregister(d);
dvb_unregister_adapter(&adap->dvb_adap);
}
@@ -954,6 +1014,7 @@ void dvb_usbv2_disconnect(struct usb_interface *intf)
struct dvb_usb_device *d = usb_get_intfdata(intf);
const char *name = d->name;
struct device dev = d->udev->dev;
+
dev_dbg(&d->udev->dev, "%s: bInterfaceNumber=%d\n", __func__,
intf->cur_altsetting->desc.bInterfaceNumber);
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] dvb-usb-v2: add support for the media controller at USB driver
2015-02-12 0:04 [PATCH RFC] dvb-usb-v2: add support for the media controller at USB driver Rafael Lourenço de Lima Chehab
@ 2015-02-12 0:11 ` Antti Palosaari
2015-02-12 9:42 ` Mauro Carvalho Chehab
1 sibling, 0 replies; 3+ messages in thread
From: Antti Palosaari @ 2015-02-12 0:11 UTC (permalink / raw)
To: Rafael Lourenço de Lima Chehab, Linux Media Mailing List
Moikka!
On 02/12/2015 02:04 AM, Rafael Lourenço de Lima Chehab wrote:
> Create a struct media_device and add it to the dvb adapter.
>
> Please notice that the tuner is not mapped yet by the dvb core.
>
> Signed-off-by: Rafael Lourenço de Lima Chehab <chehabrafael@gmail.com>
> ---
> drivers/media/usb/dvb-usb-v2/dvb_usb.h | 5 +++
> drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 61 +++++++++++++++++++++++++++++
> 2 files changed, 66 insertions(+)
I am not against that patch, but I don't simply understand media
controller concept enough detailed level. So it is all up to Mauro.
regards
Antti
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] dvb-usb-v2: add support for the media controller at USB driver
2015-02-12 0:04 [PATCH RFC] dvb-usb-v2: add support for the media controller at USB driver Rafael Lourenço de Lima Chehab
2015-02-12 0:11 ` Antti Palosaari
@ 2015-02-12 9:42 ` Mauro Carvalho Chehab
1 sibling, 0 replies; 3+ messages in thread
From: Mauro Carvalho Chehab @ 2015-02-12 9:42 UTC (permalink / raw)
To: Rafael Lourenço de Lima Chehab; +Cc: Linux Media Mailing List
Em Wed, 11 Feb 2015 22:04:44 -0200
Rafael Lourenço de Lima Chehab <chehabrafael@gmail.com> escreveu:
> Create a struct media_device and add it to the dvb adapter.
>
> Please notice that the tuner is not mapped yet by the dvb core.
>
> Signed-off-by: Rafael Lourenço de Lima Chehab <chehabrafael@gmail.com>
> ---
> drivers/media/usb/dvb-usb-v2/dvb_usb.h | 5 +++
> drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 61 +++++++++++++++++++++++++++++
> 2 files changed, 66 insertions(+)
>
> diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb.h b/drivers/media/usb/dvb-usb-v2/dvb_usb.h
> index 14e111e13e54..b273250d0e31 100644
> --- a/drivers/media/usb/dvb-usb-v2/dvb_usb.h
> +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb.h
> @@ -25,6 +25,7 @@
> #include <linux/usb/input.h>
> #include <linux/firmware.h>
> #include <media/rc-core.h>
> +#include <media/media-device.h>
>
> #include "dvb_frontend.h"
> #include "dvb_demux.h"
> @@ -389,6 +390,10 @@ struct dvb_usb_device {
> struct delayed_work rc_query_work;
>
> void *priv;
> +
> +#if defined(CONFIG_MEDIA_CONTROLLER)
> + struct media_device *media_dev;
> +#endif
> };
>
> extern int dvb_usbv2_probe(struct usb_interface *,
> diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
> index 1950f37df835..ea4d7bec8fc1 100644
> --- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
> +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
> @@ -86,6 +86,8 @@ static int dvb_usbv2_i2c_init(struct dvb_usb_device *d)
> goto err;
> }
>
> + dvb_create_media_graph(d->media_dev);
> +
> return 0;
Hmm... this is being called too early. It should be called, instead, at
dvb_usbv2_adapter_frontend_init():
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
index f3d1211..0fd184c 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
@@ -86,8 +86,6 @@ static int dvb_usbv2_i2c_init(struct dvb_usb_device *d)
goto err;
}
- dvb_create_media_graph(d->media_dev);
-
return 0;
err:
dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
@@ -703,6 +701,8 @@ static int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap)
}
}
+ dvb_create_media_graph(d->media_dev);
+
return 0;
err_dvb_unregister_frontend:
With the above change, the patch looks OK on my eyes.
I did a quick test here with two devices:
$ media-ctl -p
Media controller API version 0.1.0
Media device information
------------------------
driver usb
model TerraTec Cinergy T Stick RC
serial 010101010600001
bus info 1.2
hw revision 0x200
driver version 3.19.0
Device topology
- entity 1: demux (2 pads, 2 links)
type Node subtype DVB DEMUX flags 0
device node name /dev/dvb/adapter0/demux0
pad0: Sink
<- "Afatech AF9013":1 [ENABLED]
pad1: Source
-> "dvr":0 [ENABLED]
- entity 2: dvr (1 pad, 1 link)
type Node subtype DVB DVR flags 0
device node name /dev/dvb/adapter0/dvr0
pad0: Sink
<- "demux":1 [ENABLED]
- entity 3: dvb net (0 pad, 0 link)
type Node subtype DVB NET flags 0
device node name /dev/dvb/adapter0/net0
- entity 4: Afatech AF9013 (2 pads, 1 link)
type Node subtype DVB FE flags 0
device node name /dev/dvb/adapter0/frontend0
pad0: Sink
pad1: Source
-> "demux":0 [ENABLED]
$ media-ctl -p -d /dev/media1
Media controller API version 0.1.0
Media device information
------------------------
driver usb
model DVBSky S960CI
serial 20130508
bus info 2
hw revision 0x0
driver version 3.19.0
Device topology
- entity 1: demux (2 pads, 3 links)
type Node subtype DVB DEMUX flags 0
device node name /dev/dvb/adapter1/demux0
pad0: Sink
<- "Montage M88DS3103":1 [ENABLED]
pad1: Source
-> "dvr":0 [ENABLED]
-> "ca_en50221":0 [ENABLED]
- entity 2: dvr (1 pad, 1 link)
type Node subtype DVB DVR flags 0
device node name /dev/dvb/adapter1/dvr0
pad0: Sink
<- "demux":1 [ENABLED]
- entity 3: dvb net (0 pad, 0 link)
type Node subtype DVB NET flags 0
device node name /dev/dvb/adapter1/net0
- entity 4: ca_en50221 (2 pads, 1 link)
type Node subtype DVB CA flags 0
device node name /dev/dvb/adapter1/ca0
pad0: Sink
<- "demux":1 [ENABLED]
pad1: Source
- entity 5: Montage M88DS3103 (2 pads, 1 link)
type Node subtype DVB FE flags 0
device node name /dev/dvb/adapter1/frontend0
pad0: Sink
pad1: Source
-> "demux":0 [ENABLED]
Both devices are OK on my eyes.
Regards,
Mauro
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-02-12 9:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-12 0:04 [PATCH RFC] dvb-usb-v2: add support for the media controller at USB driver Rafael Lourenço de Lima Chehab
2015-02-12 0:11 ` Antti Palosaari
2015-02-12 9:42 ` 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).