From: Jani Nikula <jani.nikula@linux.intel.com>
To: Kai Vehmanen <kai.vehmanen@linux.intel.com>,
Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
Cc: intel-gfx@lists.freedesktop.org, jyri.sarha@linux.intel.com
Subject: Re: [Intel-gfx] [RFC 2/3] drm/i915/display: Configure and initialize HDMI audio capabilities
Date: Mon, 19 Jun 2023 18:32:54 +0300 [thread overview]
Message-ID: <878rcfjwm1.fsf@intel.com> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2306191423170.3532114@eliteleevi.tm.intel.com>
On Mon, 19 Jun 2023, Kai Vehmanen <kai.vehmanen@linux.intel.com> wrote:
> Hey,
>
> replying to 9th June version (my mistake), but I checked the 15th June
> patch version and comments applied to that one as well:
>
> On Fri, 9 Jun 2023, Mitul Golani wrote:
>
>> Initialize the source audio capabilities for HDMI in crtc_state
>> property by setting them to their maximum supported values,
>> including max_channel and max_frequency. This allows for the
>> calculation of HDMI audio source capabilities with respect to
>> the available mode bandwidth. These capabilities encompass
>> parameters such as supported frequency and channel configurations.
> [...]
>> @@ -1131,6 +1131,12 @@ struct intel_crtc_state {
>>
>> struct {
>> bool has_audio;
>> +
>> + /* Audio rate in Hz */
>> + int max_frequency;
>> +
>> + /* Number of audio channels */
>> + int max_channel;
>> } audio;
>
> Comment on this below.
>
>> --- a/drivers/gpu/drm/i915/display/intel_hdmi.c
>> +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
>> @@ -2277,6 +2277,40 @@ bool intel_hdmi_compute_has_hdmi_sink(struct intel_encoder *encoder,
>> !intel_hdmi_is_cloned(crtc_state);
>> }
>>
>> +static unsigned int calc_audio_bw(int channel, int frequency)
>> +{
>> + int bits_per_sample = 32;
>> + unsigned int bandwidth = channel * frequency * bits_per_sample;
>
> Maybe unsigned for bits_per_sample as well?
Personally, I'd always go for signed ints. Integer promotions are hard.
BR,
Jani.
> And not sure how fixed this
> is, but having 32 as a define at start file with more descriptive name
> might be a good idea as well. I.e. this is the audio sample container
> size used in all calculations.
>
>> +void
>> +intel_hdmi_audio_compute_config(struct intel_crtc_state *pipe_config)
>> +{
>> + struct drm_display_mode *adjusted_mode = &pipe_config->hw.adjusted_mode;
>> + int num_of_channel, aud_rates[7] = {192000, 176000, 96000, 88000, 48000, 44100, 32000};
>> + unsigned int audio_req_bandwidth, available_blank_bandwidth, vblank, hblank;
>> +
>> + hblank = adjusted_mode->htotal - adjusted_mode->hdisplay;
>> + vblank = adjusted_mode->vtotal - adjusted_mode->vdisplay;
>> + available_blank_bandwidth = hblank * vblank *
>> + drm_mode_vrefresh(adjusted_mode) * pipe_config->pipe_bpp;
>> + for (num_of_channel = 8; num_of_channel > 0; num_of_channel--) {
>
> The maximum channel count of 8 would deserve its own define. It's pretty
> much a constant coming from the specs, but still avoid magic numbers in
> code would be preferable. Or we remove this altoghter, see below...
>
>> + for (int index = 0; index < 7; index++) {
>> + audio_req_bandwidth = calc_audio_bw(num_of_channel,
>> + aud_rates[index]);
>> + if (audio_req_bandwidth < available_blank_bandwidth) {
>
> <= ?
>
>> + pipe_config->audio.max_frequency = aud_rates[index];
>> + pipe_config->audio.max_channel = num_of_channel;
>> + return;
>> + }
>
> This will hit a problem if we have a case where bandwidth is not enough
> for 5.1 at 192kHz, but it is enough for 2ch 192kHz audio. This approach
> forces us to give preference to either channel acount or sampling rate.
>
> What if we just store the 'max audio samples per second' into pipe config:
>
> - have "int max_audio_samples_per_second;" in pipe_config
> - pipe_config->audio.max_audio_samples_per_second =
> available_blank_bandwidth / 32;
>
> Then when filtering SADs, the invidial channels+rate combination
> of each SAD is compared to the max_audio_samples_per_second and based
> on that, the SAD is either filter or passed on. What do you think?
>
> Br, Kai
>
--
Jani Nikula, Intel Open Source Graphics Center
next prev parent reply other threads:[~2023-06-19 15:33 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-09 17:42 [Intel-gfx] [RFC 0/3] Get optimal audio frequency and channels Mitul Golani
2023-06-09 17:42 ` [Intel-gfx] [RFC 1/3] drm/i915/hdmi: Optimize source audio parameter handling Mitul Golani
2023-06-09 17:42 ` [Intel-gfx] [RFC 2/3] drm/i915/display: Configure and initialize HDMI audio capabilities Mitul Golani
2023-06-19 12:25 ` Kai Vehmanen
2023-06-19 15:32 ` Jani Nikula [this message]
2023-06-20 14:34 ` Borah, Chaitanya Kumar
2023-06-21 17:05 ` Kai Vehmanen
2023-06-26 16:28 ` Golani, Mitulkumar Ajitkumar
2023-06-28 17:11 ` Kai Vehmanen
2023-06-29 3:04 ` Golani, Mitulkumar Ajitkumar
2023-06-26 16:03 ` Golani, Mitulkumar Ajitkumar
2023-06-09 17:42 ` [Intel-gfx] [RFC 3/3] drm/i915/display: Add wrapper to Compute SAD Mitul Golani
2023-06-15 3:59 ` Borah, Chaitanya Kumar
2023-06-15 7:09 ` Golani, Mitulkumar Ajitkumar
2023-06-19 11:19 ` Kai Vehmanen
2023-06-26 16:05 ` Golani, Mitulkumar Ajitkumar
2023-06-09 18:20 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for Get optimal audio frequency and channels (rev2) Patchwork
2023-06-09 18:50 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-06-11 10:18 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2023-06-15 6:31 [Intel-gfx] [RFC 0/3] Get optimal audio frequency and channels Mitul Golani
2023-06-15 6:31 ` [Intel-gfx] [RFC 2/3] drm/i915/display: Configure and initialize HDMI audio capabilities Mitul Golani
2023-06-15 7:07 [Intel-gfx] [RFC 0/3] Get optimal audio frequency and channels Mitul Golani
2023-06-15 7:07 ` [Intel-gfx] [RFC 2/3] drm/i915/display: Configure and initialize HDMI audio capabilities Mitul Golani
2023-06-26 16:38 [Intel-gfx] [RFC 0/3] Get optimal audio frequency and channels Mitul Golani
2023-06-26 16:38 ` [Intel-gfx] [RFC 2/3] drm/i915/display: Configure and initialize HDMI audio capabilities Mitul Golani
2023-06-26 17:04 ` Jani Nikula
2023-06-26 16:46 [Intel-gfx] [RFC 0/3] Get optimal audio frequency and channels Mitul Golani
2023-06-26 16:46 ` [Intel-gfx] [RFC 2/3] drm/i915/display: Configure and initialize HDMI audio capabilities Mitul Golani
2023-06-28 16:11 [Intel-gfx] [RFC 0/3] Get optimal audio frequency and channels Mitul Golani
2023-06-28 16:11 ` [Intel-gfx] [RFC 2/3] drm/i915/display: Configure and initialize HDMI audio capabilities Mitul Golani
2023-06-28 16:33 [Intel-gfx] [RFC 0/3] Get optimal audio frequency and channels Mitul Golani
2023-06-28 16:33 ` [Intel-gfx] [RFC 2/3] drm/i915/display: Configure and initialize HDMI audio capabilities Mitul Golani
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=878rcfjwm1.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jyri.sarha@linux.intel.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=mitulkumar.ajitkumar.golani@intel.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