dvb core: add basic support for the media controller
Subsystems (3)
v3 cover dvb core: add basic support for the media controller
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(-)
Signature · 1 line
2.1.0
PATCH v3 1/20 media: add new types for DVB devnodes
Most of the DVB subdevs have already their own devnode.
Add support for them at the media controller API.
include/uapi/linux/media.h +8 -1
@@ -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)
Signature · 1 line
2.1.0
A message that is not in the archive (sent off-list or not yet received): 7f1ea82b1055aa490726f3af2ad22bca25e49a28.1420578087.git.mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org
Re: [PATCHv3 01/20] media: add new types for DVB devnodes
Hi Mauro,
Quoted 11 lines · Mauro Carvalho Chehab
Most of the DVB subdevs have already their own devnode.
Add support for them at the media controller API.
Signed-off-by Mauro Carvalho Chehab <[email protected]>include/uapi/linux/media.h +0
-0
include/uapi/linux/media.h struct media_device_info { · line 57
Quoted 9 lines
include/uapi/linux/media.h +5
-1@@ -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.
Quoted 7 lines
include/uapi/linux/media.h +3
-0+ +/* 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)
Signature · 4 lines
Kind regards, Sakari Ailus sakari.ailus-VuQAYsv1563Yd54FQh9/[email protected]
A message that is not in the archive (sent off-list or not yet received): 54AD3E00.5070208-VuQAYsv1563Yd54FQh9/[email protected]
Re: [PATCHv3 01/20] media: add new types for DVB devnodes
Em Wed, 07 Jan 2015 16:09:04 +0200
Sakari Ailus <sakari.ailus-VuQAYsv1563Yd54FQh9/[email protected]> escreveu:
Quoted 18 lines
Hi Mauro,
Quoted 15 lines · Mauro Carvalho Chehab
Most of the DVB subdevs have already their own devnode.
Add support for them at the media controller API.
Signed-off-by Mauro Carvalho Chehab <[email protected]>include/uapi/linux/media.h +0
-1@@ -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)
Quoted 8 lines
include/uapi/linux/media.h struct media_device_info { · line 57
Quoted 5 lines
include/uapi/linux/media.h +5
-0+#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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCHv3 01/20] media: add new types for DVB devnodes
Hi Mauro,
Quoted 51 lines · On Wednesday 07 January 2015 12:22:39 Mauro Carvalho Chehab wrote:
Em Wed, 07 Jan 2015 16:09:04 +0200 Sakari Ailus escreveu:
Quoted 17 lines
Quoted 16 lines · Mauro Carvalho Chehab
Most of the DVB subdevs have already their own devnode.
Add support for them at the media controller API.
Signed-off-by Mauro Carvalho Chehab <[email protected]>include/uapi/linux/media.h +0
-0@@ -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)Quoted 9 lines
include/uapi/linux/media.h struct media_device_info { · line 57
Quoted 6 lines
include/uapi/linux/media.h +5
-1-#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 devicesAt 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.
Quoted 5 lines
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.
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCHv3 01/20] media: add new types for DVB devnodes
Em Thu, 08 Jan 2015 18:10:13 +0200
Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/[email protected]> escreveu:
Quoted 67 lines
Hi Mauro,
Quoted 51 lines · On Wednesday 07 January 2015 12:22:39 Mauro Carvalho Chehab wrote:
Em Wed, 07 Jan 2015 16:09:04 +0200 Sakari Ailus escreveu:
Quoted 17 lines
Quoted 16 lines · Mauro Carvalho Chehab
Most of the DVB subdevs have already their own devnode.
Add support for them at the media controller API.
Signed-off-by Mauro Carvalho Chehab <[email protected]>include/uapi/linux/media.h +0
-0@@ -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)Quoted 9 lines
include/uapi/linux/media.h struct media_device_info { · line 59
Quoted 6 lines
include/uapi/linux/media.h +5
-1-#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 devicesAt 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.
Quoted 5 lines
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-ctlAs I've mentioned in a previous discussion, the
media_entitytype 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.
Quoted 3 lines
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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCHv3 01/20] media: add new types for DVB devnodes
Hi Mauro,
Quoted 71 lines · On Thursday 08 January 2015 15:44:50 Mauro Carvalho Chehab wrote:
Em Thu, 08 Jan 2015 18:10:13 +0200 Laurent Pinchart escreveu:
Quoted 66 lines · On Wednesday 07 January 2015 12:22:39 Mauro Carvalho Chehab wrote:
Quoted 51 lines
Em Wed, 07 Jan 2015 16:09:04 +0200 Sakari Ailus escreveu:
Quoted 17 lines
Quoted 16 lines · Mauro Carvalho Chehab
Most of the DVB subdevs have already their own devnode.
Add support for them at the media controller API.
Signed-off-by Mauro Carvalho Chehab <[email protected]>include/uapi/linux/media.h +0
-0@@ -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)Quoted 9 lines
include/uapi/linux/media.h struct media_device_info { · line 59
Quoted 6 lines
include/uapi/linux/media.h +5
-1-#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 devicesAt 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.
Quoted 6 lines
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_entitytype 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.Quoted 3 lines
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.
Quoted 5 lines
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.
Quoted 2 lines
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.
Quoted 5 lines
[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.
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCHv3 01/20] media: add new types for DVB devnodes
Em Sun, 11 Jan 2015 15:54:14 +0200
Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/[email protected]> escreveu:
Quoted 80 lines
Hi Mauro,
Quoted 71 lines · On Thursday 08 January 2015 15:44:50 Mauro Carvalho Chehab wrote:
Em Thu, 08 Jan 2015 18:10:13 +0200 Laurent Pinchart escreveu:
Quoted 66 lines · On Wednesday 07 January 2015 12:22:39 Mauro Carvalho Chehab wrote:
Quoted 51 lines
Em Wed, 07 Jan 2015 16:09:04 +0200 Sakari Ailus escreveu:
Quoted 17 lines
Quoted 16 lines · Mauro Carvalho Chehab
Most of the DVB subdevs have already their own devnode.
Add support for them at the media controller API.
Signed-off-by Mauro Carvalho Chehab <[email protected]>include/uapi/linux/media.h +0
-0@@ -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)Quoted 9 lines
include/uapi/linux/media.h struct media_device_info { · line 59
Quoted 6 lines
include/uapi/linux/media.h +5
-1-#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 devicesAt 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.
Quoted 6 lines
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_entitytype 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.Quoted 3 lines
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.
Quoted 5 lines
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].
Quoted 3 lines
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.
Quoted 6 lines
Quoted 3 lines
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).
Quoted 7 lines
Quoted 6 lines
[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.
PATCH v3 2/20 dvbdev: add support for media controller
In reply to Mauro Carvalho ChehabProvide 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.
drivers/media/dvb-core/dvbdev.c +61 -1
@@ -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);
drivers/media/dvb-core/dvbdev.h +13 -0
@@ -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; };
Signature · 1 line
2.1.0
PATCH v3 3/20 cx231xx: add media controller support
In reply to Mauro Carvalho ChehabLet'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.
drivers/media/usb/cx231xx/cx231xx-cards.c +54 -6
@@ -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" );
drivers/media/usb/cx231xx/cx231xx-dvb.c +3 -0
@@ -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;
drivers/media/usb/cx231xx/cx231xx.h +4 -0
@@ -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;
Signature · 1 line
2.1.0
Re: [PATCHv3 03/20] cx231xx: add media controller support
Quoted 120 lines · Mauro Carvalho Chehab
Let's add media controller support for this driver and register it for both V4L and DVB.
The media controller on this driver is not mandatory, as it can fully work without it. So, if the media controller register fails, just print an error message, but proceed with device registering.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/usb/cx231xx/cx231xx-cards.c +50
-6@@ -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 ;
drivers/media/usb/cx231xx/cx231xx-cards.c static int cx231xx_usb_probe(struct usb_interface *interface, · line 1552
Quoted 8 lines
drivers/media/usb/cx231xx/cx231xx-cards.c +4
-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?
Quoted 46 lines
drivers/media/usb/cx231xx/cx231xx-cards.c +0
-0retval =v4l2_device_register (&interface->dev, &dev->v4l2_dev);if (retval) {dev_err (d,"v4l2_device_register failed\n" );drivers/media/usb/cx231xx/cx231xx-dvb.c +3
-0@@ -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;drivers/media/usb/cx231xx/cx231xx.h +4
-1@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv3 03/20] cx231xx: add media controller support
Hi Shuah,
Em Wed, 7 Jan 2015 18:44:26 -0700
Shuah Khan <[email protected]> escreveu:
Quoted 7 lines
drivers/media/usb/cx231xx/cx231xx-cards.c static int cx231xx_usb_probe(struct usb_interface *interface, · line 1552
Quoted 3 lines
drivers/media/usb/cx231xx/cx231xx-cards.c +2
-0+/* Create v4l2 device */ + dev->v4l2_dev.mdev = dev->media_dev;When
media_device_register(mdev)fails incx231xx_media_device_register(),media_devis null? The above will simply assign null todev->v4l2_dev.mdevIs 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
PATCH v3 4/20 dvb_frontend: add media controller support for DVB frontend
In reply to Mauro Carvalho ChehabNow that the dvb core is capable of registering devices via the media controller, add support for the DVB frontend devices.
drivers/media/dvb-core/dvb_frontend.c +4 -1
@@ -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 };
Signature · 1 line
2.1.0
PATCH v3 5/20 dmxdev: add support for demux/dvr nodes at media controller
In reply to Mauro Carvalho ChehabMake the dvb core demux support aware of the media controller and register the corresponding devices.
drivers/media/dvb-core/dmxdev.c +8 -3
@@ -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;
Signature · 1 line
2.1.0
PATCH v3 6/20 dvb_ca_en50221: add support for CA node at the media controller
In reply to Mauro Carvalho ChehabMake the dvb core CA support aware of the media controller and register the corresponding devices.
drivers/media/dvb-core/dvb_ca_en50221.c +4 -2
@@ -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 */
Signature · 1 line
2.1.0
PATCH v3 7/20 dvb_net: add support for DVB net node at the media controller
In reply to Mauro Carvalho ChehabMake the dvb core network support aware of the media controller and register the corresponding devices.
drivers/media/dvb-core/dvb_net.c +4 -2
@@ -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;
Signature · 1 line
2.1.0
PATCH v3 8/20 dvbdev: add pad for the DVB devnodes
In reply to Mauro Carvalho ChehabWe 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.
drivers/media/dvb-core/dvbdev.c +36 -2
@@ -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
drivers/media/dvb-core/dvbdev.h +2 -1
@@ -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;
Signature · 1 line
2.1.0
PATCH v3 9/20 tuner-core: properly initialize media controller subdev
In reply to Mauro Carvalho ChehabProperly initialize tuner core subdev at the media controller.
That requires a new subtype at the media controller API.
drivers/media/v4l2-core/tuner-core.c +20 -0
@@ -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 ;
include/uapi/linux/media.h +2 -0
@@ -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 {
Signature · 1 line
2.1.0
PATCH v3 10/20 cx25840: fill the media controller entity
In reply to Mauro Carvalho ChehabInstead of keeping the media controller entity not initialized, fill it and create the pads for cx25840.
drivers/media/i2c/cx25840/cx25840-core.c +18 -0
@@ -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 :
drivers/media/i2c/cx25840/cx25840-core.h +3 -0
@@ -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)
Signature · 1 line
2.1.0
Re: [PATCHv3 10/20] cx25840: fill the media controller entity
Hi Mauro,
Thanks for the patch.
Quoted 20 lines · Mauro Carvalho Chehab
Instead of keeping the media controller entity not initialized, fill it and create the pads for cx25840.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/i2c/cx25840/cx25840-core.c +3
-0@@ -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 ))
drivers/media/i2c/cx25840/cx25840-core.c static int cx25840_probe(struct i2c_client *client, · line 5186
Quoted 6 lines
drivers/media/i2c/cx25840/cx25840-core.c +3
-0@@ -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 ?
drivers/media/i2c/cx25840/cx25840-core.c static int cx25840_probe(struct i2c_client *client, · line 5188
Quoted 2 lines
drivers/media/i2c/cx25840/cx25840-core.c +2
-0+ 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.
drivers/media/i2c/cx25840/cx25840-core.c static int cx25840_probe(struct i2c_client *client, · line 5195
Quoted 7 lines
drivers/media/i2c/cx25840/cx25840-core.c +7
-0+ 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.
drivers/media/i2c/cx25840/cx25840-core.c static int cx25840_probe(struct i2c_client *client, · line 5196
Quoted 1 line
drivers/media/i2c/cx25840/cx25840-core.c +1
-0+return -ENODEV ;
return ret; instead ?
Thanks,
--Prabhakar Lad
Re: [PATCHv3 10/20] cx25840: fill the media controller entity
Hi Prabhakar,
Em Wed, 7 Jan 2015 11:44:08 +0000
Prabhakar Lad <[email protected]> escreveu:
Quoted 3 lines
Hi Mauro,
Thanks for the patch.
Thanks for review.
Quoted 23 lines
Quoted 21 lines · Mauro Carvalho Chehab
Instead of keeping the media controller entity not initialized, fill it and create the pads for cx25840.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/i2c/cx25840/cx25840-core.c +3
-0@@ -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,
Quoted 7 lines
drivers/media/i2c/cx25840/cx25840-core.c static int cx25840_probe(struct i2c_client *client, · line 5186
Quoted 5 lines
drivers/media/i2c/cx25840/cx25840-core.c +3
-0sd = &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.
Quoted 4 lines
drivers/media/i2c/cx25840/cx25840-core.c static int cx25840_probe(struct i2c_client *client, · line 5188
Quoted 2 lines
drivers/media/i2c/cx25840/cx25840-core.c +2
-0+ 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.
Quoted 8 lines
drivers/media/i2c/cx25840/cx25840-core.c static int cx25840_probe(struct i2c_client *client, · line 5195
Quoted 7 lines
drivers/media/i2c/cx25840/cx25840-core.c +7
-0+ 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.
Quoted 3 lines
drivers/media/i2c/cx25840/cx25840-core.c static int cx25840_probe(struct i2c_client *client, · line 5196
Quoted 2 lines
drivers/media/i2c/cx25840/cx25840-core.c +1
-0+return -ENODEV ;return ret; instead ?
Yeah, makes sense. I'll fix that on a next spin of the patch.
Quoted 3 lines
Thanks,
--Prabhakar Lad
Signature · 2 lines
Cheers, Mauro
PATCH v3 11/20 cx231xx: initialize video/vbi pads
In reply to Mauro Carvalho ChehabBoth video and vbi are sink pads. Initialize them as such.
drivers/media/usb/cx231xx/cx231xx-video.c +12 -1
@@ -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,
drivers/media/usb/cx231xx/cx231xx.h +1 -0
@@ -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 ];
Signature · 1 line
2.1.0
PATCH v3 12/20 cx231xx: create media links for analog mode
In reply to Mauro Carvalho ChehabNow 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.
drivers/media/usb/cx231xx/cx231xx-cards.c +38 -0
@@ -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: */
Signature · 1 line
2.1.0
PATCH v3 13/20 dvbdev: represent frontend with two pads
In reply to Mauro Carvalho ChehabWhile 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.
drivers/media/dvb-core/dvbdev.c +7 -5
@@ -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 ;
Signature · 1 line
2.1.0
PATCH v3 14/20 dvbdev: add a function to create DVB media graph
In reply to Mauro Carvalho ChehabWe 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.
drivers/media/dvb-core/dvbdev.c +45 -0
@@ -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;
drivers/media/dvb-core/dvbdev.h +1 -0
@@ -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);
Signature · 1 line
2.1.0
PATCH v3 15/20 cx231xx: create DVB graph
In reply to Mauro Carvalho Chehabcx231xx 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.
drivers/media/usb/cx231xx/cx231xx-dvb.c +1 -0
@@ -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:
Signature · 1 line
2.1.0
PATCH v3 16/20 dvbdev: enable DVB-specific links
In reply to Mauro Carvalho ChehabFor 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.
drivers/media/dvb-core/dvbdev.c +3 -3
@@ -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);
Signature · 1 line
2.1.0
PATCH v3 17/20 dvb-frontend: enable tuner link when the FE thread starts
In reply to Mauro Carvalho ChehabIf 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.
drivers/media/dvb-core/dvb_frontend.c +94 -0
@@ -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 ();
Signature · 1 line
2.1.0
Re: [PATCHv3 17/20] dvb-frontend: enable tuner link when the FE thread starts
Quoted 45 lines · Mauro Carvalho Chehab
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 <[email protected]>drivers/media/dvb-core/dvb_frontend.c +31
-0@@ -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 ; +
drivers/media/dvb-core/dvb_frontend.c static void dvb_frontend_wakeup(struct dvb_frontend *fe) · line 633
Quoted 10 lines
drivers/media/dvb-core/dvb_frontend.c +10
-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?
Quoted 76 lines
drivers/media/dvb-core/dvb_frontend.c +53
-1+ +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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 18/20 cx231xx: enable tuner->decoder link at videobuf start
In reply to Mauro Carvalho ChehabThe tuner->decoder needs to be enabled when we're about to start streaming.
drivers/media/usb/cx231xx/cx231xx-video.c +71 -0
@@ -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:
Signature · 1 line
2.1.0
Re: [PATCHv3 18/20] cx231xx: enable tuner->decoder link at videobuf start
Quoted 38 lines · Mauro Carvalho Chehab
The
tuner->decoderneeds to be enabled when we're about to start streaming.Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/usb/cx231xx/cx231xx-video.c +25
-0@@ -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 ;
drivers/media/usb/cx231xx/cx231xx-video.c static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf) · line 740
Quoted 10 lines
drivers/media/usb/cx231xx/cx231xx-video.c +10
-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?
Quoted 53 lines
drivers/media/usb/cx231xx/cx231xx-video.c +36
-1+ +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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 19/20 cx231xx: create a streaming pipeline at VB start
In reply to Mauro Carvalho ChehabWhen videobuf starts, create a streaming pipeline, destroying it when the stream stops.
drivers/media/usb/cx231xx/cx231xx-video.c +24 -7
@@ -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); }
drivers/media/usb/cx231xx/cx231xx.h +2 -0
@@ -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 ];
Signature · 1 line
2.1.0
PATCH v3 20/20 dvb_frontend: start media pipeline while thread is running
In reply to Mauro Carvalho ChehabWhile 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.
drivers/media/dvb-core/dvb_frontend.c +24 -2
@@ -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 );
Signature · 1 line
2.1.0