* [PATCH] au0828: Cache the decoder info at au0828 dev structure
@ 2015-06-18 16:09 Mauro Carvalho Chehab
2015-06-18 16:43 ` Hans Verkuil
0 siblings, 1 reply; 2+ messages in thread
From: Mauro Carvalho Chehab @ 2015-06-18 16:09 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab
Instead of seeking for the decoder every time analog stream is
started, cache it.
Requested-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
---
drivers/media/usb/au0828/au0828-video.c | 37 ++++++++++++++++++---------------
drivers/media/usb/au0828/au0828.h | 1 +
2 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 4ebe13673adf..5f6e2aaad222 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -641,32 +641,35 @@ static int au0828_enable_analog_tuner(struct au0828_dev *dev)
{
#ifdef CONFIG_MEDIA_CONTROLLER
struct media_device *mdev = dev->media_dev;
- struct media_entity *entity, *decoder = NULL, *source;
+ struct media_entity *entity, *source;
struct media_link *link, *found_link = NULL;
int i, ret, active_links = 0;
if (!mdev)
return 0;
- /*
- * This will find the tuner that 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, as we can't
- * do DVB streaming while the DMA engine is being used for V4L2,
- * this should be enough for the actual needs.
- */
- media_device_for_each_entity(entity, mdev) {
- if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
- decoder = entity;
- break;
+ if (!dev->decoder) {
+ /*
+ * This will find the tuner that 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, as we
+ * can't do DVB streaming while the DMA engine is being used for
+ * V4L2, this should be enough for the actual needs.
+ */
+ media_device_for_each_entity(entity, mdev) {
+ if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
+ dev->decoder = entity;
+ break;
+ }
}
+
+ if (!dev->decoder)
+ return 0;
}
- if (!decoder)
- return 0;
- for (i = 0; i < decoder->num_links; i++) {
- link = &decoder->links[i];
- if (link->sink->entity == decoder) {
+ for (i = 0; i < dev->decoder->num_links; i++) {
+ link = &dev->decoder->links[i];
+ if (link->sink->entity == dev->decoder) {
found_link = link;
if (link->flags & MEDIA_LNK_FL_ENABLED)
active_links++;
diff --git a/drivers/media/usb/au0828/au0828.h b/drivers/media/usb/au0828/au0828.h
index 7e6a3bbc68ab..d3644b3fe6fa 100644
--- a/drivers/media/usb/au0828/au0828.h
+++ b/drivers/media/usb/au0828/au0828.h
@@ -280,6 +280,7 @@ struct au0828_dev {
#ifdef CONFIG_MEDIA_CONTROLLER
struct media_device *media_dev;
struct media_pad video_pad, vbi_pad;
+ struct media_entity *decoder;
#endif
};
--
2.4.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] au0828: Cache the decoder info at au0828 dev structure
2015-06-18 16:09 [PATCH] au0828: Cache the decoder info at au0828 dev structure Mauro Carvalho Chehab
@ 2015-06-18 16:43 ` Hans Verkuil
0 siblings, 0 replies; 2+ messages in thread
From: Hans Verkuil @ 2015-06-18 16:43 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Linux Media Mailing List; +Cc: Mauro Carvalho Chehab
On 06/18/2015 06:09 PM, Mauro Carvalho Chehab wrote:
> Instead of seeking for the decoder every time analog stream is
> started, cache it.
>
> Requested-by: Hans Verkuil <hverkuil@xs4all.nl>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> ---
> drivers/media/usb/au0828/au0828-video.c | 37 ++++++++++++++++++---------------
> drivers/media/usb/au0828/au0828.h | 1 +
> 2 files changed, 21 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
> index 4ebe13673adf..5f6e2aaad222 100644
> --- a/drivers/media/usb/au0828/au0828-video.c
> +++ b/drivers/media/usb/au0828/au0828-video.c
> @@ -641,32 +641,35 @@ static int au0828_enable_analog_tuner(struct au0828_dev *dev)
> {
> #ifdef CONFIG_MEDIA_CONTROLLER
> struct media_device *mdev = dev->media_dev;
> - struct media_entity *entity, *decoder = NULL, *source;
> + struct media_entity *entity, *source;
> struct media_link *link, *found_link = NULL;
> int i, ret, active_links = 0;
>
> if (!mdev)
> return 0;
>
> - /*
> - * This will find the tuner that 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, as we can't
> - * do DVB streaming while the DMA engine is being used for V4L2,
> - * this should be enough for the actual needs.
> - */
> - media_device_for_each_entity(entity, mdev) {
> - if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
> - decoder = entity;
> - break;
> + if (!dev->decoder) {
> + /*
> + * This will find the tuner that 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, as we
> + * can't do DVB streaming while the DMA engine is being used for
> + * V4L2, this should be enough for the actual needs.
> + */
> + media_device_for_each_entity(entity, mdev) {
> + if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
> + dev->decoder = entity;
> + break;
> + }
No, this is still searching unnecessary. Look in au0828_card_analog_fe_setup(),
which is where the au8522 is loaded (and that's the only decoder used by this driver):
just store the &sd->entity pointer in the decoder field and you're done. You can
drop this whole 'if (!dev->decoder)' part here.
BTW, the comment in the 'if' block belongs to 'for' loop below.
Regards,
Hans
> }
> +
> + if (!dev->decoder)
> + return 0;
> }
> - if (!decoder)
> - return 0;
>
> - for (i = 0; i < decoder->num_links; i++) {
> - link = &decoder->links[i];
> - if (link->sink->entity == decoder) {
> + for (i = 0; i < dev->decoder->num_links; i++) {
> + link = &dev->decoder->links[i];
> + if (link->sink->entity == dev->decoder) {
> found_link = link;
> if (link->flags & MEDIA_LNK_FL_ENABLED)
> active_links++;
> diff --git a/drivers/media/usb/au0828/au0828.h b/drivers/media/usb/au0828/au0828.h
> index 7e6a3bbc68ab..d3644b3fe6fa 100644
> --- a/drivers/media/usb/au0828/au0828.h
> +++ b/drivers/media/usb/au0828/au0828.h
> @@ -280,6 +280,7 @@ struct au0828_dev {
> #ifdef CONFIG_MEDIA_CONTROLLER
> struct media_device *media_dev;
> struct media_pad video_pad, vbi_pad;
> + struct media_entity *decoder;
> #endif
> };
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-18 16:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-18 16:09 [PATCH] au0828: Cache the decoder info at au0828 dev structure Mauro Carvalho Chehab
2015-06-18 16:43 ` Hans Verkuil
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).