From: Jyri Sarha <jsarha@ti.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: liam.r.girdwood@linux.intel.com, alsa-devel@alsa-project.org,
linux-fbdev@vger.kernel.org, peter.ujfalusi@ti.com,
broonie@kernel.org, linux-omap@vger.kernel.org
Subject: Re: [PATCH 1/2] OMAPDSS: hdmi: Reconfigure and restart audio when display is enabled
Date: Fri, 28 Aug 2015 11:35:52 +0000 [thread overview]
Message-ID: <55E04798.3030905@ti.com> (raw)
In-Reply-To: <55E039FC.8090707@ti.com>
On 08/28/15 13:37, Tomi Valkeinen wrote:
>
> On 26/08/15 16:11, Jyri Sarha wrote:
>
>> diff --git a/drivers/video/fbdev/omap2/dss/hdmi5.c b/drivers/video/fbdev/omap2/dss/hdmi5.c
>> index 7f87578..f352c4b 100644
>> --- a/drivers/video/fbdev/omap2/dss/hdmi5.c
>> +++ b/drivers/video/fbdev/omap2/dss/hdmi5.c
>> @@ -352,6 +352,7 @@ static int read_edid(u8 *buf, int len)
>> static int hdmi_display_enable(struct omap_dss_device *dssdev)
>> {
>> struct omap_dss_device *out = &hdmi.output;
>> + unsigned long flags;
>> int r = 0;
>>
>> DSSDBG("ENTER hdmi_display_enable\n");
>> @@ -370,7 +371,37 @@ static int hdmi_display_enable(struct omap_dss_device *dssdev)
>> goto err0;
>> }
>>
>> + if (hdmi.audio_configured) {
>> + spin_lock_irqsave(&hdmi.audio_playing_lock, flags);
>> + hdmi_wp_audio_core_req_enable(&hdmi.wp, false);
>> + hdmi_wp_audio_enable(&hdmi.wp, false);
>> + if (hdmi.wp_idlemode > 0)
>> + REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG,
>> + hdmi.wp_idlemode, 3, 2);
>> + hdmi.wp_idlemode = -1;
>> + spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags);
>
> Here I think the audio HW is always disabled already. It has to be,
> because the whole HDMI IP has been off. So the above should not be needed.
>
>> +
>> + r = hdmi5_audio_config(&hdmi.core, &hdmi.wp, &hdmi.audio_config,
>> + hdmi.cfg.timings.pixelclock);
>> + if (r) {
>> + DSSERR("Error restoring audio configuration: %d", r);
>> + hdmi.audio_abort_cb(&hdmi.pdev->dev);
>> + hdmi.audio_configured = false;
>> + }
>> + }
>> +
>> + spin_lock_irqsave(&hdmi.audio_playing_lock, flags);
>> + if (hdmi.audio_configured && hdmi.audio_playing) {
>> + /* No-idle while playing audio, store the old value */
>> + hdmi.wp_idlemode >> + REG_GET(hdmi.wp.base, HDMI_WP_SYSCONFIG, 3, 2);
>> + REG_FLD_MOD(hdmi.wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2);
>> +
>> + hdmi_wp_audio_enable(&hdmi.wp, true);
>> + hdmi_wp_audio_core_req_enable(&hdmi.wp, true);
>> + }
>> hdmi.display_enabled = true;
>> + spin_unlock_irqrestore(&hdmi.audio_playing_lock, flags);
>
> Maybe you've looked at the locking carefully, but it's not obvious to
> me. So is hdmi_audio_start and hdmi_audio_stop the only functions that
> are called from atomic context? Every other function is protected with
> the mutex?
>
The idea is for the spinlock to make audio start, audio stop, and
updates to hdmi.display_enabled and hdmi.audio_playing variable atomic.
This is needed for the transitions from display enabled state (when
audio start/stop commands can be written to HW) to display disabled
state (when audio start/stop commands update only the hdmi.audio_playing
variable) to always serialize correctly.
IOW, the idea is to make sure the hdmi.audio_playing variable is always
in sync with what is in the HW when hdmi.display_enabled = true.
For example: when display is turned back on we take the spinlock and we
can be sure that the audio start/stop status won't change while we
update the HW according to current state and set hdmi.display_enabled to
true. After releasing the lock hdmi.display_enabled is true and all
audio_start and audio_stop commands write their stuff directly to HW.
In theory, just making hdmi.display_enabled and hdmi.audio_playing
atomic-variables and touching them always in correct oreder should be
enough, but explaining the mechanism would then be even trickier.
Cheers,
Jyri
next prev parent reply other threads:[~2015-08-28 11:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-26 13:11 [PATCH 0/2] OMAPDSS: Couple of HDMI audio fixes Jyri Sarha
2015-08-26 13:11 ` [PATCH 1/2] OMAPDSS: hdmi: Reconfigure and restart audio when display is enabled Jyri Sarha
2015-08-27 14:30 ` Tomi Valkeinen
2015-08-28 10:37 ` Tomi Valkeinen
2015-08-28 11:35 ` Jyri Sarha [this message]
2015-08-26 13:11 ` [PATCH 2/2] ASoC: omap-hdmi-audio: Set buffer bytes step constraint to 128 Jyri Sarha
2015-08-26 17:42 ` [PATCH 0/2] OMAPDSS: Couple of HDMI audio fixes Mark Brown
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=55E04798.3030905@ti.com \
--to=jsarha@ti.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=liam.r.girdwood@linux.intel.com \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=peter.ujfalusi@ti.com \
--cc=tomi.valkeinen@ti.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).