alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: shuah <shuah@kernel.org>
To: Hans Verkuil <hverkuil@xs4all.nl>,
	mchehab@kernel.org, perex@perex.cz, tiwai@suse.com
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	alsa-devel@alsa-project.org, shuah <shuah@kernel.org>
Subject: Re: [PATCH v14 5/6] au0828: fix enable and disable source audio and video inconsistencies
Date: Mon, 1 Apr 2019 08:53:17 -0600	[thread overview]
Message-ID: <43ad656a-47d7-9723-d5af-06f86d40e8a0@kernel.org> (raw)
In-Reply-To: <b67b2a75-ef2a-08df-c67c-c14bd9e33303@xs4all.nl>

On 4/1/19 5:14 AM, Hans Verkuil wrote:
> Hi Shuah,
> 
> On 3/30/19 2:54 AM, Shuah Khan wrote:
>> Enable and disable source interfaces aren't consistent in enforcing
>> how video and audio share the tuner resource.
>>
>> Fix these issues to enforce the following rules and allow
>> sharing between audio and video applications.
>>
>> - When DVB is streaming, audio/video/vbi/s-video/composite
>>    should find the resource busy. DVB holds the tuner in
>>    exclusive mode.
>> - When video is streaming, audio can share the tuner and vice versa.
>> - v4l2 allows multiple applications to open video device.
>> - Video applications call enable source multiple times during their
>>    run-time. Resource should stay locked until the last application
>>    releases it.
>> - A shared resource should stay in shared state and locked when it is
>>    in use by audio and video. More than one video application is allowed
>>    to use the tuner as long as video streaming protocol allows such usage.
>>    Resource is released when the last video/audio application releases it.
>> - S-Video and Composite hold the resource in exclusive mode.
>> - VBI allows more than vbi applications sharing and will not share
>>    with another type. When resource is locked by VBI and in use by
>>    multiple VBI applications, it should stay locked until the last
>>    application disables it.
> 
> This isn't correct: only one application at most can stream VBI, but
> VBI can be shared with video and audio streaming.
> 
> All three come from the same source (analog TV), so as long as one of
> these is streaming the analog tuner resource is in use.
> 
> With this patch it seems that streaming VBI blocks streaming audio/video
> and vice versa. That's wrong.

Right. The reason I went this route is that VBI streaming stops even
when another VBI starts to stream. I am debugging this. Looks like
you have a fix for this from reading below.

> 
> Otherwise everything looks OK, except for a typo below.
> 

Will fix the typos and also I noticed, I forgot to catch updating
Copyright in one of the files.

>>
>> Signed-off-by: Shuah Khan <shuah@kernel.org>
>> ---
>>   drivers/media/usb/au0828/au0828-core.c | 182 +++++++++++++++++++------
>>   drivers/media/usb/au0828/au0828.h      |   5 +-
>>   2 files changed, 148 insertions(+), 39 deletions(-)
>>
>> diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
>> index 4f8ba6f64d3c..b8bcab2fa1dc 100644
>> --- a/drivers/media/usb/au0828/au0828-core.c
>> +++ b/drivers/media/usb/au0828/au0828-core.c
>> @@ -272,6 +272,27 @@ static void au0828_media_graph_notify(struct media_entity *new,
>>   	}
>>   }
>>   
>> +static bool au0828_is_link_sharable(struct media_entity *owner,
>> +				    struct media_entity *entity)
>> +{
>> +	bool sharable = false;
> 
> typo: sharable -> shareable
> 
> Also in the function name: do a search-and-replace for this.

Will do.

> 
>> +
>> +	/* Tuner link can be shared by audio and video */
> 
> add: and VBI
> 
> I think the core issue is here since VBI should be included with
> IO_V4L and AUDIO_CAPTURE.
> 
>> +	switch (owner->function) {
>> +	case MEDIA_ENT_F_IO_V4L:
>> +	case MEDIA_ENT_F_AUDIO_CAPTURE:
>> +		if (entity->function == MEDIA_ENT_F_IO_V4L ||
>> +		    entity->function == MEDIA_ENT_F_AUDIO_CAPTURE)
>> +			sharable = true;
>> +		break;
>> +	case MEDIA_ENT_F_DTV_DEMOD:
>> +	case MEDIA_ENT_F_IO_VBI:
>> +	default:
>> +		break;
>> +	}
>> +	return sharable;
> 
> I hacked this function so VBI is included with IO_V4L/AUDIO_CAPTURE
> and now it works.
> 

Yes. Y have been debugging with VBI included in the sharing, however
running into the below problem. Do you have the patch I can use to
test with this series?

> There is one remaining issue (but that was always a problem with au0828):
> when streaming is in progress from both video and vbi, and then you stop
> the video streaming, then vbi stops as well.
> 
> au0828_stop_streaming() calls v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
> which it should only do when the last user disappears. I'll post a patch
> for au0828 to fix this.
> 

Thanks for finding this problem. I narrowed it to close and didn't get
a chance to play with it.

thanks,
-- Shuah

  reply	other threads:[~2019-04-01 14:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-30  1:53 [PATCH v14 0/6] Media Device Allocator API Shuah Khan
2019-03-30  1:53 ` [PATCH v14 1/6] media: " Shuah Khan
2019-03-30  1:53 ` [PATCH v14 2/6] media: change au0828 to use " Shuah Khan
2019-03-30  1:53 ` [PATCH v14 3/6] media: media.h: Enable ALSA MEDIA_INTF_T* interface types Shuah Khan
2019-03-30  1:53 ` [PATCH v14 4/6] sound/usb: Use Media Controller API to share media resources Shuah Khan
2019-03-30  1:54 ` [PATCH v14 5/6] au0828: fix enable and disable source audio and video inconsistencies Shuah Khan
2019-04-01 11:14   ` Hans Verkuil
2019-04-01 14:53     ` shuah [this message]
2019-03-30  1:54 ` [PATCH v14 6/6] selftests: media_dev_allocator api test Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43ad656a-47d7-9723-d5af-06f86d40e8a0@kernel.org \
    --to=shuah@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).