diff options
author | Rafael Lourenço de Lima Chehab <chehabrafael@gmail.com> | 2015-02-13 18:29:14 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-02-26 09:52:26 -0300 |
commit | 496ccf92b9b5342b995a711829de76c320a916b6 (patch) | |
tree | 36ccaadc4fe701b1a96db88569c2da59c92a236b /drivers/media/usb | |
parent | 823b460ee76d0e4e1a9d50e7c1d4aebc0e9e467b (diff) | |
download | linux-496ccf92b9b5342b995a711829de76c320a916b6.tar.bz2 |
[media] dvb-usb: add support for the media controller at USB driver
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.
[mchehab@osg.samsung.com: use config option MEDIA_CONTROLLER_DVB]
Signed-off-by: Rafael Lourenço de Lima Chehab <chehabrafael@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/usb')
-rw-r--r-- | drivers/media/usb/dvb-usb/dvb-usb-dvb.c | 58 | ||||
-rw-r--r-- | drivers/media/usb/dvb-usb/dvb-usb.h | 4 |
2 files changed, 62 insertions, 0 deletions
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c index 719413b15f20..d0b0f3071422 100644 --- a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c +++ b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c @@ -94,6 +94,55 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) return dvb_usb_ctrl_feed(dvbdmxfeed,0); } +static void dvb_usb_media_device_register(struct dvb_usb_device *d) +{ +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + + 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->desc->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_usb_media_device_unregister(struct dvb_usb_device *d) +{ +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + if (!d->media_dev) + return; + + media_device_unregister(d->media_dev); + kfree(d->media_dev); + d->media_dev = NULL; + +#endif +} + int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap, short *adapter_nums) { int i; @@ -107,6 +156,11 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap, short *adapter_nums) } adap->dvb_adap.priv = adap; +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + dvb_usb_media_device_register(adap->dev); + adap->dvb_adap.mdev = adap->dev->media_dev; +#endif + if (adap->dev->props.read_mac_address) { if (adap->dev->props.read_mac_address(adap->dev,adap->dvb_adap.proposed_mac) == 0) info("MAC address: %pM",adap->dvb_adap.proposed_mac); @@ -154,6 +208,7 @@ err_net_init: err_dmx_dev: dvb_dmx_release(&adap->demux); err_dmx: + dvb_usb_media_device_unregister(adap->dev); dvb_unregister_adapter(&adap->dvb_adap); err: return ret; @@ -167,6 +222,7 @@ int dvb_usb_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_usb_media_device_unregister(adap->dev); dvb_unregister_adapter(&adap->dvb_adap); adap->state &= ~DVB_USB_ADAP_STATE_DVB; } @@ -268,6 +324,8 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap) adap->num_frontends_initialized++; } + dvb_create_media_graph(adap->dev->media_dev); + return 0; } diff --git a/drivers/media/usb/dvb-usb/dvb-usb.h b/drivers/media/usb/dvb-usb/dvb-usb.h index ce4c4e3b58bb..8d37f1e5ff23 100644 --- a/drivers/media/usb/dvb-usb/dvb-usb.h +++ b/drivers/media/usb/dvb-usb/dvb-usb.h @@ -453,6 +453,10 @@ struct dvb_usb_device { struct module *owner; void *priv; + +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + struct media_device *media_dev; +#endif }; extern int dvb_usb_device_init(struct usb_interface *, |