From: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [Intel-gfx] [RFC 2/3] drm/i915/display: Configure and initialize HDMI audio capabilities
Date: Thu, 15 Jun 2023 12:37:22 +0530 [thread overview]
Message-ID: <20230615070723.2220271-3-mitulkumar.ajitkumar.golani@intel.com> (raw)
In-Reply-To: <20230615070723.2220271-1-mitulkumar.ajitkumar.golani@intel.com>
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.
--v1:
- Refactor max_channel and max_rate to this commit as it is being
initialised here
- Remove call for intel_audio_compute_eld to avoid any regression while
merge. instead call it in different commit when it is defined.
- Use int instead of unsigned int for max_channel and max_frequecy
- Update commit message and header
Signed-off-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
---
.../drm/i915/display/intel_display_types.h | 6 ++++
drivers/gpu/drm/i915/display/intel_hdmi.c | 35 +++++++++++++++++++
drivers/gpu/drm/i915/display/intel_hdmi.h | 1 +
3 files changed, 42 insertions(+)
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index ebd147180a6e..74eee87d2df1 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -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;
/*
diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
index 32157bef2eef..0188a600f9f5 100644
--- 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;
+ return bandwidth;
+}
+
+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--) {
+ 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;
+ }
+ }
+ }
+
+ pipe_config->audio.max_frequency = 0;
+ pipe_config->audio.max_channel = 0;
+}
+
int intel_hdmi_compute_config(struct intel_encoder *encoder,
struct intel_crtc_state *pipe_config,
struct drm_connector_state *conn_state)
@@ -2344,6 +2378,7 @@ int intel_hdmi_compute_config(struct intel_encoder *encoder,
pipe_config->hdmi_high_tmds_clock_ratio = true;
}
}
+ intel_hdmi_audio_compute_config(pipe_config);
intel_hdmi_compute_gcp_infoframe(encoder, pipe_config,
conn_state);
diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.h b/drivers/gpu/drm/i915/display/intel_hdmi.h
index 6b39df38d57a..6df303daf348 100644
--- a/drivers/gpu/drm/i915/display/intel_hdmi.h
+++ b/drivers/gpu/drm/i915/display/intel_hdmi.h
@@ -27,6 +27,7 @@ void intel_hdmi_init_connector(struct intel_digital_port *dig_port,
bool intel_hdmi_compute_has_hdmi_sink(struct intel_encoder *encoder,
const struct intel_crtc_state *crtc_state,
const struct drm_connector_state *conn_state);
+void intel_hdmi_audio_compute_config(struct intel_crtc_state *pipe_config);
int intel_hdmi_compute_config(struct intel_encoder *encoder,
struct intel_crtc_state *pipe_config,
struct drm_connector_state *conn_state);
--
2.25.1
next prev parent reply other threads:[~2023-06-15 7:06 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
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 1/3] drm/i915/hdmi: Optimize source audio parameter handling Mitul Golani
2023-06-15 7:07 ` Mitul Golani [this message]
2023-06-15 7:07 ` [Intel-gfx] [RFC 3/3] drm/i915/display: Add wrapper to Compute SAD Mitul Golani
2023-06-16 9:24 ` Borah, Chaitanya Kumar
2023-06-15 7:37 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for Get optimal audio frequency and channels (rev4) Patchwork
2023-06-15 8:19 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-06-15 9:49 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
-- strict thread matches above, loose matches on Subject: below --
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
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-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-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-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-09 17:42 [Intel-gfx] [RFC 0/3] Get optimal audio frequency and channels 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
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
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=20230615070723.2220271-3-mitulkumar.ajitkumar.golani@intel.com \
--to=mitulkumar.ajitkumar.golani@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/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