2014-10-27 16:26:43 +02:00
|
|
|
/*
|
|
|
|
* Copyright © 2014 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2015-01-08 17:54:14 +02:00
|
|
|
#include <linux/component.h>
|
2019-04-05 14:00:03 +03:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
|
|
|
|
#include <drm/drm_edid.h>
|
2023-10-31 12:16:40 +02:00
|
|
|
#include <drm/drm_eld.h>
|
2024-08-05 18:07:54 +03:00
|
|
|
#include <drm/drm_fixed.h>
|
2025-04-17 12:10:37 +03:00
|
|
|
#include <drm/drm_print.h>
|
2024-05-30 16:19:04 +03:00
|
|
|
#include <drm/intel/i915_component.h>
|
2014-10-27 16:26:43 +02:00
|
|
|
|
2019-10-15 22:30:24 +03:00
|
|
|
#include "intel_atomic.h"
|
2019-04-05 14:00:03 +03:00
|
|
|
#include "intel_audio.h"
|
2022-06-02 12:45:42 +03:00
|
|
|
#include "intel_audio_regs.h"
|
2020-01-21 16:03:53 +02:00
|
|
|
#include "intel_cdclk.h"
|
2021-12-08 13:05:17 +02:00
|
|
|
#include "intel_crtc.h"
|
2021-04-30 17:39:44 +03:00
|
|
|
#include "intel_de.h"
|
2019-08-06 14:39:33 +03:00
|
|
|
#include "intel_display_types.h"
|
2019-05-02 18:02:41 +03:00
|
|
|
#include "intel_lpe_audio.h"
|
2014-10-27 16:26:43 +02:00
|
|
|
|
2014-10-27 16:27:00 +02:00
|
|
|
/**
|
|
|
|
* DOC: High Definition Audio over HDMI and Display Port
|
|
|
|
*
|
|
|
|
* The graphics and audio drivers together support High Definition Audio over
|
|
|
|
* HDMI and Display Port. The audio programming sequences are divided into audio
|
|
|
|
* codec and controller enable and disable sequences. The graphics driver
|
|
|
|
* handles the audio codec sequences, while the audio driver handles the audio
|
|
|
|
* controller sequences.
|
|
|
|
*
|
|
|
|
* The disable sequences must be performed before disabling the transcoder or
|
|
|
|
* port. The enable sequences may only be performed after enabling the
|
2015-07-02 16:05:27 +03:00
|
|
|
* transcoder and port, and after completed link training. Therefore the audio
|
|
|
|
* enable/disable sequences are part of the modeset sequence.
|
2014-10-27 16:27:00 +02:00
|
|
|
*
|
|
|
|
* The codec and controller sequences could be done either parallel or serial,
|
|
|
|
* but generally the ELDV/PD change in the codec sequence indicates to the audio
|
|
|
|
* driver that the controller sequence should start. Indeed, most of the
|
|
|
|
* co-operation between the graphics and audio drivers is handled via audio
|
|
|
|
* related registers. (The notable exception is the power management, not
|
|
|
|
* covered here.)
|
2015-10-01 17:01:09 +08:00
|
|
|
*
|
2016-08-12 22:48:37 +02:00
|
|
|
* The struct &i915_audio_component is used to interact between the graphics
|
|
|
|
* and audio drivers. The struct &i915_audio_component_ops @ops in it is
|
2015-10-01 17:01:09 +08:00
|
|
|
* defined in graphics driver and called in audio driver. The
|
2016-08-12 22:48:37 +02:00
|
|
|
* struct &i915_audio_component_audio_ops @audio_ops is called from i915 driver.
|
2014-10-27 16:27:00 +02:00
|
|
|
*/
|
|
|
|
|
2021-11-04 18:18:56 +02:00
|
|
|
struct intel_audio_funcs {
|
|
|
|
void (*audio_codec_enable)(struct intel_encoder *encoder,
|
|
|
|
const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct drm_connector_state *conn_state);
|
|
|
|
void (*audio_codec_disable)(struct intel_encoder *encoder,
|
|
|
|
const struct intel_crtc_state *old_crtc_state,
|
|
|
|
const struct drm_connector_state *old_conn_state);
|
2023-01-24 16:46:21 +02:00
|
|
|
void (*audio_codec_get_config)(struct intel_encoder *encoder,
|
|
|
|
struct intel_crtc_state *crtc_state);
|
2021-11-04 18:18:56 +02:00
|
|
|
};
|
|
|
|
|
2019-06-27 15:07:08 -07:00
|
|
|
struct hdmi_aud_ncts {
|
|
|
|
int sample_rate;
|
|
|
|
int clock;
|
|
|
|
int n;
|
|
|
|
int cts;
|
|
|
|
};
|
|
|
|
|
2014-10-27 16:26:44 +02:00
|
|
|
static const struct {
|
2014-10-27 16:26:43 +02:00
|
|
|
int clock;
|
|
|
|
u32 config;
|
|
|
|
} hdmi_audio_clock[] = {
|
2015-10-08 11:43:34 +03:00
|
|
|
{ 25175, AUD_CONFIG_PIXEL_CLOCK_HDMI_25175 },
|
2014-10-27 16:26:43 +02:00
|
|
|
{ 25200, AUD_CONFIG_PIXEL_CLOCK_HDMI_25200 }, /* default per bspec */
|
|
|
|
{ 27000, AUD_CONFIG_PIXEL_CLOCK_HDMI_27000 },
|
2015-10-08 11:43:34 +03:00
|
|
|
{ 27027, AUD_CONFIG_PIXEL_CLOCK_HDMI_27027 },
|
2014-10-27 16:26:43 +02:00
|
|
|
{ 54000, AUD_CONFIG_PIXEL_CLOCK_HDMI_54000 },
|
2015-10-08 11:43:34 +03:00
|
|
|
{ 54054, AUD_CONFIG_PIXEL_CLOCK_HDMI_54054 },
|
|
|
|
{ 74176, AUD_CONFIG_PIXEL_CLOCK_HDMI_74176 },
|
2014-10-27 16:26:43 +02:00
|
|
|
{ 74250, AUD_CONFIG_PIXEL_CLOCK_HDMI_74250 },
|
2015-10-08 11:43:34 +03:00
|
|
|
{ 148352, AUD_CONFIG_PIXEL_CLOCK_HDMI_148352 },
|
2014-10-27 16:26:43 +02:00
|
|
|
{ 148500, AUD_CONFIG_PIXEL_CLOCK_HDMI_148500 },
|
2020-03-10 18:23:38 +02:00
|
|
|
{ 296703, AUD_CONFIG_PIXEL_CLOCK_HDMI_296703 },
|
|
|
|
{ 297000, AUD_CONFIG_PIXEL_CLOCK_HDMI_297000 },
|
|
|
|
{ 593407, AUD_CONFIG_PIXEL_CLOCK_HDMI_593407 },
|
|
|
|
{ 594000, AUD_CONFIG_PIXEL_CLOCK_HDMI_594000 },
|
2014-10-27 16:26:43 +02:00
|
|
|
};
|
|
|
|
|
2015-09-02 14:11:39 +08:00
|
|
|
/* HDMI N/CTS table */
|
|
|
|
#define TMDS_297M 297000
|
2015-10-08 11:43:34 +03:00
|
|
|
#define TMDS_296M 296703
|
2018-10-25 11:52:00 -07:00
|
|
|
#define TMDS_594M 594000
|
|
|
|
#define TMDS_593M 593407
|
|
|
|
|
2019-06-27 15:07:08 -07:00
|
|
|
static const struct hdmi_aud_ncts hdmi_aud_ncts_24bpp[] = {
|
2015-09-02 14:11:39 +08:00
|
|
|
{ 32000, TMDS_296M, 5824, 421875 },
|
|
|
|
{ 32000, TMDS_297M, 3072, 222750 },
|
2018-10-31 13:54:55 -07:00
|
|
|
{ 32000, TMDS_593M, 5824, 843750 },
|
|
|
|
{ 32000, TMDS_594M, 3072, 445500 },
|
|
|
|
{ 44100, TMDS_296M, 4459, 234375 },
|
|
|
|
{ 44100, TMDS_297M, 4704, 247500 },
|
|
|
|
{ 44100, TMDS_593M, 8918, 937500 },
|
|
|
|
{ 44100, TMDS_594M, 9408, 990000 },
|
2015-09-02 14:11:39 +08:00
|
|
|
{ 88200, TMDS_296M, 8918, 234375 },
|
|
|
|
{ 88200, TMDS_297M, 9408, 247500 },
|
2018-10-31 13:54:55 -07:00
|
|
|
{ 88200, TMDS_593M, 17836, 937500 },
|
|
|
|
{ 88200, TMDS_594M, 18816, 990000 },
|
2015-09-02 14:11:39 +08:00
|
|
|
{ 176400, TMDS_296M, 17836, 234375 },
|
|
|
|
{ 176400, TMDS_297M, 18816, 247500 },
|
2018-10-31 13:54:55 -07:00
|
|
|
{ 176400, TMDS_593M, 35672, 937500 },
|
|
|
|
{ 176400, TMDS_594M, 37632, 990000 },
|
|
|
|
{ 48000, TMDS_296M, 5824, 281250 },
|
|
|
|
{ 48000, TMDS_297M, 5120, 247500 },
|
2018-10-25 11:52:00 -07:00
|
|
|
{ 48000, TMDS_593M, 5824, 562500 },
|
|
|
|
{ 48000, TMDS_594M, 6144, 594000 },
|
2018-10-31 13:54:55 -07:00
|
|
|
{ 96000, TMDS_296M, 11648, 281250 },
|
|
|
|
{ 96000, TMDS_297M, 10240, 247500 },
|
2018-10-25 11:52:00 -07:00
|
|
|
{ 96000, TMDS_593M, 11648, 562500 },
|
|
|
|
{ 96000, TMDS_594M, 12288, 594000 },
|
2018-10-31 13:54:55 -07:00
|
|
|
{ 192000, TMDS_296M, 23296, 281250 },
|
|
|
|
{ 192000, TMDS_297M, 20480, 247500 },
|
2018-10-25 11:52:00 -07:00
|
|
|
{ 192000, TMDS_593M, 23296, 562500 },
|
|
|
|
{ 192000, TMDS_594M, 24576, 594000 },
|
2015-09-02 14:11:39 +08:00
|
|
|
};
|
|
|
|
|
2019-06-27 15:07:08 -07:00
|
|
|
/* Appendix C - N & CTS values for deep color from HDMI 2.0 spec*/
|
|
|
|
/* HDMI N/CTS table for 10 bit deep color(30 bpp)*/
|
|
|
|
#define TMDS_371M 371250
|
|
|
|
#define TMDS_370M 370878
|
|
|
|
|
|
|
|
static const struct hdmi_aud_ncts hdmi_aud_ncts_30bpp[] = {
|
|
|
|
{ 32000, TMDS_370M, 5824, 527344 },
|
|
|
|
{ 32000, TMDS_371M, 6144, 556875 },
|
|
|
|
{ 44100, TMDS_370M, 8918, 585938 },
|
|
|
|
{ 44100, TMDS_371M, 4704, 309375 },
|
|
|
|
{ 88200, TMDS_370M, 17836, 585938 },
|
|
|
|
{ 88200, TMDS_371M, 9408, 309375 },
|
|
|
|
{ 176400, TMDS_370M, 35672, 585938 },
|
|
|
|
{ 176400, TMDS_371M, 18816, 309375 },
|
|
|
|
{ 48000, TMDS_370M, 11648, 703125 },
|
|
|
|
{ 48000, TMDS_371M, 5120, 309375 },
|
|
|
|
{ 96000, TMDS_370M, 23296, 703125 },
|
|
|
|
{ 96000, TMDS_371M, 10240, 309375 },
|
|
|
|
{ 192000, TMDS_370M, 46592, 703125 },
|
|
|
|
{ 192000, TMDS_371M, 20480, 309375 },
|
|
|
|
};
|
|
|
|
|
|
|
|
/* HDMI N/CTS table for 12 bit deep color(36 bpp)*/
|
|
|
|
#define TMDS_445_5M 445500
|
|
|
|
#define TMDS_445M 445054
|
|
|
|
|
|
|
|
static const struct hdmi_aud_ncts hdmi_aud_ncts_36bpp[] = {
|
|
|
|
{ 32000, TMDS_445M, 5824, 632813 },
|
|
|
|
{ 32000, TMDS_445_5M, 4096, 445500 },
|
|
|
|
{ 44100, TMDS_445M, 8918, 703125 },
|
|
|
|
{ 44100, TMDS_445_5M, 4704, 371250 },
|
|
|
|
{ 88200, TMDS_445M, 17836, 703125 },
|
|
|
|
{ 88200, TMDS_445_5M, 9408, 371250 },
|
|
|
|
{ 176400, TMDS_445M, 35672, 703125 },
|
|
|
|
{ 176400, TMDS_445_5M, 18816, 371250 },
|
|
|
|
{ 48000, TMDS_445M, 5824, 421875 },
|
|
|
|
{ 48000, TMDS_445_5M, 5120, 371250 },
|
|
|
|
{ 96000, TMDS_445M, 11648, 421875 },
|
|
|
|
{ 96000, TMDS_445_5M, 10240, 371250 },
|
|
|
|
{ 192000, TMDS_445M, 23296, 421875 },
|
|
|
|
{ 192000, TMDS_445_5M, 20480, 371250 },
|
|
|
|
};
|
|
|
|
|
2024-05-09 11:05:08 +05:30
|
|
|
/*
|
|
|
|
* WA_14020863754: Implement Audio Workaround
|
|
|
|
* Corner case with Min Hblank Fix can cause audio hang
|
|
|
|
*/
|
2025-01-08 16:04:13 +02:00
|
|
|
static bool needs_wa_14020863754(struct intel_display *display)
|
2024-05-09 11:05:08 +05:30
|
|
|
{
|
2025-02-27 17:28:18 -03:00
|
|
|
return DISPLAY_VERx100(display) == 3000 ||
|
|
|
|
DISPLAY_VERx100(display) == 2000 ||
|
2025-02-27 17:28:17 -03:00
|
|
|
DISPLAY_VERx100(display) == 1401;
|
2024-05-09 11:05:08 +05:30
|
|
|
}
|
|
|
|
|
2014-10-27 16:26:43 +02:00
|
|
|
/* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */
|
2017-10-30 20:46:53 +02:00
|
|
|
static u32 audio_config_hdmi_pixel_clock(const struct intel_crtc_state *crtc_state)
|
2014-10-27 16:26:43 +02:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(crtc_state);
|
2017-10-30 20:46:53 +02:00
|
|
|
const struct drm_display_mode *adjusted_mode =
|
2019-10-31 12:26:02 +01:00
|
|
|
&crtc_state->hw.adjusted_mode;
|
2014-10-27 16:26:43 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(hdmi_audio_clock); i++) {
|
2015-09-25 16:38:56 +03:00
|
|
|
if (adjusted_mode->crtc_clock == hdmi_audio_clock[i].clock)
|
2014-10-27 16:26:43 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (DISPLAY_VER(display) < 12 && adjusted_mode->crtc_clock > 148500)
|
2020-03-10 18:23:38 +02:00
|
|
|
i = ARRAY_SIZE(hdmi_audio_clock);
|
|
|
|
|
2014-10-27 16:26:43 +02:00
|
|
|
if (i == ARRAY_SIZE(hdmi_audio_clock)) {
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_dbg_kms(display->drm,
|
drm/i915/audio: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-1-jani.nikula@intel.com
2020-04-02 14:48:03 +03:00
|
|
|
"HDMI audio pixel clock setting for %d not found, falling back to defaults\n",
|
|
|
|
adjusted_mode->crtc_clock);
|
2014-10-27 16:26:43 +02:00
|
|
|
i = 1;
|
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_dbg_kms(display->drm,
|
drm/i915/audio: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-1-jani.nikula@intel.com
2020-04-02 14:48:03 +03:00
|
|
|
"Configuring HDMI audio for pixel clock %d (0x%08x)\n",
|
|
|
|
hdmi_audio_clock[i].clock,
|
|
|
|
hdmi_audio_clock[i].config);
|
2014-10-27 16:26:43 +02:00
|
|
|
|
|
|
|
return hdmi_audio_clock[i].config;
|
|
|
|
}
|
|
|
|
|
2017-10-30 20:46:53 +02:00
|
|
|
static int audio_config_hdmi_get_n(const struct intel_crtc_state *crtc_state,
|
2016-10-10 18:04:07 +03:00
|
|
|
int rate)
|
2015-09-02 14:11:39 +08:00
|
|
|
{
|
2019-06-27 15:07:08 -07:00
|
|
|
const struct hdmi_aud_ncts *hdmi_ncts_table;
|
|
|
|
int i, size;
|
|
|
|
|
|
|
|
if (crtc_state->pipe_bpp == 36) {
|
|
|
|
hdmi_ncts_table = hdmi_aud_ncts_36bpp;
|
|
|
|
size = ARRAY_SIZE(hdmi_aud_ncts_36bpp);
|
|
|
|
} else if (crtc_state->pipe_bpp == 30) {
|
|
|
|
hdmi_ncts_table = hdmi_aud_ncts_30bpp;
|
|
|
|
size = ARRAY_SIZE(hdmi_aud_ncts_30bpp);
|
|
|
|
} else {
|
|
|
|
hdmi_ncts_table = hdmi_aud_ncts_24bpp;
|
|
|
|
size = ARRAY_SIZE(hdmi_aud_ncts_24bpp);
|
|
|
|
}
|
2015-09-02 14:11:39 +08:00
|
|
|
|
2019-06-27 15:07:08 -07:00
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
if (rate == hdmi_ncts_table[i].sample_rate &&
|
|
|
|
crtc_state->port_clock == hdmi_ncts_table[i].clock) {
|
|
|
|
return hdmi_ncts_table[i].n;
|
2015-09-02 14:11:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-10-26 20:01:44 +03:00
|
|
|
/* ELD buffer size in dwords */
|
2025-01-08 16:04:13 +02:00
|
|
|
static int g4x_eld_buffer_size(struct intel_display *display)
|
2022-10-26 20:01:44 +03:00
|
|
|
{
|
|
|
|
u32 tmp;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
tmp = intel_de_read(display, G4X_AUD_CNTL_ST);
|
2022-10-26 20:01:44 +03:00
|
|
|
|
|
|
|
return REG_FIELD_GET(G4X_ELD_BUFFER_SIZE_MASK, tmp);
|
|
|
|
}
|
|
|
|
|
2023-01-24 16:46:21 +02:00
|
|
|
static void g4x_audio_codec_get_config(struct intel_encoder *encoder,
|
|
|
|
struct intel_crtc_state *crtc_state)
|
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2023-01-24 16:46:21 +02:00
|
|
|
u32 *eld = (u32 *)crtc_state->eld;
|
|
|
|
int eld_buffer_size, len, i;
|
|
|
|
u32 tmp;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
tmp = intel_de_read(display, G4X_AUD_CNTL_ST);
|
2023-01-24 16:46:21 +02:00
|
|
|
if ((tmp & G4X_ELD_VALID) == 0)
|
|
|
|
return;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, G4X_AUD_CNTL_ST, G4X_ELD_ADDRESS_MASK, 0);
|
2023-01-24 16:46:21 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
eld_buffer_size = g4x_eld_buffer_size(display);
|
2023-01-24 16:46:21 +02:00
|
|
|
len = min_t(int, sizeof(crtc_state->eld) / 4, eld_buffer_size);
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
2025-01-08 16:04:13 +02:00
|
|
|
eld[i] = intel_de_read(display, G4X_HDMIW_HDMIEDID);
|
2023-01-24 16:46:21 +02:00
|
|
|
}
|
|
|
|
|
2017-10-30 20:46:53 +02:00
|
|
|
static void g4x_audio_codec_disable(struct intel_encoder *encoder,
|
|
|
|
const struct intel_crtc_state *old_crtc_state,
|
|
|
|
const struct drm_connector_state *old_conn_state)
|
2014-10-27 16:26:57 +02:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2022-10-26 20:01:49 +03:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc);
|
2014-10-27 16:26:57 +02:00
|
|
|
|
|
|
|
/* Invalidate ELD */
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, G4X_AUD_CNTL_ST,
|
2022-10-26 20:01:47 +03:00
|
|
|
G4X_ELD_VALID, 0);
|
2022-10-26 20:01:49 +03:00
|
|
|
|
|
|
|
intel_crtc_wait_for_next_vblank(crtc);
|
|
|
|
intel_crtc_wait_for_next_vblank(crtc);
|
2014-10-27 16:26:57 +02:00
|
|
|
}
|
|
|
|
|
2017-10-30 20:46:53 +02:00
|
|
|
static void g4x_audio_codec_enable(struct intel_encoder *encoder,
|
|
|
|
const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct drm_connector_state *conn_state)
|
2014-10-27 16:26:43 +02:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2022-10-26 20:01:49 +03:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
|
2023-01-24 16:46:19 +02:00
|
|
|
const u32 *eld = (const u32 *)crtc_state->eld;
|
2022-10-26 20:01:45 +03:00
|
|
|
int eld_buffer_size, len, i;
|
2014-10-27 16:26:43 +02:00
|
|
|
|
2022-10-26 20:01:49 +03:00
|
|
|
intel_crtc_wait_for_next_vblank(crtc);
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, G4X_AUD_CNTL_ST,
|
2022-10-26 20:01:47 +03:00
|
|
|
G4X_ELD_VALID | G4X_ELD_ADDRESS_MASK, 0);
|
2014-10-27 16:26:43 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
eld_buffer_size = g4x_eld_buffer_size(display);
|
2023-01-24 16:46:19 +02:00
|
|
|
len = min(drm_eld_size(crtc_state->eld) / 4, eld_buffer_size);
|
2022-10-26 20:01:44 +03:00
|
|
|
|
2014-10-27 16:26:43 +02:00
|
|
|
for (i = 0; i < len; i++)
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_write(display, G4X_HDMIW_HDMIEDID, eld[i]);
|
2022-10-26 20:01:45 +03:00
|
|
|
for (; i < eld_buffer_size; i++)
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_write(display, G4X_HDMIW_HDMIEDID, 0);
|
2022-10-26 20:01:45 +03:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_WARN_ON(display->drm,
|
|
|
|
(intel_de_read(display, G4X_AUD_CNTL_ST) & G4X_ELD_ADDRESS_MASK) != 0);
|
2014-10-27 16:26:43 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, G4X_AUD_CNTL_ST,
|
2022-10-26 20:01:47 +03:00
|
|
|
0, G4X_ELD_VALID);
|
2014-10-27 16:26:43 +02:00
|
|
|
}
|
|
|
|
|
2016-10-10 18:04:03 +03:00
|
|
|
static void
|
2017-10-30 20:46:53 +02:00
|
|
|
hsw_dp_audio_config_update(struct intel_encoder *encoder,
|
|
|
|
const struct intel_crtc_state *crtc_state)
|
2016-10-10 18:04:03 +03:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2019-04-30 17:29:01 +03:00
|
|
|
enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
|
2016-10-10 18:04:03 +03:00
|
|
|
|
2024-04-30 14:48:25 +05:30
|
|
|
/* Enable time stamps. Let HW calculate Maud/Naud values */
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, HSW_AUD_CFG(cpu_transcoder),
|
2024-04-30 14:48:25 +05:30
|
|
|
AUD_CONFIG_N_VALUE_INDEX |
|
|
|
|
AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK |
|
|
|
|
AUD_CONFIG_UPPER_N_MASK |
|
|
|
|
AUD_CONFIG_LOWER_N_MASK |
|
|
|
|
AUD_CONFIG_N_PROG_ENABLE,
|
|
|
|
AUD_CONFIG_N_VALUE_INDEX);
|
2016-10-25 17:54:18 +03:00
|
|
|
|
2016-10-10 18:04:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-10-30 20:46:53 +02:00
|
|
|
hsw_hdmi_audio_config_update(struct intel_encoder *encoder,
|
|
|
|
const struct intel_crtc_state *crtc_state)
|
2016-10-10 18:04:00 +03:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
|
|
|
struct i915_audio_component *acomp = display->audio.component;
|
2019-04-30 17:29:01 +03:00
|
|
|
enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
|
2017-10-30 20:46:53 +02:00
|
|
|
enum port port = encoder->port;
|
|
|
|
int n, rate;
|
2016-10-10 18:04:00 +03:00
|
|
|
u32 tmp;
|
|
|
|
|
2017-10-30 20:46:53 +02:00
|
|
|
rate = acomp ? acomp->aud_sample_rate[port] : 0;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
tmp = intel_de_read(display, HSW_AUD_CFG(cpu_transcoder));
|
2016-10-10 18:04:00 +03:00
|
|
|
tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
|
|
|
|
tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK;
|
|
|
|
tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
|
2017-10-30 20:46:53 +02:00
|
|
|
tmp |= audio_config_hdmi_pixel_clock(crtc_state);
|
2016-10-10 18:04:03 +03:00
|
|
|
|
2017-10-30 20:46:53 +02:00
|
|
|
n = audio_config_hdmi_get_n(crtc_state, rate);
|
2016-10-25 17:54:17 +03:00
|
|
|
if (n != 0) {
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_dbg_kms(display->drm, "using N %d\n", n);
|
2016-10-25 17:54:17 +03:00
|
|
|
|
|
|
|
tmp &= ~AUD_CONFIG_N_MASK;
|
|
|
|
tmp |= AUD_CONFIG_N(n);
|
|
|
|
tmp |= AUD_CONFIG_N_PROG_ENABLE;
|
|
|
|
} else {
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_dbg_kms(display->drm, "using automatic N\n");
|
2016-10-10 18:04:00 +03:00
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_write(display, HSW_AUD_CFG(cpu_transcoder), tmp);
|
2016-10-25 17:54:18 +03:00
|
|
|
|
2016-11-11 16:46:28 +08:00
|
|
|
/*
|
|
|
|
* Let's disable "Enable CTS or M Prog bit"
|
|
|
|
* and let HW calculate the value
|
|
|
|
*/
|
2025-01-08 16:04:13 +02:00
|
|
|
tmp = intel_de_read(display, HSW_AUD_M_CTS_ENABLE(cpu_transcoder));
|
2016-11-11 16:46:28 +08:00
|
|
|
tmp &= ~AUD_M_CTS_M_PROG_ENABLE;
|
2016-10-25 17:54:18 +03:00
|
|
|
tmp &= ~AUD_M_CTS_M_VALUE_INDEX;
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_write(display, HSW_AUD_M_CTS_ENABLE(cpu_transcoder), tmp);
|
2016-10-10 18:04:00 +03:00
|
|
|
}
|
|
|
|
|
2016-10-10 18:04:03 +03:00
|
|
|
static void
|
2017-10-30 20:46:53 +02:00
|
|
|
hsw_audio_config_update(struct intel_encoder *encoder,
|
|
|
|
const struct intel_crtc_state *crtc_state)
|
2016-10-10 18:04:03 +03:00
|
|
|
{
|
2017-10-30 20:46:53 +02:00
|
|
|
if (intel_crtc_has_dp_encoder(crtc_state))
|
|
|
|
hsw_dp_audio_config_update(encoder, crtc_state);
|
2016-10-10 18:04:03 +03:00
|
|
|
else
|
2017-10-30 20:46:53 +02:00
|
|
|
hsw_hdmi_audio_config_update(encoder, crtc_state);
|
2016-10-10 18:04:03 +03:00
|
|
|
}
|
|
|
|
|
2025-05-20 17:22:19 +03:00
|
|
|
static void intel_audio_sdp_split_update(const struct intel_crtc_state *crtc_state,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
struct intel_display *display = to_intel_display(crtc_state);
|
|
|
|
enum transcoder trans = crtc_state->cpu_transcoder;
|
|
|
|
|
|
|
|
if (!HAS_DP20(display))
|
|
|
|
return;
|
|
|
|
|
|
|
|
intel_de_rmw(display, AUD_DP_2DOT0_CTRL(trans), AUD_ENABLE_SDP_SPLIT,
|
|
|
|
enable && crtc_state->sdp_split_enable ? AUD_ENABLE_SDP_SPLIT : 0);
|
|
|
|
}
|
|
|
|
|
2017-10-30 20:46:53 +02:00
|
|
|
static void hsw_audio_codec_disable(struct intel_encoder *encoder,
|
|
|
|
const struct intel_crtc_state *old_crtc_state,
|
|
|
|
const struct drm_connector_state *old_conn_state)
|
2014-10-27 16:26:50 +02:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2022-10-26 20:01:49 +03:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc);
|
2019-04-30 17:29:01 +03:00
|
|
|
enum transcoder cpu_transcoder = old_crtc_state->cpu_transcoder;
|
2014-10-27 16:26:50 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_lock(&display->audio.mutex);
|
2015-09-02 14:11:39 +08:00
|
|
|
|
2014-11-04 10:30:23 +02:00
|
|
|
/* Disable timestamps */
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, HSW_AUD_CFG(cpu_transcoder),
|
2022-10-26 20:01:47 +03:00
|
|
|
AUD_CONFIG_N_VALUE_INDEX |
|
|
|
|
AUD_CONFIG_UPPER_N_MASK |
|
|
|
|
AUD_CONFIG_LOWER_N_MASK,
|
|
|
|
AUD_CONFIG_N_PROG_ENABLE |
|
|
|
|
(intel_crtc_has_dp_encoder(old_crtc_state) ?
|
|
|
|
AUD_CONFIG_N_VALUE_INDEX : 0));
|
|
|
|
|
2022-10-26 20:01:48 +03:00
|
|
|
/* Invalidate ELD */
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, HSW_AUD_PIN_ELD_CP_VLD,
|
2022-10-26 20:01:48 +03:00
|
|
|
AUDIO_ELD_VALID(cpu_transcoder), 0);
|
|
|
|
|
2022-10-26 20:01:49 +03:00
|
|
|
intel_crtc_wait_for_next_vblank(crtc);
|
|
|
|
intel_crtc_wait_for_next_vblank(crtc);
|
|
|
|
|
2022-10-26 20:01:48 +03:00
|
|
|
/* Disable audio presence detect */
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, HSW_AUD_PIN_ELD_CP_VLD,
|
2022-10-26 20:01:47 +03:00
|
|
|
AUDIO_OUTPUT_ENABLE(cpu_transcoder), 0);
|
2015-09-02 14:11:39 +08:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (needs_wa_14020863754(display))
|
|
|
|
intel_de_rmw(display, AUD_CHICKENBIT_REG3, DACBE_DISABLE_MIN_HBLANK_FIX, 0);
|
2024-05-09 11:05:08 +05:30
|
|
|
|
2025-05-20 17:22:19 +03:00
|
|
|
intel_audio_sdp_split_update(old_crtc_state, false);
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_unlock(&display->audio.mutex);
|
2014-10-27 16:26:50 +02:00
|
|
|
}
|
|
|
|
|
2020-04-29 21:54:57 +03:00
|
|
|
static unsigned int calc_hblank_early_prog(struct intel_encoder *encoder,
|
|
|
|
const struct intel_crtc_state *crtc_state)
|
2020-04-16 16:24:19 +05:30
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2020-04-16 16:24:19 +05:30
|
|
|
unsigned int link_clks_available, link_clks_required;
|
|
|
|
unsigned int tu_data, tu_line, link_clks_active;
|
2020-04-29 21:54:55 +03:00
|
|
|
unsigned int h_active, h_total, hblank_delta, pixel_clk;
|
2023-11-10 15:40:13 +05:30
|
|
|
unsigned int fec_coeff, cdclk, vdsc_bppx16;
|
2020-04-29 21:54:56 +03:00
|
|
|
unsigned int link_clk, lanes;
|
2020-04-29 21:54:57 +03:00
|
|
|
unsigned int hblank_rise;
|
2020-04-16 16:24:19 +05:30
|
|
|
|
|
|
|
h_active = crtc_state->hw.adjusted_mode.crtc_hdisplay;
|
|
|
|
h_total = crtc_state->hw.adjusted_mode.crtc_htotal;
|
|
|
|
pixel_clk = crtc_state->hw.adjusted_mode.crtc_clock;
|
2023-11-10 15:40:13 +05:30
|
|
|
vdsc_bppx16 = crtc_state->dsc.compressed_bpp_x16;
|
2025-01-08 16:04:13 +02:00
|
|
|
cdclk = display->cdclk.hw.cdclk;
|
2020-04-16 16:24:19 +05:30
|
|
|
/* fec= 0.972261, using rounding multiplier of 1000000 */
|
|
|
|
fec_coeff = 972261;
|
2020-04-29 21:54:56 +03:00
|
|
|
link_clk = crtc_state->port_clock;
|
|
|
|
lanes = crtc_state->lane_count;
|
2020-04-16 16:24:19 +05:30
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_dbg_kms(display->drm,
|
2024-08-05 18:07:54 +03:00
|
|
|
"h_active = %u link_clk = %u : lanes = %u vdsc_bpp = " FXP_Q4_FMT " cdclk = %u\n",
|
|
|
|
h_active, link_clk, lanes, FXP_Q4_ARGS(vdsc_bppx16), cdclk);
|
2020-04-16 16:24:19 +05:30
|
|
|
|
2023-11-10 15:40:13 +05:30
|
|
|
if (WARN_ON(!link_clk || !pixel_clk || !lanes || !vdsc_bppx16 || !cdclk))
|
2020-04-20 16:16:32 +03:00
|
|
|
return 0;
|
|
|
|
|
2020-04-29 21:54:57 +03:00
|
|
|
link_clks_available = (h_total - h_active) * link_clk / pixel_clk - 28;
|
|
|
|
link_clks_required = DIV_ROUND_UP(192000 * h_total, 1000 * pixel_clk) * (48 / lanes + 2);
|
2020-04-16 16:24:19 +05:30
|
|
|
|
|
|
|
if (link_clks_available > link_clks_required)
|
|
|
|
hblank_delta = 32;
|
|
|
|
else
|
2020-04-29 21:54:57 +03:00
|
|
|
hblank_delta = DIV64_U64_ROUND_UP(mul_u32_u32(5 * (link_clk + cdclk), pixel_clk),
|
|
|
|
mul_u32_u32(link_clk, cdclk));
|
2020-04-16 16:24:19 +05:30
|
|
|
|
2023-11-10 15:40:13 +05:30
|
|
|
tu_data = div64_u64(mul_u32_u32(pixel_clk * vdsc_bppx16 * 8, 1000000),
|
|
|
|
mul_u32_u32(link_clk * lanes * 16, fec_coeff));
|
2020-04-29 21:54:57 +03:00
|
|
|
tu_line = div64_u64(h_active * mul_u32_u32(link_clk, fec_coeff),
|
|
|
|
mul_u32_u32(64 * pixel_clk, 1000000));
|
|
|
|
link_clks_active = (tu_line - 1) * 64 + tu_data;
|
2020-04-16 16:24:19 +05:30
|
|
|
|
2020-04-29 21:54:57 +03:00
|
|
|
hblank_rise = (link_clks_active + 6 * DIV_ROUND_UP(link_clks_active, 250) + 4) * pixel_clk / link_clk;
|
2020-04-16 16:24:19 +05:30
|
|
|
|
2020-04-29 21:54:57 +03:00
|
|
|
return h_active - hblank_rise + hblank_delta;
|
2020-04-16 16:24:19 +05:30
|
|
|
}
|
|
|
|
|
2020-04-29 21:54:57 +03:00
|
|
|
static unsigned int calc_samples_room(const struct intel_crtc_state *crtc_state)
|
2020-04-16 16:24:19 +05:30
|
|
|
{
|
|
|
|
unsigned int h_active, h_total, pixel_clk;
|
2020-04-29 21:54:56 +03:00
|
|
|
unsigned int link_clk, lanes;
|
2020-04-16 16:24:19 +05:30
|
|
|
|
|
|
|
h_active = crtc_state->hw.adjusted_mode.hdisplay;
|
|
|
|
h_total = crtc_state->hw.adjusted_mode.htotal;
|
|
|
|
pixel_clk = crtc_state->hw.adjusted_mode.clock;
|
2020-04-29 21:54:56 +03:00
|
|
|
link_clk = crtc_state->port_clock;
|
|
|
|
lanes = crtc_state->lane_count;
|
2020-04-16 16:24:19 +05:30
|
|
|
|
2020-04-29 21:54:57 +03:00
|
|
|
return ((h_total - h_active) * link_clk - 12 * pixel_clk) /
|
|
|
|
(pixel_clk * (48 / lanes + 2));
|
2020-04-16 16:24:19 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
static void enable_audio_dsc_wa(struct intel_encoder *encoder,
|
|
|
|
const struct intel_crtc_state *crtc_state)
|
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2023-02-22 17:14:54 +02:00
|
|
|
enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
|
2020-04-20 16:16:32 +03:00
|
|
|
unsigned int hblank_early_prog, samples_room;
|
2020-04-16 16:24:19 +05:30
|
|
|
unsigned int val;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (DISPLAY_VER(display) < 11)
|
2020-04-16 16:24:19 +05:30
|
|
|
return;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
val = intel_de_read(display, AUD_CONFIG_BE);
|
2020-04-16 16:24:19 +05:30
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (DISPLAY_VER(display) == 11)
|
2023-02-22 17:14:54 +02:00
|
|
|
val |= HBLANK_EARLY_ENABLE_ICL(cpu_transcoder);
|
2025-01-08 16:04:13 +02:00
|
|
|
else if (DISPLAY_VER(display) >= 12)
|
2023-02-22 17:14:54 +02:00
|
|
|
val |= HBLANK_EARLY_ENABLE_TGL(cpu_transcoder);
|
2020-04-16 16:24:19 +05:30
|
|
|
|
|
|
|
if (crtc_state->dsc.compression_enable &&
|
2021-05-04 11:14:01 +03:00
|
|
|
crtc_state->hw.adjusted_mode.hdisplay >= 3840 &&
|
|
|
|
crtc_state->hw.adjusted_mode.vdisplay >= 2160) {
|
2020-04-16 16:24:19 +05:30
|
|
|
/* Get hblank early enable value required */
|
2023-02-22 17:14:54 +02:00
|
|
|
val &= ~HBLANK_START_COUNT_MASK(cpu_transcoder);
|
2020-04-29 21:54:57 +03:00
|
|
|
hblank_early_prog = calc_hblank_early_prog(encoder, crtc_state);
|
2021-05-04 11:14:00 +03:00
|
|
|
if (hblank_early_prog < 32)
|
2023-02-22 17:14:54 +02:00
|
|
|
val |= HBLANK_START_COUNT(cpu_transcoder, HBLANK_START_COUNT_32);
|
2021-05-04 11:14:00 +03:00
|
|
|
else if (hblank_early_prog < 64)
|
2023-02-22 17:14:54 +02:00
|
|
|
val |= HBLANK_START_COUNT(cpu_transcoder, HBLANK_START_COUNT_64);
|
2021-05-04 11:14:00 +03:00
|
|
|
else if (hblank_early_prog < 96)
|
2023-02-22 17:14:54 +02:00
|
|
|
val |= HBLANK_START_COUNT(cpu_transcoder, HBLANK_START_COUNT_96);
|
2021-05-04 11:14:00 +03:00
|
|
|
else
|
2023-02-22 17:14:54 +02:00
|
|
|
val |= HBLANK_START_COUNT(cpu_transcoder, HBLANK_START_COUNT_128);
|
2020-04-16 16:24:19 +05:30
|
|
|
|
|
|
|
/* Get samples room value required */
|
2023-02-22 17:14:54 +02:00
|
|
|
val &= ~NUMBER_SAMPLES_PER_LINE_MASK(cpu_transcoder);
|
2020-04-29 21:54:57 +03:00
|
|
|
samples_room = calc_samples_room(crtc_state);
|
2021-05-04 11:14:00 +03:00
|
|
|
if (samples_room < 3)
|
2023-02-22 17:14:54 +02:00
|
|
|
val |= NUMBER_SAMPLES_PER_LINE(cpu_transcoder, samples_room);
|
2021-05-04 11:14:00 +03:00
|
|
|
else /* Program 0 i.e "All Samples available in buffer" */
|
2023-02-22 17:14:54 +02:00
|
|
|
val |= NUMBER_SAMPLES_PER_LINE(cpu_transcoder, 0x0);
|
2020-04-16 16:24:19 +05:30
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_write(display, AUD_CONFIG_BE, val);
|
2020-04-16 16:24:19 +05:30
|
|
|
}
|
|
|
|
|
2017-10-30 20:46:53 +02:00
|
|
|
static void hsw_audio_codec_enable(struct intel_encoder *encoder,
|
|
|
|
const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct drm_connector_state *conn_state)
|
2014-10-27 16:26:43 +02:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2022-10-26 20:01:49 +03:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
|
2019-04-30 17:29:01 +03:00
|
|
|
enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
|
2014-10-27 16:26:43 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_lock(&display->audio.mutex);
|
2015-09-02 14:11:39 +08:00
|
|
|
|
2020-04-16 16:24:19 +05:30
|
|
|
/* Enable Audio WA for 4k DSC usecases */
|
|
|
|
if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP))
|
|
|
|
enable_audio_dsc_wa(encoder, crtc_state);
|
|
|
|
|
2025-05-20 17:22:19 +03:00
|
|
|
intel_audio_sdp_split_update(crtc_state, true);
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (needs_wa_14020863754(display))
|
|
|
|
intel_de_rmw(display, AUD_CHICKENBIT_REG3, 0, DACBE_DISABLE_MIN_HBLANK_FIX);
|
2024-05-09 11:05:08 +05:30
|
|
|
|
2022-10-26 20:01:48 +03:00
|
|
|
/* Enable audio presence detect */
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, HSW_AUD_PIN_ELD_CP_VLD,
|
2022-10-26 20:01:48 +03:00
|
|
|
0, AUDIO_OUTPUT_ENABLE(cpu_transcoder));
|
|
|
|
|
2022-10-26 20:01:49 +03:00
|
|
|
intel_crtc_wait_for_next_vblank(crtc);
|
|
|
|
|
2022-10-26 20:01:48 +03:00
|
|
|
/* Invalidate ELD */
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, HSW_AUD_PIN_ELD_CP_VLD,
|
2022-10-26 20:01:48 +03:00
|
|
|
AUDIO_ELD_VALID(cpu_transcoder), 0);
|
2014-10-27 16:26:43 +02:00
|
|
|
|
2023-01-24 16:46:17 +02:00
|
|
|
/*
|
2025-01-20 13:45:16 +05:30
|
|
|
* The audio component is used to convey the ELD
|
2023-01-24 16:46:17 +02:00
|
|
|
* instead using of the hardware ELD buffer.
|
|
|
|
*/
|
2014-11-04 10:30:23 +02:00
|
|
|
|
|
|
|
/* Enable timestamps */
|
2017-10-30 20:46:53 +02:00
|
|
|
hsw_audio_config_update(encoder, crtc_state);
|
2015-09-02 14:11:39 +08:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_unlock(&display->audio.mutex);
|
2014-10-27 16:26:43 +02:00
|
|
|
}
|
|
|
|
|
2023-01-24 16:46:27 +02:00
|
|
|
struct ibx_audio_regs {
|
2022-10-26 20:01:39 +03:00
|
|
|
i915_reg_t hdmiw_hdmiedid, aud_config, aud_cntl_st, aud_cntrl_st2;
|
|
|
|
};
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
static void ibx_audio_regs_init(struct intel_display *display,
|
2022-10-26 20:01:39 +03:00
|
|
|
enum pipe pipe,
|
2023-01-24 16:46:27 +02:00
|
|
|
struct ibx_audio_regs *regs)
|
2022-10-26 20:01:39 +03:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
if (display->platform.valleyview || display->platform.cherryview) {
|
2022-10-26 20:01:39 +03:00
|
|
|
regs->hdmiw_hdmiedid = VLV_HDMIW_HDMIEDID(pipe);
|
|
|
|
regs->aud_config = VLV_AUD_CFG(pipe);
|
|
|
|
regs->aud_cntl_st = VLV_AUD_CNTL_ST(pipe);
|
|
|
|
regs->aud_cntrl_st2 = VLV_AUD_CNTL_ST2;
|
2025-04-17 12:10:36 +03:00
|
|
|
} else if (HAS_PCH_CPT(display)) {
|
2022-10-26 20:01:39 +03:00
|
|
|
regs->hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID(pipe);
|
|
|
|
regs->aud_config = CPT_AUD_CFG(pipe);
|
|
|
|
regs->aud_cntl_st = CPT_AUD_CNTL_ST(pipe);
|
|
|
|
regs->aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
|
2025-04-17 12:10:36 +03:00
|
|
|
} else if (HAS_PCH_IBX(display)) {
|
2023-01-24 16:46:28 +02:00
|
|
|
regs->hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID(pipe);
|
|
|
|
regs->aud_config = IBX_AUD_CFG(pipe);
|
|
|
|
regs->aud_cntl_st = IBX_AUD_CNTL_ST(pipe);
|
|
|
|
regs->aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
|
2022-10-26 20:01:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-24 16:46:27 +02:00
|
|
|
static void ibx_audio_codec_disable(struct intel_encoder *encoder,
|
2017-10-30 20:46:53 +02:00
|
|
|
const struct intel_crtc_state *old_crtc_state,
|
|
|
|
const struct drm_connector_state *old_conn_state)
|
2014-10-27 16:26:55 +02:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2019-10-31 12:26:03 +01:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc);
|
2017-10-30 20:46:53 +02:00
|
|
|
enum port port = encoder->port;
|
2022-10-26 20:01:47 +03:00
|
|
|
enum pipe pipe = crtc->pipe;
|
2023-01-24 16:46:27 +02:00
|
|
|
struct ibx_audio_regs regs;
|
2014-10-27 16:26:55 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (drm_WARN_ON(display->drm, port == PORT_A))
|
2015-05-04 17:20:49 +03:00
|
|
|
return;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
ibx_audio_regs_init(display, pipe, ®s);
|
2014-10-27 16:26:55 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_lock(&display->audio.mutex);
|
2022-10-26 20:01:42 +03:00
|
|
|
|
2014-10-27 16:26:55 +02:00
|
|
|
/* Disable timestamps */
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, regs.aud_config,
|
2022-10-26 20:01:47 +03:00
|
|
|
AUD_CONFIG_N_VALUE_INDEX |
|
|
|
|
AUD_CONFIG_UPPER_N_MASK |
|
|
|
|
AUD_CONFIG_LOWER_N_MASK,
|
|
|
|
AUD_CONFIG_N_PROG_ENABLE |
|
|
|
|
(intel_crtc_has_dp_encoder(old_crtc_state) ?
|
|
|
|
AUD_CONFIG_N_VALUE_INDEX : 0));
|
2014-10-27 16:26:55 +02:00
|
|
|
|
|
|
|
/* Invalidate ELD */
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, regs.aud_cntrl_st2,
|
2022-10-26 20:01:47 +03:00
|
|
|
IBX_ELD_VALID(port), 0);
|
2022-10-26 20:01:42 +03:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_unlock(&display->audio.mutex);
|
2022-10-26 20:01:49 +03:00
|
|
|
|
|
|
|
intel_crtc_wait_for_next_vblank(crtc);
|
|
|
|
intel_crtc_wait_for_next_vblank(crtc);
|
2014-10-27 16:26:55 +02:00
|
|
|
}
|
|
|
|
|
2023-01-24 16:46:27 +02:00
|
|
|
static void ibx_audio_codec_enable(struct intel_encoder *encoder,
|
2017-10-30 20:46:53 +02:00
|
|
|
const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct drm_connector_state *conn_state)
|
2014-10-27 16:26:43 +02:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2019-10-31 12:26:03 +01:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
|
2017-10-30 20:46:53 +02:00
|
|
|
enum port port = encoder->port;
|
2022-10-26 20:01:47 +03:00
|
|
|
enum pipe pipe = crtc->pipe;
|
2023-01-24 16:46:27 +02:00
|
|
|
struct ibx_audio_regs regs;
|
2014-11-04 10:31:28 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (drm_WARN_ON(display->drm, port == PORT_A))
|
2015-05-04 17:20:49 +03:00
|
|
|
return;
|
|
|
|
|
2022-10-26 20:01:49 +03:00
|
|
|
intel_crtc_wait_for_next_vblank(crtc);
|
2014-10-27 16:26:43 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
ibx_audio_regs_init(display, pipe, ®s);
|
2014-10-27 16:26:43 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_lock(&display->audio.mutex);
|
2014-10-27 16:26:43 +02:00
|
|
|
|
2014-11-04 10:31:28 +02:00
|
|
|
/* Invalidate ELD */
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, regs.aud_cntrl_st2,
|
2022-10-26 20:01:47 +03:00
|
|
|
IBX_ELD_VALID(port), 0);
|
2014-10-27 16:26:43 +02:00
|
|
|
|
2023-01-24 16:46:16 +02:00
|
|
|
/*
|
2025-01-20 13:45:16 +05:30
|
|
|
* The audio component is used to convey the ELD
|
2023-01-24 16:46:16 +02:00
|
|
|
* instead using of the hardware ELD buffer.
|
|
|
|
*/
|
2014-11-04 10:31:28 +02:00
|
|
|
|
|
|
|
/* Enable timestamps */
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, regs.aud_config,
|
2022-10-26 20:01:47 +03:00
|
|
|
AUD_CONFIG_N_VALUE_INDEX |
|
|
|
|
AUD_CONFIG_N_PROG_ENABLE |
|
|
|
|
AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK,
|
|
|
|
(intel_crtc_has_dp_encoder(crtc_state) ?
|
|
|
|
AUD_CONFIG_N_VALUE_INDEX :
|
|
|
|
audio_config_hdmi_pixel_clock(crtc_state)));
|
2022-10-26 20:01:42 +03:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_unlock(&display->audio.mutex);
|
2014-10-27 16:26:43 +02:00
|
|
|
}
|
|
|
|
|
2023-01-24 16:46:19 +02:00
|
|
|
bool intel_audio_compute_config(struct intel_encoder *encoder,
|
|
|
|
struct intel_crtc_state *crtc_state,
|
|
|
|
struct drm_connector_state *conn_state)
|
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2023-01-24 16:46:19 +02:00
|
|
|
struct drm_connector *connector = conn_state->connector;
|
|
|
|
const struct drm_display_mode *adjusted_mode =
|
|
|
|
&crtc_state->hw.adjusted_mode;
|
|
|
|
|
2024-12-06 11:43:09 +02:00
|
|
|
mutex_lock(&connector->eld_mutex);
|
2023-01-24 16:46:20 +02:00
|
|
|
if (!connector->eld[0]) {
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_dbg_kms(display->drm,
|
2023-01-24 16:46:19 +02:00
|
|
|
"Bogus ELD on [CONNECTOR:%d:%s]\n",
|
|
|
|
connector->base.id, connector->name);
|
2024-12-06 11:43:09 +02:00
|
|
|
mutex_unlock(&connector->eld_mutex);
|
2023-01-24 16:46:20 +02:00
|
|
|
return false;
|
|
|
|
}
|
2023-01-24 16:46:19 +02:00
|
|
|
|
|
|
|
BUILD_BUG_ON(sizeof(crtc_state->eld) != sizeof(connector->eld));
|
|
|
|
memcpy(crtc_state->eld, connector->eld, sizeof(crtc_state->eld));
|
|
|
|
|
|
|
|
crtc_state->eld[6] = drm_av_sync_delay(connector, adjusted_mode) / 2;
|
2024-12-06 11:43:09 +02:00
|
|
|
mutex_unlock(&connector->eld_mutex);
|
2023-01-24 16:46:19 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-10-27 16:26:50 +02:00
|
|
|
/**
|
|
|
|
* intel_audio_codec_enable - Enable the audio codec for HD audio
|
2017-10-30 20:46:53 +02:00
|
|
|
* @encoder: encoder on which to enable audio
|
2016-11-08 13:55:38 +01:00
|
|
|
* @crtc_state: pointer to the current crtc state.
|
|
|
|
* @conn_state: pointer to the current connector state.
|
2014-10-27 16:26:50 +02:00
|
|
|
*
|
|
|
|
* The enable sequences may only be performed after enabling the transcoder and
|
|
|
|
* port, and after completed link training.
|
|
|
|
*/
|
2017-10-30 20:46:53 +02:00
|
|
|
void intel_audio_codec_enable(struct intel_encoder *encoder,
|
2016-11-08 13:55:38 +01:00
|
|
|
const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct drm_connector_state *conn_state)
|
2014-10-27 16:26:43 +02:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
|
|
|
struct i915_audio_component *acomp = display->audio.component;
|
2019-10-31 12:26:03 +01:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
|
2023-01-24 16:46:18 +02:00
|
|
|
struct intel_connector *connector = to_intel_connector(conn_state->connector);
|
2023-02-22 17:14:54 +02:00
|
|
|
enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
|
2023-01-24 16:46:18 +02:00
|
|
|
struct intel_audio_state *audio_state;
|
2017-10-30 20:46:53 +02:00
|
|
|
enum port port = encoder->port;
|
2014-10-27 16:26:43 +02:00
|
|
|
|
2022-03-30 12:41:09 +03:00
|
|
|
if (!crtc_state->has_audio)
|
|
|
|
return;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_dbg_kms(display->drm,
|
|
|
|
"[CONNECTOR:%d:%s][ENCODER:%d:%s] Enable audio codec on [CRTC:%d:%s], %u bytes ELD\n",
|
2023-01-24 16:46:18 +02:00
|
|
|
connector->base.base.id, connector->base.name,
|
2022-03-30 12:41:08 +03:00
|
|
|
encoder->base.base.id, encoder->base.name,
|
2023-01-24 16:46:18 +02:00
|
|
|
crtc->base.base.id, crtc->base.name,
|
2023-01-24 16:46:19 +02:00
|
|
|
drm_eld_size(crtc_state->eld));
|
2014-10-27 16:26:43 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (display->funcs.audio)
|
|
|
|
display->funcs.audio->audio_codec_enable(encoder,
|
2022-11-08 17:18:28 +02:00
|
|
|
crtc_state,
|
|
|
|
conn_state);
|
2015-08-19 10:48:56 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_lock(&display->audio.mutex);
|
drm/i915/dp: DP audio API changes for MST
DP MST provides the capability to send multiple video and audio streams
through a single port. This requires the API's between i915 and audio
drivers to distinguish between multiple audio capable displays that can be
connected to a port. Currently only the port identity is shared in the
APIs. This patch adds support for MST with an additional parameter
'int pipe'. The existing parameter 'port' does not change it's meaning.
pipe =
MST : display pipe that the stream originates from
Non-MST : -1
Affected APIs:
struct i915_audio_component_ops
- int (*sync_audio_rate)(struct device *, int port, int rate);
+ int (*sync_audio_rate)(struct device *, int port, int pipe,
+ int rate);
- int (*get_eld)(struct device *, int port, bool *enabled,
- unsigned char *buf, int max_bytes);
+ int (*get_eld)(struct device *, int port, int pipe,
+ bool *enabled, unsigned char *buf, int max_bytes);
struct i915_audio_component_audio_ops
- void (*pin_eld_notify)(void *audio_ptr, int port);
+ void (*pin_eld_notify)(void *audio_ptr, int port, int pipe);
This patch makes dummy changes in the audio drivers (thanks Libin) for
build to succeed. The audio side drivers will send the right 'pipe' values
for MST in patches that will follow.
v2:
Renamed the new API parameter from 'dev_id' to 'pipe'. (Jim, Ville)
Included Asoc driver API compatibility changes from Jeeja.
Added WARN_ON() for invalid pipe in get_saved_encoder(). (Takashi)
Added comment for av_enc_map[] definition. (Takashi)
v3:
Fixed logic error introduced while renaming 'dev_id' as 'pipe' (Ville)
Renamed get_saved_encoder() to get_saved_enc() to reduce line length
v4:
Rebased.
Parameter check for pipe < -1 values in get_saved_enc() (Ville)
Switched to for_each_pipe() in get_saved_enc() (Ville)
Renamed 'pipe' to 'dev_id' in audio side code (Takashi)
v5:
Included a comment for the dev_id arg. (Libin)
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1474488168-2343-1-git-send-email-dhinakaran.pandiyan@intel.com
2016-09-21 13:02:48 -07:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
audio_state = &display->audio.state[cpu_transcoder];
|
2023-01-24 16:46:18 +02:00
|
|
|
|
|
|
|
audio_state->encoder = encoder;
|
2023-01-24 16:46:19 +02:00
|
|
|
BUILD_BUG_ON(sizeof(audio_state->eld) != sizeof(crtc_state->eld));
|
|
|
|
memcpy(audio_state->eld, crtc_state->eld, sizeof(audio_state->eld));
|
2023-01-24 16:46:18 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_unlock(&display->audio.mutex);
|
2015-11-12 15:23:41 +01:00
|
|
|
|
2018-07-11 15:17:22 +02:00
|
|
|
if (acomp && acomp->base.audio_ops &&
|
|
|
|
acomp->base.audio_ops->pin_eld_notify) {
|
2023-02-22 17:14:54 +02:00
|
|
|
/* audio drivers expect cpu_transcoder = -1 to indicate Non-MST cases */
|
2017-10-30 20:46:54 +02:00
|
|
|
if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP_MST))
|
2023-02-22 17:14:54 +02:00
|
|
|
cpu_transcoder = -1;
|
2018-07-11 15:17:22 +02:00
|
|
|
acomp->base.audio_ops->pin_eld_notify(acomp->base.audio_ops->audio_ptr,
|
2023-02-22 17:14:54 +02:00
|
|
|
(int)port, (int)cpu_transcoder);
|
2017-01-31 14:16:50 -06:00
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:14 +02:00
|
|
|
intel_lpe_audio_notify(display, cpu_transcoder, port, crtc_state->eld,
|
2017-04-27 19:02:24 +03:00
|
|
|
crtc_state->port_clock,
|
2017-10-30 20:46:54 +02:00
|
|
|
intel_crtc_has_dp_encoder(crtc_state));
|
2014-10-27 16:26:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* intel_audio_codec_disable - Disable the audio codec for HD audio
|
2017-10-30 20:46:53 +02:00
|
|
|
* @encoder: encoder on which to disable audio
|
2017-11-14 21:11:27 +02:00
|
|
|
* @old_crtc_state: pointer to the old crtc state.
|
|
|
|
* @old_conn_state: pointer to the old connector state.
|
2014-10-27 16:26:50 +02:00
|
|
|
*
|
|
|
|
* The disable sequences must be performed before disabling the transcoder or
|
|
|
|
* port.
|
|
|
|
*/
|
2017-10-30 20:46:53 +02:00
|
|
|
void intel_audio_codec_disable(struct intel_encoder *encoder,
|
|
|
|
const struct intel_crtc_state *old_crtc_state,
|
|
|
|
const struct drm_connector_state *old_conn_state)
|
2014-10-27 16:26:50 +02:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
|
|
|
struct i915_audio_component *acomp = display->audio.component;
|
2019-10-31 12:26:03 +01:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc);
|
2023-01-24 16:46:18 +02:00
|
|
|
struct intel_connector *connector = to_intel_connector(old_conn_state->connector);
|
2023-02-22 17:14:54 +02:00
|
|
|
enum transcoder cpu_transcoder = old_crtc_state->cpu_transcoder;
|
2023-01-24 16:46:18 +02:00
|
|
|
struct intel_audio_state *audio_state;
|
2017-10-30 20:46:53 +02:00
|
|
|
enum port port = encoder->port;
|
2014-10-27 16:26:50 +02:00
|
|
|
|
2022-03-30 12:41:09 +03:00
|
|
|
if (!old_crtc_state->has_audio)
|
|
|
|
return;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_dbg_kms(display->drm,
|
|
|
|
"[CONNECTOR:%d:%s][ENCODER:%d:%s] Disable audio codec on [CRTC:%d:%s]\n",
|
2023-01-24 16:46:18 +02:00
|
|
|
connector->base.base.id, connector->base.name,
|
|
|
|
encoder->base.base.id, encoder->base.name,
|
|
|
|
crtc->base.base.id, crtc->base.name);
|
2022-03-30 12:41:08 +03:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (display->funcs.audio)
|
|
|
|
display->funcs.audio->audio_codec_disable(encoder,
|
2022-11-08 17:18:28 +02:00
|
|
|
old_crtc_state,
|
|
|
|
old_conn_state);
|
2015-08-19 10:48:56 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_lock(&display->audio.mutex);
|
2023-01-24 16:46:18 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
audio_state = &display->audio.state[cpu_transcoder];
|
2023-01-24 16:46:18 +02:00
|
|
|
|
|
|
|
audio_state->encoder = NULL;
|
2023-01-24 16:46:19 +02:00
|
|
|
memset(audio_state->eld, 0, sizeof(audio_state->eld));
|
2023-01-24 16:46:18 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_unlock(&display->audio.mutex);
|
2015-11-12 15:23:41 +01:00
|
|
|
|
2018-07-11 15:17:22 +02:00
|
|
|
if (acomp && acomp->base.audio_ops &&
|
|
|
|
acomp->base.audio_ops->pin_eld_notify) {
|
2023-02-22 17:14:54 +02:00
|
|
|
/* audio drivers expect cpu_transcoder = -1 to indicate Non-MST cases */
|
2017-10-30 20:46:54 +02:00
|
|
|
if (!intel_crtc_has_type(old_crtc_state, INTEL_OUTPUT_DP_MST))
|
2023-02-22 17:14:54 +02:00
|
|
|
cpu_transcoder = -1;
|
2018-07-11 15:17:22 +02:00
|
|
|
acomp->base.audio_ops->pin_eld_notify(acomp->base.audio_ops->audio_ptr,
|
2023-02-22 17:14:54 +02:00
|
|
|
(int)port, (int)cpu_transcoder);
|
2017-01-31 14:16:50 -06:00
|
|
|
}
|
2017-01-25 04:27:50 +05:30
|
|
|
|
2025-01-08 16:04:14 +02:00
|
|
|
intel_lpe_audio_notify(display, cpu_transcoder, port, NULL, 0, false);
|
2014-10-27 16:26:43 +02:00
|
|
|
}
|
|
|
|
|
2023-01-24 16:46:21 +02:00
|
|
|
static void intel_acomp_get_config(struct intel_encoder *encoder,
|
|
|
|
struct intel_crtc_state *crtc_state)
|
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2023-02-22 17:14:54 +02:00
|
|
|
enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
|
2023-01-24 16:46:21 +02:00
|
|
|
struct intel_audio_state *audio_state;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_lock(&display->audio.mutex);
|
2023-01-24 16:46:21 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
audio_state = &display->audio.state[cpu_transcoder];
|
2023-01-24 16:46:21 +02:00
|
|
|
|
|
|
|
if (audio_state->encoder)
|
|
|
|
memcpy(crtc_state->eld, audio_state->eld, sizeof(audio_state->eld));
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_unlock(&display->audio.mutex);
|
2023-01-24 16:46:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void intel_audio_codec_get_config(struct intel_encoder *encoder,
|
|
|
|
struct intel_crtc_state *crtc_state)
|
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2023-01-24 16:46:21 +02:00
|
|
|
|
|
|
|
if (!crtc_state->has_audio)
|
|
|
|
return;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (display->funcs.audio)
|
|
|
|
display->funcs.audio->audio_codec_get_config(encoder, crtc_state);
|
2023-01-24 16:46:21 +02:00
|
|
|
}
|
|
|
|
|
2021-09-29 01:58:02 +03:00
|
|
|
static const struct intel_audio_funcs g4x_audio_funcs = {
|
|
|
|
.audio_codec_enable = g4x_audio_codec_enable,
|
|
|
|
.audio_codec_disable = g4x_audio_codec_disable,
|
2023-01-24 16:46:21 +02:00
|
|
|
.audio_codec_get_config = g4x_audio_codec_get_config,
|
2021-09-29 01:58:02 +03:00
|
|
|
};
|
|
|
|
|
2023-01-24 16:46:27 +02:00
|
|
|
static const struct intel_audio_funcs ibx_audio_funcs = {
|
|
|
|
.audio_codec_enable = ibx_audio_codec_enable,
|
|
|
|
.audio_codec_disable = ibx_audio_codec_disable,
|
2023-01-24 16:46:21 +02:00
|
|
|
.audio_codec_get_config = intel_acomp_get_config,
|
2021-09-29 01:58:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct intel_audio_funcs hsw_audio_funcs = {
|
|
|
|
.audio_codec_enable = hsw_audio_codec_enable,
|
|
|
|
.audio_codec_disable = hsw_audio_codec_disable,
|
2023-01-24 16:46:21 +02:00
|
|
|
.audio_codec_get_config = intel_acomp_get_config,
|
2021-09-29 01:58:02 +03:00
|
|
|
};
|
|
|
|
|
2014-10-27 16:26:43 +02:00
|
|
|
/**
|
2021-11-04 18:18:58 +02:00
|
|
|
* intel_audio_hooks_init - Set up chip specific audio hooks
|
2025-01-08 16:04:13 +02:00
|
|
|
* @display: display device
|
2014-10-27 16:26:43 +02:00
|
|
|
*/
|
2025-01-08 16:04:13 +02:00
|
|
|
void intel_audio_hooks_init(struct intel_display *display)
|
2014-10-27 16:26:43 +02:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
if (display->platform.g4x)
|
|
|
|
display->funcs.audio = &g4x_audio_funcs;
|
|
|
|
else if (display->platform.valleyview || display->platform.cherryview ||
|
2025-04-17 12:10:36 +03:00
|
|
|
HAS_PCH_CPT(display) || HAS_PCH_IBX(display))
|
2025-01-08 16:04:13 +02:00
|
|
|
display->funcs.audio = &ibx_audio_funcs;
|
|
|
|
else if (display->platform.haswell || DISPLAY_VER(display) >= 8)
|
|
|
|
display->funcs.audio = &hsw_audio_funcs;
|
2014-10-27 16:26:43 +02:00
|
|
|
}
|
2015-01-08 17:54:14 +02:00
|
|
|
|
2021-10-21 13:59:15 +03:00
|
|
|
struct aud_ts_cdclk_m_n {
|
|
|
|
u8 m;
|
|
|
|
u16 n;
|
|
|
|
};
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
void intel_audio_cdclk_change_pre(struct intel_display *display)
|
2021-10-21 13:59:15 +03:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
if (DISPLAY_VER(display) >= 13)
|
|
|
|
intel_de_rmw(display, AUD_TS_CDCLK_M, AUD_TS_CDCLK_M_EN, 0);
|
2021-10-21 13:59:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void get_aud_ts_cdclk_m_n(int refclk, int cdclk, struct aud_ts_cdclk_m_n *aud_ts)
|
|
|
|
{
|
2023-03-16 16:46:54 -07:00
|
|
|
aud_ts->m = 60;
|
2021-10-21 13:59:15 +03:00
|
|
|
aud_ts->n = cdclk * aud_ts->m / 24000;
|
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
void intel_audio_cdclk_change_post(struct intel_display *display)
|
2021-10-21 13:59:15 +03:00
|
|
|
{
|
|
|
|
struct aud_ts_cdclk_m_n aud_ts;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (DISPLAY_VER(display) >= 13) {
|
|
|
|
get_aud_ts_cdclk_m_n(display->cdclk.hw.ref,
|
|
|
|
display->cdclk.hw.cdclk, &aud_ts);
|
2021-10-21 13:59:15 +03:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_write(display, AUD_TS_CDCLK_N, aud_ts.n);
|
|
|
|
intel_de_write(display, AUD_TS_CDCLK_M, aud_ts.m | AUD_TS_CDCLK_M_EN);
|
|
|
|
drm_dbg_kms(display->drm, "aud_ts_cdclk set to M=%u, N=%u\n",
|
|
|
|
aud_ts.m, aud_ts.n);
|
2021-10-21 13:59:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-21 16:03:53 +02:00
|
|
|
static int glk_force_audio_cdclk_commit(struct intel_atomic_state *state,
|
2020-02-03 13:34:08 +00:00
|
|
|
struct intel_crtc *crtc,
|
2020-01-21 16:03:53 +02:00
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
struct intel_cdclk_state *cdclk_state;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* need to hold at least one crtc lock for the global state */
|
|
|
|
ret = drm_modeset_lock(&crtc->base.mutex, state->base.acquire_ctx);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
cdclk_state = intel_atomic_get_cdclk_state(state);
|
|
|
|
if (IS_ERR(cdclk_state))
|
|
|
|
return PTR_ERR(cdclk_state);
|
|
|
|
|
2025-06-25 13:32:31 +03:00
|
|
|
intel_cdclk_force_min_cdclk(cdclk_state, enable ? 2 * 96000 : 0);
|
2020-01-21 16:03:53 +02:00
|
|
|
|
|
|
|
return drm_atomic_commit(&state->base);
|
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
static void glk_force_audio_cdclk(struct intel_display *display,
|
2019-03-20 15:54:36 +02:00
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
struct drm_modeset_acquire_ctx ctx;
|
|
|
|
struct drm_atomic_state *state;
|
2020-02-03 13:34:08 +00:00
|
|
|
struct intel_crtc *crtc;
|
2019-03-20 15:54:36 +02:00
|
|
|
int ret;
|
|
|
|
|
2025-02-06 20:55:25 +02:00
|
|
|
crtc = intel_first_crtc(display);
|
2020-02-03 13:34:08 +00:00
|
|
|
if (!crtc)
|
|
|
|
return;
|
|
|
|
|
2019-03-20 15:54:36 +02:00
|
|
|
drm_modeset_acquire_init(&ctx, 0);
|
2025-01-08 16:04:13 +02:00
|
|
|
state = drm_atomic_state_alloc(display->drm);
|
|
|
|
if (drm_WARN_ON(display->drm, !state))
|
2019-03-20 15:54:36 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
state->acquire_ctx = &ctx;
|
2023-03-28 15:23:57 +03:00
|
|
|
to_intel_atomic_state(state)->internal = true;
|
2019-03-20 15:54:36 +02:00
|
|
|
|
|
|
|
retry:
|
2020-02-03 13:34:08 +00:00
|
|
|
ret = glk_force_audio_cdclk_commit(to_intel_atomic_state(state), crtc,
|
|
|
|
enable);
|
2019-03-20 15:54:36 +02:00
|
|
|
if (ret == -EDEADLK) {
|
|
|
|
drm_atomic_state_clear(state);
|
|
|
|
drm_modeset_backoff(&ctx);
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_WARN_ON(display->drm, ret);
|
2019-03-20 15:54:36 +02:00
|
|
|
|
|
|
|
drm_atomic_state_put(state);
|
|
|
|
|
|
|
|
drm_modeset_drop_locks(&ctx);
|
|
|
|
drm_modeset_acquire_fini(&ctx);
|
|
|
|
}
|
|
|
|
|
2024-10-29 23:52:10 +02:00
|
|
|
int intel_audio_min_cdclk(const struct intel_crtc_state *crtc_state)
|
|
|
|
{
|
|
|
|
struct intel_display *display = to_intel_display(crtc_state);
|
|
|
|
int min_cdclk = 0;
|
|
|
|
|
2024-10-29 23:52:11 +02:00
|
|
|
if (!crtc_state->has_audio)
|
|
|
|
return 0;
|
|
|
|
|
2024-10-29 23:52:10 +02:00
|
|
|
/* BSpec says "Do not use DisplayPort with CDCLK less than 432 MHz,
|
|
|
|
* audio enabled, port width x4, and link rate HBR2 (5.4 GHz), or else
|
|
|
|
* there may be audio corruption or screen corruption." This cdclk
|
|
|
|
* restriction for GLK is 316.8 MHz.
|
|
|
|
*/
|
|
|
|
if (intel_crtc_has_dp_encoder(crtc_state) &&
|
|
|
|
crtc_state->port_clock >= 540000 &&
|
|
|
|
crtc_state->lane_count == 4) {
|
|
|
|
if (DISPLAY_VER(display) == 10) {
|
|
|
|
/* Display WA #1145: glk */
|
2024-10-29 23:52:17 +02:00
|
|
|
min_cdclk = max(min_cdclk, 316800);
|
2025-01-08 16:04:13 +02:00
|
|
|
} else if (DISPLAY_VER(display) == 9 || display->platform.broadwell) {
|
2024-10-29 23:52:10 +02:00
|
|
|
/* Display WA #1144: skl,bxt */
|
2024-10-29 23:52:17 +02:00
|
|
|
min_cdclk = max(min_cdclk, 432000);
|
2024-10-29 23:52:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* According to BSpec, "The CD clock frequency must be at least twice
|
|
|
|
* the frequency of the Azalia BCLK." and BCLK is 96 MHz by default.
|
|
|
|
*/
|
2024-10-29 23:52:11 +02:00
|
|
|
if (DISPLAY_VER(display) >= 9)
|
2024-10-29 23:52:17 +02:00
|
|
|
min_cdclk = max(min_cdclk, 2 * 96000);
|
2024-10-29 23:52:10 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* "For DP audio configuration, cdclk frequency shall be set to
|
|
|
|
* meet the following requirements:
|
|
|
|
* DP Link Frequency(MHz) | Cdclk frequency(MHz)
|
|
|
|
* 270 | 320 or higher
|
|
|
|
* 162 | 200 or higher"
|
|
|
|
*/
|
2025-01-08 16:04:13 +02:00
|
|
|
if ((display->platform.valleyview || display->platform.cherryview) &&
|
2024-10-29 23:52:11 +02:00
|
|
|
intel_crtc_has_dp_encoder(crtc_state))
|
2024-10-29 23:52:17 +02:00
|
|
|
min_cdclk = max(min_cdclk, crtc_state->port_clock);
|
2024-10-29 23:52:10 +02:00
|
|
|
|
|
|
|
return min_cdclk;
|
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:15 +02:00
|
|
|
static unsigned long intel_audio_component_get_power(struct device *kdev)
|
2015-01-08 17:54:14 +02:00
|
|
|
{
|
2024-08-29 17:47:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(kdev);
|
2024-09-18 20:35:47 +03:00
|
|
|
intel_wakeref_t wakeref;
|
2019-03-20 15:54:36 +02:00
|
|
|
|
2019-02-13 15:21:09 +00:00
|
|
|
/* Catch potential impedance mismatches before they occur! */
|
|
|
|
BUILD_BUG_ON(sizeof(intel_wakeref_t) > sizeof(unsigned long));
|
|
|
|
|
2025-02-06 20:55:27 +02:00
|
|
|
wakeref = intel_display_power_get(display, POWER_DOMAIN_AUDIO_PLAYBACK);
|
2019-03-20 15:54:36 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (display->audio.power_refcount++ == 0) {
|
|
|
|
if (DISPLAY_VER(display) >= 9) {
|
|
|
|
intel_de_write(display, AUD_FREQ_CNTRL,
|
|
|
|
display->audio.freq_cntrl);
|
|
|
|
drm_dbg_kms(display->drm,
|
drm/i915/audio: convert to struct drm_device logging macros.
Converts the printk based logging macros in i915/display/intel_audio.c
to the struct drm_device based logging macros.
This transformation was achieved using the following coccinelle script
that matches the existence of the struct drm_i915_private device:
@rule1@
identifier fn, T;
@@
fn(struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
)
...+>
}
Checkpatch warnings were manually fixed.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200121134559.17355-4-wambui.karugax@gmail.com
2020-01-21 16:45:57 +03:00
|
|
|
"restored AUD_FREQ_CNTRL to 0x%x\n",
|
2025-01-08 16:04:13 +02:00
|
|
|
display->audio.freq_cntrl);
|
2019-09-20 11:39:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Force CDCLK to 2*BCLK as long as we need audio powered. */
|
2025-01-08 16:04:13 +02:00
|
|
|
if (display->platform.geminilake)
|
|
|
|
glk_force_audio_cdclk(display, true);
|
2019-10-03 11:55:30 +03:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (DISPLAY_VER(display) >= 10)
|
|
|
|
intel_de_rmw(display, AUD_PIN_BUF_CTL,
|
2022-10-26 20:01:47 +03:00
|
|
|
0, AUD_PIN_BUF_ENABLE);
|
2019-09-20 11:39:18 +03:00
|
|
|
}
|
2019-03-20 15:54:36 +02:00
|
|
|
|
2024-09-18 20:35:47 +03:00
|
|
|
return (unsigned long)wakeref;
|
2015-01-08 17:54:14 +02:00
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:15 +02:00
|
|
|
static void intel_audio_component_put_power(struct device *kdev,
|
|
|
|
unsigned long cookie)
|
2015-01-08 17:54:14 +02:00
|
|
|
{
|
2024-08-29 17:47:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(kdev);
|
2024-09-18 20:35:47 +03:00
|
|
|
intel_wakeref_t wakeref = (intel_wakeref_t)cookie;
|
2019-03-20 15:54:36 +02:00
|
|
|
|
|
|
|
/* Stop forcing CDCLK to 2*BCLK if no need for audio to be powered. */
|
2025-01-08 16:04:13 +02:00
|
|
|
if (--display->audio.power_refcount == 0)
|
|
|
|
if (display->platform.geminilake)
|
|
|
|
glk_force_audio_cdclk(display, false);
|
2019-03-20 15:54:36 +02:00
|
|
|
|
2025-02-06 20:55:27 +02:00
|
|
|
intel_display_power_put(display, POWER_DOMAIN_AUDIO_PLAYBACK, wakeref);
|
2015-01-08 17:54:14 +02:00
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:15 +02:00
|
|
|
static void intel_audio_component_codec_wake_override(struct device *kdev,
|
|
|
|
bool enable)
|
2015-05-05 09:05:47 +08:00
|
|
|
{
|
2024-08-29 17:47:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(kdev);
|
2019-02-13 15:21:09 +00:00
|
|
|
unsigned long cookie;
|
2015-05-05 09:05:47 +08:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (DISPLAY_VER(display) < 9)
|
2015-05-05 09:05:47 +08:00
|
|
|
return;
|
|
|
|
|
2025-01-08 16:04:15 +02:00
|
|
|
cookie = intel_audio_component_get_power(kdev);
|
2016-08-03 17:09:00 +01:00
|
|
|
|
2015-05-05 09:05:47 +08:00
|
|
|
/*
|
|
|
|
* Enable/disable generating the codec wake signal, overriding the
|
|
|
|
* internal logic to generate the codec wake to controller.
|
|
|
|
*/
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, HSW_AUD_CHICKENBIT,
|
2022-10-26 20:01:47 +03:00
|
|
|
SKL_AUD_CODEC_WAKE_SIGNAL, 0);
|
2015-05-05 09:05:47 +08:00
|
|
|
usleep_range(1000, 1500);
|
|
|
|
|
|
|
|
if (enable) {
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_de_rmw(display, HSW_AUD_CHICKENBIT,
|
2022-10-26 20:01:47 +03:00
|
|
|
0, SKL_AUD_CODEC_WAKE_SIGNAL);
|
2015-05-05 09:05:47 +08:00
|
|
|
usleep_range(1000, 1500);
|
|
|
|
}
|
2016-08-03 17:09:00 +01:00
|
|
|
|
2025-01-08 16:04:15 +02:00
|
|
|
intel_audio_component_put_power(kdev, cookie);
|
2015-05-05 09:05:47 +08:00
|
|
|
}
|
|
|
|
|
2015-01-08 17:54:14 +02:00
|
|
|
/* Get CDCLK in kHz */
|
2025-01-08 16:04:15 +02:00
|
|
|
static int intel_audio_component_get_cdclk_freq(struct device *kdev)
|
2015-01-08 17:54:14 +02:00
|
|
|
{
|
2024-08-29 17:47:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(kdev);
|
2015-01-08 17:54:14 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (drm_WARN_ON_ONCE(display->drm, !HAS_DDI(display)))
|
2015-01-08 17:54:14 +02:00
|
|
|
return -ENODEV;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
return display->cdclk.hw.cdclk;
|
2015-01-08 17:54:14 +02:00
|
|
|
}
|
|
|
|
|
2016-12-01 13:17:18 +08:00
|
|
|
/*
|
2023-02-22 17:14:54 +02:00
|
|
|
* get the intel audio state according to the parameter port and cpu_transcoder
|
|
|
|
* MST & (cpu_transcoder >= 0): return the audio.state[cpu_transcoder].encoder],
|
2016-12-01 13:17:18 +08:00
|
|
|
* when port is matched
|
2023-02-22 17:14:54 +02:00
|
|
|
* MST & (cpu_transcoder < 0): this is invalid
|
|
|
|
* Non-MST & (cpu_transcoder >= 0): only cpu_transcoder = 0 (the first device entry)
|
2016-12-01 13:17:18 +08:00
|
|
|
* will get the right intel_encoder with port matched
|
2023-02-22 17:14:54 +02:00
|
|
|
* Non-MST & (cpu_transcoder < 0): get the right intel_encoder with port matched
|
2016-12-01 13:17:18 +08:00
|
|
|
*/
|
2025-01-08 16:04:13 +02:00
|
|
|
static struct intel_audio_state *find_audio_state(struct intel_display *display,
|
2023-02-22 17:14:54 +02:00
|
|
|
int port, int cpu_transcoder)
|
drm/i915/dp: DP audio API changes for MST
DP MST provides the capability to send multiple video and audio streams
through a single port. This requires the API's between i915 and audio
drivers to distinguish between multiple audio capable displays that can be
connected to a port. Currently only the port identity is shared in the
APIs. This patch adds support for MST with an additional parameter
'int pipe'. The existing parameter 'port' does not change it's meaning.
pipe =
MST : display pipe that the stream originates from
Non-MST : -1
Affected APIs:
struct i915_audio_component_ops
- int (*sync_audio_rate)(struct device *, int port, int rate);
+ int (*sync_audio_rate)(struct device *, int port, int pipe,
+ int rate);
- int (*get_eld)(struct device *, int port, bool *enabled,
- unsigned char *buf, int max_bytes);
+ int (*get_eld)(struct device *, int port, int pipe,
+ bool *enabled, unsigned char *buf, int max_bytes);
struct i915_audio_component_audio_ops
- void (*pin_eld_notify)(void *audio_ptr, int port);
+ void (*pin_eld_notify)(void *audio_ptr, int port, int pipe);
This patch makes dummy changes in the audio drivers (thanks Libin) for
build to succeed. The audio side drivers will send the right 'pipe' values
for MST in patches that will follow.
v2:
Renamed the new API parameter from 'dev_id' to 'pipe'. (Jim, Ville)
Included Asoc driver API compatibility changes from Jeeja.
Added WARN_ON() for invalid pipe in get_saved_encoder(). (Takashi)
Added comment for av_enc_map[] definition. (Takashi)
v3:
Fixed logic error introduced while renaming 'dev_id' as 'pipe' (Ville)
Renamed get_saved_encoder() to get_saved_enc() to reduce line length
v4:
Rebased.
Parameter check for pipe < -1 values in get_saved_enc() (Ville)
Switched to for_each_pipe() in get_saved_enc() (Ville)
Renamed 'pipe' to 'dev_id' in audio side code (Takashi)
v5:
Included a comment for the dev_id arg. (Libin)
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1474488168-2343-1-git-send-email-dhinakaran.pandiyan@intel.com
2016-09-21 13:02:48 -07:00
|
|
|
{
|
|
|
|
/* MST */
|
2023-02-22 17:14:54 +02:00
|
|
|
if (cpu_transcoder >= 0) {
|
2023-01-24 16:46:18 +02:00
|
|
|
struct intel_audio_state *audio_state;
|
2022-11-08 17:18:27 +02:00
|
|
|
struct intel_encoder *encoder;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (drm_WARN_ON(display->drm,
|
|
|
|
cpu_transcoder >= ARRAY_SIZE(display->audio.state)))
|
2018-02-14 19:38:40 +02:00
|
|
|
return NULL;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
audio_state = &display->audio.state[cpu_transcoder];
|
2023-01-24 16:46:18 +02:00
|
|
|
encoder = audio_state->encoder;
|
|
|
|
|
2022-11-08 17:18:27 +02:00
|
|
|
if (encoder && encoder->port == port &&
|
2016-12-01 13:17:18 +08:00
|
|
|
encoder->type == INTEL_OUTPUT_DP_MST)
|
2023-01-24 16:46:18 +02:00
|
|
|
return audio_state;
|
2016-12-01 13:17:18 +08:00
|
|
|
}
|
drm/i915/dp: DP audio API changes for MST
DP MST provides the capability to send multiple video and audio streams
through a single port. This requires the API's between i915 and audio
drivers to distinguish between multiple audio capable displays that can be
connected to a port. Currently only the port identity is shared in the
APIs. This patch adds support for MST with an additional parameter
'int pipe'. The existing parameter 'port' does not change it's meaning.
pipe =
MST : display pipe that the stream originates from
Non-MST : -1
Affected APIs:
struct i915_audio_component_ops
- int (*sync_audio_rate)(struct device *, int port, int rate);
+ int (*sync_audio_rate)(struct device *, int port, int pipe,
+ int rate);
- int (*get_eld)(struct device *, int port, bool *enabled,
- unsigned char *buf, int max_bytes);
+ int (*get_eld)(struct device *, int port, int pipe,
+ bool *enabled, unsigned char *buf, int max_bytes);
struct i915_audio_component_audio_ops
- void (*pin_eld_notify)(void *audio_ptr, int port);
+ void (*pin_eld_notify)(void *audio_ptr, int port, int pipe);
This patch makes dummy changes in the audio drivers (thanks Libin) for
build to succeed. The audio side drivers will send the right 'pipe' values
for MST in patches that will follow.
v2:
Renamed the new API parameter from 'dev_id' to 'pipe'. (Jim, Ville)
Included Asoc driver API compatibility changes from Jeeja.
Added WARN_ON() for invalid pipe in get_saved_encoder(). (Takashi)
Added comment for av_enc_map[] definition. (Takashi)
v3:
Fixed logic error introduced while renaming 'dev_id' as 'pipe' (Ville)
Renamed get_saved_encoder() to get_saved_enc() to reduce line length
v4:
Rebased.
Parameter check for pipe < -1 values in get_saved_enc() (Ville)
Switched to for_each_pipe() in get_saved_enc() (Ville)
Renamed 'pipe' to 'dev_id' in audio side code (Takashi)
v5:
Included a comment for the dev_id arg. (Libin)
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1474488168-2343-1-git-send-email-dhinakaran.pandiyan@intel.com
2016-09-21 13:02:48 -07:00
|
|
|
|
|
|
|
/* Non-MST */
|
2023-02-22 17:14:54 +02:00
|
|
|
if (cpu_transcoder > 0)
|
2016-12-01 13:17:18 +08:00
|
|
|
return NULL;
|
drm/i915/dp: DP audio API changes for MST
DP MST provides the capability to send multiple video and audio streams
through a single port. This requires the API's between i915 and audio
drivers to distinguish between multiple audio capable displays that can be
connected to a port. Currently only the port identity is shared in the
APIs. This patch adds support for MST with an additional parameter
'int pipe'. The existing parameter 'port' does not change it's meaning.
pipe =
MST : display pipe that the stream originates from
Non-MST : -1
Affected APIs:
struct i915_audio_component_ops
- int (*sync_audio_rate)(struct device *, int port, int rate);
+ int (*sync_audio_rate)(struct device *, int port, int pipe,
+ int rate);
- int (*get_eld)(struct device *, int port, bool *enabled,
- unsigned char *buf, int max_bytes);
+ int (*get_eld)(struct device *, int port, int pipe,
+ bool *enabled, unsigned char *buf, int max_bytes);
struct i915_audio_component_audio_ops
- void (*pin_eld_notify)(void *audio_ptr, int port);
+ void (*pin_eld_notify)(void *audio_ptr, int port, int pipe);
This patch makes dummy changes in the audio drivers (thanks Libin) for
build to succeed. The audio side drivers will send the right 'pipe' values
for MST in patches that will follow.
v2:
Renamed the new API parameter from 'dev_id' to 'pipe'. (Jim, Ville)
Included Asoc driver API compatibility changes from Jeeja.
Added WARN_ON() for invalid pipe in get_saved_encoder(). (Takashi)
Added comment for av_enc_map[] definition. (Takashi)
v3:
Fixed logic error introduced while renaming 'dev_id' as 'pipe' (Ville)
Renamed get_saved_encoder() to get_saved_enc() to reduce line length
v4:
Rebased.
Parameter check for pipe < -1 values in get_saved_enc() (Ville)
Switched to for_each_pipe() in get_saved_enc() (Ville)
Renamed 'pipe' to 'dev_id' in audio side code (Takashi)
v5:
Included a comment for the dev_id arg. (Libin)
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1474488168-2343-1-git-send-email-dhinakaran.pandiyan@intel.com
2016-09-21 13:02:48 -07:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
for_each_cpu_transcoder(display, cpu_transcoder) {
|
2023-01-24 16:46:18 +02:00
|
|
|
struct intel_audio_state *audio_state;
|
2022-11-08 17:18:27 +02:00
|
|
|
struct intel_encoder *encoder;
|
drm/i915/dp: DP audio API changes for MST
DP MST provides the capability to send multiple video and audio streams
through a single port. This requires the API's between i915 and audio
drivers to distinguish between multiple audio capable displays that can be
connected to a port. Currently only the port identity is shared in the
APIs. This patch adds support for MST with an additional parameter
'int pipe'. The existing parameter 'port' does not change it's meaning.
pipe =
MST : display pipe that the stream originates from
Non-MST : -1
Affected APIs:
struct i915_audio_component_ops
- int (*sync_audio_rate)(struct device *, int port, int rate);
+ int (*sync_audio_rate)(struct device *, int port, int pipe,
+ int rate);
- int (*get_eld)(struct device *, int port, bool *enabled,
- unsigned char *buf, int max_bytes);
+ int (*get_eld)(struct device *, int port, int pipe,
+ bool *enabled, unsigned char *buf, int max_bytes);
struct i915_audio_component_audio_ops
- void (*pin_eld_notify)(void *audio_ptr, int port);
+ void (*pin_eld_notify)(void *audio_ptr, int port, int pipe);
This patch makes dummy changes in the audio drivers (thanks Libin) for
build to succeed. The audio side drivers will send the right 'pipe' values
for MST in patches that will follow.
v2:
Renamed the new API parameter from 'dev_id' to 'pipe'. (Jim, Ville)
Included Asoc driver API compatibility changes from Jeeja.
Added WARN_ON() for invalid pipe in get_saved_encoder(). (Takashi)
Added comment for av_enc_map[] definition. (Takashi)
v3:
Fixed logic error introduced while renaming 'dev_id' as 'pipe' (Ville)
Renamed get_saved_encoder() to get_saved_enc() to reduce line length
v4:
Rebased.
Parameter check for pipe < -1 values in get_saved_enc() (Ville)
Switched to for_each_pipe() in get_saved_enc() (Ville)
Renamed 'pipe' to 'dev_id' in audio side code (Takashi)
v5:
Included a comment for the dev_id arg. (Libin)
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1474488168-2343-1-git-send-email-dhinakaran.pandiyan@intel.com
2016-09-21 13:02:48 -07:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
audio_state = &display->audio.state[cpu_transcoder];
|
2023-01-24 16:46:18 +02:00
|
|
|
encoder = audio_state->encoder;
|
2016-12-01 13:17:18 +08:00
|
|
|
|
2022-11-08 17:18:27 +02:00
|
|
|
if (encoder && encoder->port == port &&
|
|
|
|
encoder->type != INTEL_OUTPUT_DP_MST)
|
2023-01-24 16:46:18 +02:00
|
|
|
return audio_state;
|
drm/i915/dp: DP audio API changes for MST
DP MST provides the capability to send multiple video and audio streams
through a single port. This requires the API's between i915 and audio
drivers to distinguish between multiple audio capable displays that can be
connected to a port. Currently only the port identity is shared in the
APIs. This patch adds support for MST with an additional parameter
'int pipe'. The existing parameter 'port' does not change it's meaning.
pipe =
MST : display pipe that the stream originates from
Non-MST : -1
Affected APIs:
struct i915_audio_component_ops
- int (*sync_audio_rate)(struct device *, int port, int rate);
+ int (*sync_audio_rate)(struct device *, int port, int pipe,
+ int rate);
- int (*get_eld)(struct device *, int port, bool *enabled,
- unsigned char *buf, int max_bytes);
+ int (*get_eld)(struct device *, int port, int pipe,
+ bool *enabled, unsigned char *buf, int max_bytes);
struct i915_audio_component_audio_ops
- void (*pin_eld_notify)(void *audio_ptr, int port);
+ void (*pin_eld_notify)(void *audio_ptr, int port, int pipe);
This patch makes dummy changes in the audio drivers (thanks Libin) for
build to succeed. The audio side drivers will send the right 'pipe' values
for MST in patches that will follow.
v2:
Renamed the new API parameter from 'dev_id' to 'pipe'. (Jim, Ville)
Included Asoc driver API compatibility changes from Jeeja.
Added WARN_ON() for invalid pipe in get_saved_encoder(). (Takashi)
Added comment for av_enc_map[] definition. (Takashi)
v3:
Fixed logic error introduced while renaming 'dev_id' as 'pipe' (Ville)
Renamed get_saved_encoder() to get_saved_enc() to reduce line length
v4:
Rebased.
Parameter check for pipe < -1 values in get_saved_enc() (Ville)
Switched to for_each_pipe() in get_saved_enc() (Ville)
Renamed 'pipe' to 'dev_id' in audio side code (Takashi)
v5:
Included a comment for the dev_id arg. (Libin)
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1474488168-2343-1-git-send-email-dhinakaran.pandiyan@intel.com
2016-09-21 13:02:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:15 +02:00
|
|
|
static int intel_audio_component_sync_audio_rate(struct device *kdev, int port,
|
|
|
|
int cpu_transcoder, int rate)
|
2015-09-02 14:11:39 +08:00
|
|
|
{
|
2024-08-29 17:47:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(kdev);
|
2025-01-08 16:04:13 +02:00
|
|
|
struct i915_audio_component *acomp = display->audio.component;
|
2023-01-24 16:46:18 +02:00
|
|
|
const struct intel_audio_state *audio_state;
|
2017-10-30 20:46:53 +02:00
|
|
|
struct intel_encoder *encoder;
|
|
|
|
struct intel_crtc *crtc;
|
2019-02-13 15:21:09 +00:00
|
|
|
unsigned long cookie;
|
2015-11-30 18:19:39 +01:00
|
|
|
int err = 0;
|
2015-09-02 14:11:39 +08:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (!HAS_DDI(display))
|
2015-09-02 14:11:39 +08:00
|
|
|
return 0;
|
|
|
|
|
2025-01-08 16:04:15 +02:00
|
|
|
cookie = intel_audio_component_get_power(kdev);
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_lock(&display->audio.mutex);
|
drm/i915/dp: DP audio API changes for MST
DP MST provides the capability to send multiple video and audio streams
through a single port. This requires the API's between i915 and audio
drivers to distinguish between multiple audio capable displays that can be
connected to a port. Currently only the port identity is shared in the
APIs. This patch adds support for MST with an additional parameter
'int pipe'. The existing parameter 'port' does not change it's meaning.
pipe =
MST : display pipe that the stream originates from
Non-MST : -1
Affected APIs:
struct i915_audio_component_ops
- int (*sync_audio_rate)(struct device *, int port, int rate);
+ int (*sync_audio_rate)(struct device *, int port, int pipe,
+ int rate);
- int (*get_eld)(struct device *, int port, bool *enabled,
- unsigned char *buf, int max_bytes);
+ int (*get_eld)(struct device *, int port, int pipe,
+ bool *enabled, unsigned char *buf, int max_bytes);
struct i915_audio_component_audio_ops
- void (*pin_eld_notify)(void *audio_ptr, int port);
+ void (*pin_eld_notify)(void *audio_ptr, int port, int pipe);
This patch makes dummy changes in the audio drivers (thanks Libin) for
build to succeed. The audio side drivers will send the right 'pipe' values
for MST in patches that will follow.
v2:
Renamed the new API parameter from 'dev_id' to 'pipe'. (Jim, Ville)
Included Asoc driver API compatibility changes from Jeeja.
Added WARN_ON() for invalid pipe in get_saved_encoder(). (Takashi)
Added comment for av_enc_map[] definition. (Takashi)
v3:
Fixed logic error introduced while renaming 'dev_id' as 'pipe' (Ville)
Renamed get_saved_encoder() to get_saved_enc() to reduce line length
v4:
Rebased.
Parameter check for pipe < -1 values in get_saved_enc() (Ville)
Switched to for_each_pipe() in get_saved_enc() (Ville)
Renamed 'pipe' to 'dev_id' in audio side code (Takashi)
v5:
Included a comment for the dev_id arg. (Libin)
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1474488168-2343-1-git-send-email-dhinakaran.pandiyan@intel.com
2016-09-21 13:02:48 -07:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
audio_state = find_audio_state(display, port, cpu_transcoder);
|
2023-01-24 16:46:18 +02:00
|
|
|
if (!audio_state) {
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_dbg_kms(display->drm, "Not valid for port %c\n",
|
|
|
|
port_name(port));
|
2015-11-30 18:19:39 +01:00
|
|
|
err = -ENODEV;
|
|
|
|
goto unlock;
|
2015-09-02 14:11:39 +08:00
|
|
|
}
|
drm/i915/dp: DP audio API changes for MST
DP MST provides the capability to send multiple video and audio streams
through a single port. This requires the API's between i915 and audio
drivers to distinguish between multiple audio capable displays that can be
connected to a port. Currently only the port identity is shared in the
APIs. This patch adds support for MST with an additional parameter
'int pipe'. The existing parameter 'port' does not change it's meaning.
pipe =
MST : display pipe that the stream originates from
Non-MST : -1
Affected APIs:
struct i915_audio_component_ops
- int (*sync_audio_rate)(struct device *, int port, int rate);
+ int (*sync_audio_rate)(struct device *, int port, int pipe,
+ int rate);
- int (*get_eld)(struct device *, int port, bool *enabled,
- unsigned char *buf, int max_bytes);
+ int (*get_eld)(struct device *, int port, int pipe,
+ bool *enabled, unsigned char *buf, int max_bytes);
struct i915_audio_component_audio_ops
- void (*pin_eld_notify)(void *audio_ptr, int port);
+ void (*pin_eld_notify)(void *audio_ptr, int port, int pipe);
This patch makes dummy changes in the audio drivers (thanks Libin) for
build to succeed. The audio side drivers will send the right 'pipe' values
for MST in patches that will follow.
v2:
Renamed the new API parameter from 'dev_id' to 'pipe'. (Jim, Ville)
Included Asoc driver API compatibility changes from Jeeja.
Added WARN_ON() for invalid pipe in get_saved_encoder(). (Takashi)
Added comment for av_enc_map[] definition. (Takashi)
v3:
Fixed logic error introduced while renaming 'dev_id' as 'pipe' (Ville)
Renamed get_saved_encoder() to get_saved_enc() to reduce line length
v4:
Rebased.
Parameter check for pipe < -1 values in get_saved_enc() (Ville)
Switched to for_each_pipe() in get_saved_enc() (Ville)
Renamed 'pipe' to 'dev_id' in audio side code (Takashi)
v5:
Included a comment for the dev_id arg. (Libin)
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1474488168-2343-1-git-send-email-dhinakaran.pandiyan@intel.com
2016-09-21 13:02:48 -07:00
|
|
|
|
2023-01-24 16:46:18 +02:00
|
|
|
encoder = audio_state->encoder;
|
|
|
|
|
|
|
|
/* FIXME stop using the legacy crtc pointer */
|
2017-10-30 20:46:53 +02:00
|
|
|
crtc = to_intel_crtc(encoder->base.crtc);
|
2015-09-02 14:11:39 +08:00
|
|
|
|
2023-02-22 17:14:54 +02:00
|
|
|
/* port must be valid now, otherwise the cpu_transcoder will be invalid */
|
2015-09-25 09:36:12 +08:00
|
|
|
acomp->aud_sample_rate[port] = rate;
|
|
|
|
|
2023-01-24 16:46:18 +02:00
|
|
|
/* FIXME get rid of the crtc->config stuff */
|
2017-10-30 20:46:53 +02:00
|
|
|
hsw_audio_config_update(encoder, crtc->config);
|
2015-09-02 14:11:39 +08:00
|
|
|
|
2015-11-30 18:19:39 +01:00
|
|
|
unlock:
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_unlock(&display->audio.mutex);
|
2025-01-08 16:04:15 +02:00
|
|
|
intel_audio_component_put_power(kdev, cookie);
|
2015-11-30 18:19:39 +01:00
|
|
|
return err;
|
2015-09-02 14:11:39 +08:00
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:15 +02:00
|
|
|
static int intel_audio_component_get_eld(struct device *kdev, int port,
|
|
|
|
int cpu_transcoder, bool *enabled,
|
|
|
|
unsigned char *buf, int max_bytes)
|
2015-11-12 15:23:41 +01:00
|
|
|
{
|
2024-08-29 17:47:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(kdev);
|
2023-01-24 16:46:18 +02:00
|
|
|
const struct intel_audio_state *audio_state;
|
|
|
|
int ret = 0;
|
2015-11-12 15:23:41 +01:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_lock(&display->audio.mutex);
|
drm/i915/dp: DP audio API changes for MST
DP MST provides the capability to send multiple video and audio streams
through a single port. This requires the API's between i915 and audio
drivers to distinguish between multiple audio capable displays that can be
connected to a port. Currently only the port identity is shared in the
APIs. This patch adds support for MST with an additional parameter
'int pipe'. The existing parameter 'port' does not change it's meaning.
pipe =
MST : display pipe that the stream originates from
Non-MST : -1
Affected APIs:
struct i915_audio_component_ops
- int (*sync_audio_rate)(struct device *, int port, int rate);
+ int (*sync_audio_rate)(struct device *, int port, int pipe,
+ int rate);
- int (*get_eld)(struct device *, int port, bool *enabled,
- unsigned char *buf, int max_bytes);
+ int (*get_eld)(struct device *, int port, int pipe,
+ bool *enabled, unsigned char *buf, int max_bytes);
struct i915_audio_component_audio_ops
- void (*pin_eld_notify)(void *audio_ptr, int port);
+ void (*pin_eld_notify)(void *audio_ptr, int port, int pipe);
This patch makes dummy changes in the audio drivers (thanks Libin) for
build to succeed. The audio side drivers will send the right 'pipe' values
for MST in patches that will follow.
v2:
Renamed the new API parameter from 'dev_id' to 'pipe'. (Jim, Ville)
Included Asoc driver API compatibility changes from Jeeja.
Added WARN_ON() for invalid pipe in get_saved_encoder(). (Takashi)
Added comment for av_enc_map[] definition. (Takashi)
v3:
Fixed logic error introduced while renaming 'dev_id' as 'pipe' (Ville)
Renamed get_saved_encoder() to get_saved_enc() to reduce line length
v4:
Rebased.
Parameter check for pipe < -1 values in get_saved_enc() (Ville)
Switched to for_each_pipe() in get_saved_enc() (Ville)
Renamed 'pipe' to 'dev_id' in audio side code (Takashi)
v5:
Included a comment for the dev_id arg. (Libin)
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1474488168-2343-1-git-send-email-dhinakaran.pandiyan@intel.com
2016-09-21 13:02:48 -07:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
audio_state = find_audio_state(display, port, cpu_transcoder);
|
2023-01-24 16:46:18 +02:00
|
|
|
if (!audio_state) {
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_dbg_kms(display->drm, "Not valid for port %c\n",
|
|
|
|
port_name(port));
|
|
|
|
mutex_unlock(&display->audio.mutex);
|
2023-01-24 16:46:18 +02:00
|
|
|
return -EINVAL;
|
drm/i915/dp: DP audio API changes for MST
DP MST provides the capability to send multiple video and audio streams
through a single port. This requires the API's between i915 and audio
drivers to distinguish between multiple audio capable displays that can be
connected to a port. Currently only the port identity is shared in the
APIs. This patch adds support for MST with an additional parameter
'int pipe'. The existing parameter 'port' does not change it's meaning.
pipe =
MST : display pipe that the stream originates from
Non-MST : -1
Affected APIs:
struct i915_audio_component_ops
- int (*sync_audio_rate)(struct device *, int port, int rate);
+ int (*sync_audio_rate)(struct device *, int port, int pipe,
+ int rate);
- int (*get_eld)(struct device *, int port, bool *enabled,
- unsigned char *buf, int max_bytes);
+ int (*get_eld)(struct device *, int port, int pipe,
+ bool *enabled, unsigned char *buf, int max_bytes);
struct i915_audio_component_audio_ops
- void (*pin_eld_notify)(void *audio_ptr, int port);
+ void (*pin_eld_notify)(void *audio_ptr, int port, int pipe);
This patch makes dummy changes in the audio drivers (thanks Libin) for
build to succeed. The audio side drivers will send the right 'pipe' values
for MST in patches that will follow.
v2:
Renamed the new API parameter from 'dev_id' to 'pipe'. (Jim, Ville)
Included Asoc driver API compatibility changes from Jeeja.
Added WARN_ON() for invalid pipe in get_saved_encoder(). (Takashi)
Added comment for av_enc_map[] definition. (Takashi)
v3:
Fixed logic error introduced while renaming 'dev_id' as 'pipe' (Ville)
Renamed get_saved_encoder() to get_saved_enc() to reduce line length
v4:
Rebased.
Parameter check for pipe < -1 values in get_saved_enc() (Ville)
Switched to for_each_pipe() in get_saved_enc() (Ville)
Renamed 'pipe' to 'dev_id' in audio side code (Takashi)
v5:
Included a comment for the dev_id arg. (Libin)
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1474488168-2343-1-git-send-email-dhinakaran.pandiyan@intel.com
2016-09-21 13:02:48 -07:00
|
|
|
}
|
|
|
|
|
2023-01-24 16:46:19 +02:00
|
|
|
*enabled = audio_state->encoder != NULL;
|
drm/i915/dp: DP audio API changes for MST
DP MST provides the capability to send multiple video and audio streams
through a single port. This requires the API's between i915 and audio
drivers to distinguish between multiple audio capable displays that can be
connected to a port. Currently only the port identity is shared in the
APIs. This patch adds support for MST with an additional parameter
'int pipe'. The existing parameter 'port' does not change it's meaning.
pipe =
MST : display pipe that the stream originates from
Non-MST : -1
Affected APIs:
struct i915_audio_component_ops
- int (*sync_audio_rate)(struct device *, int port, int rate);
+ int (*sync_audio_rate)(struct device *, int port, int pipe,
+ int rate);
- int (*get_eld)(struct device *, int port, bool *enabled,
- unsigned char *buf, int max_bytes);
+ int (*get_eld)(struct device *, int port, int pipe,
+ bool *enabled, unsigned char *buf, int max_bytes);
struct i915_audio_component_audio_ops
- void (*pin_eld_notify)(void *audio_ptr, int port);
+ void (*pin_eld_notify)(void *audio_ptr, int port, int pipe);
This patch makes dummy changes in the audio drivers (thanks Libin) for
build to succeed. The audio side drivers will send the right 'pipe' values
for MST in patches that will follow.
v2:
Renamed the new API parameter from 'dev_id' to 'pipe'. (Jim, Ville)
Included Asoc driver API compatibility changes from Jeeja.
Added WARN_ON() for invalid pipe in get_saved_encoder(). (Takashi)
Added comment for av_enc_map[] definition. (Takashi)
v3:
Fixed logic error introduced while renaming 'dev_id' as 'pipe' (Ville)
Renamed get_saved_encoder() to get_saved_enc() to reduce line length
v4:
Rebased.
Parameter check for pipe < -1 values in get_saved_enc() (Ville)
Switched to for_each_pipe() in get_saved_enc() (Ville)
Renamed 'pipe' to 'dev_id' in audio side code (Takashi)
v5:
Included a comment for the dev_id arg. (Libin)
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1474488168-2343-1-git-send-email-dhinakaran.pandiyan@intel.com
2016-09-21 13:02:48 -07:00
|
|
|
if (*enabled) {
|
2023-01-24 16:46:19 +02:00
|
|
|
const u8 *eld = audio_state->eld;
|
2023-01-24 16:46:18 +02:00
|
|
|
|
drm/i915/dp: DP audio API changes for MST
DP MST provides the capability to send multiple video and audio streams
through a single port. This requires the API's between i915 and audio
drivers to distinguish between multiple audio capable displays that can be
connected to a port. Currently only the port identity is shared in the
APIs. This patch adds support for MST with an additional parameter
'int pipe'. The existing parameter 'port' does not change it's meaning.
pipe =
MST : display pipe that the stream originates from
Non-MST : -1
Affected APIs:
struct i915_audio_component_ops
- int (*sync_audio_rate)(struct device *, int port, int rate);
+ int (*sync_audio_rate)(struct device *, int port, int pipe,
+ int rate);
- int (*get_eld)(struct device *, int port, bool *enabled,
- unsigned char *buf, int max_bytes);
+ int (*get_eld)(struct device *, int port, int pipe,
+ bool *enabled, unsigned char *buf, int max_bytes);
struct i915_audio_component_audio_ops
- void (*pin_eld_notify)(void *audio_ptr, int port);
+ void (*pin_eld_notify)(void *audio_ptr, int port, int pipe);
This patch makes dummy changes in the audio drivers (thanks Libin) for
build to succeed. The audio side drivers will send the right 'pipe' values
for MST in patches that will follow.
v2:
Renamed the new API parameter from 'dev_id' to 'pipe'. (Jim, Ville)
Included Asoc driver API compatibility changes from Jeeja.
Added WARN_ON() for invalid pipe in get_saved_encoder(). (Takashi)
Added comment for av_enc_map[] definition. (Takashi)
v3:
Fixed logic error introduced while renaming 'dev_id' as 'pipe' (Ville)
Renamed get_saved_encoder() to get_saved_enc() to reduce line length
v4:
Rebased.
Parameter check for pipe < -1 values in get_saved_enc() (Ville)
Switched to for_each_pipe() in get_saved_enc() (Ville)
Renamed 'pipe' to 'dev_id' in audio side code (Takashi)
v5:
Included a comment for the dev_id arg. (Libin)
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1474488168-2343-1-git-send-email-dhinakaran.pandiyan@intel.com
2016-09-21 13:02:48 -07:00
|
|
|
ret = drm_eld_size(eld);
|
|
|
|
memcpy(buf, eld, min(max_bytes, ret));
|
2015-11-12 15:23:41 +01:00
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
mutex_unlock(&display->audio.mutex);
|
2015-11-12 15:23:41 +01:00
|
|
|
return ret;
|
2015-09-02 14:11:39 +08:00
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:15 +02:00
|
|
|
static const struct drm_audio_component_ops intel_audio_component_ops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.get_power = intel_audio_component_get_power,
|
|
|
|
.put_power = intel_audio_component_put_power,
|
|
|
|
.codec_wake_override = intel_audio_component_codec_wake_override,
|
|
|
|
.get_cdclk_freq = intel_audio_component_get_cdclk_freq,
|
|
|
|
.sync_audio_rate = intel_audio_component_sync_audio_rate,
|
|
|
|
.get_eld = intel_audio_component_get_eld,
|
2015-01-08 17:54:14 +02:00
|
|
|
};
|
|
|
|
|
2025-01-08 16:04:15 +02:00
|
|
|
static int intel_audio_component_bind(struct device *drv_kdev,
|
|
|
|
struct device *hda_kdev, void *data)
|
2015-01-08 17:54:14 +02:00
|
|
|
{
|
2024-08-29 17:47:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(drv_kdev);
|
2015-01-08 17:54:14 +02:00
|
|
|
struct i915_audio_component *acomp = data;
|
2015-09-25 09:36:12 +08:00
|
|
|
int i;
|
2015-01-08 17:54:14 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (drm_WARN_ON(display->drm, acomp->base.ops || acomp->base.dev))
|
2015-01-08 17:54:14 +02:00
|
|
|
return -EEXIST;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (drm_WARN_ON(display->drm,
|
2024-08-29 17:47:45 +03:00
|
|
|
!device_link_add(hda_kdev, drv_kdev,
|
drm/i915/display/audio: Make WARN* drm specific where drm_priv ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_i915_private struct pointer is readily
available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200128181603.27767-3-pankaj.laxminarayan.bharadiya@intel.com
2020-01-28 23:45:44 +05:30
|
|
|
DL_FLAG_STATELESS)))
|
2018-10-23 17:43:10 +03:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_modeset_lock_all(display->drm);
|
2025-01-08 16:04:15 +02:00
|
|
|
acomp->base.ops = &intel_audio_component_ops;
|
2024-08-29 17:47:45 +03:00
|
|
|
acomp->base.dev = drv_kdev;
|
2015-09-25 09:36:12 +08:00
|
|
|
BUILD_BUG_ON(MAX_PORTS != I915_MAX_PORTS);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(acomp->aud_sample_rate); i++)
|
|
|
|
acomp->aud_sample_rate[i] = 0;
|
2025-01-08 16:04:13 +02:00
|
|
|
display->audio.component = acomp;
|
|
|
|
drm_modeset_unlock_all(display->drm);
|
2015-01-08 17:54:14 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:15 +02:00
|
|
|
static void intel_audio_component_unbind(struct device *drv_kdev,
|
|
|
|
struct device *hda_kdev, void *data)
|
2015-01-08 17:54:14 +02:00
|
|
|
{
|
2024-08-29 17:47:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(drv_kdev);
|
2015-01-08 17:54:14 +02:00
|
|
|
struct i915_audio_component *acomp = data;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_modeset_lock_all(display->drm);
|
2018-07-11 15:17:22 +02:00
|
|
|
acomp->base.ops = NULL;
|
|
|
|
acomp->base.dev = NULL;
|
2025-01-08 16:04:13 +02:00
|
|
|
display->audio.component = NULL;
|
|
|
|
drm_modeset_unlock_all(display->drm);
|
2018-10-23 17:43:10 +03:00
|
|
|
|
2024-08-29 17:47:45 +03:00
|
|
|
device_link_remove(hda_kdev, drv_kdev);
|
2020-04-17 09:51:32 +03:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (display->audio.power_refcount)
|
|
|
|
drm_err(display->drm,
|
|
|
|
"audio power refcount %d after unbind\n",
|
|
|
|
display->audio.power_refcount);
|
2015-01-08 17:54:14 +02:00
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:15 +02:00
|
|
|
static const struct component_ops intel_audio_component_bind_ops = {
|
|
|
|
.bind = intel_audio_component_bind,
|
|
|
|
.unbind = intel_audio_component_unbind,
|
2015-01-08 17:54:14 +02:00
|
|
|
};
|
|
|
|
|
2021-03-24 14:37:25 +02:00
|
|
|
#define AUD_FREQ_TMODE_SHIFT 14
|
|
|
|
#define AUD_FREQ_4T 0
|
|
|
|
#define AUD_FREQ_8T (2 << AUD_FREQ_TMODE_SHIFT)
|
|
|
|
#define AUD_FREQ_PULLCLKS(x) (((x) & 0x3) << 11)
|
|
|
|
#define AUD_FREQ_BCLK_96M BIT(4)
|
|
|
|
|
|
|
|
#define AUD_FREQ_GEN12 (AUD_FREQ_8T | AUD_FREQ_PULLCLKS(0) | AUD_FREQ_BCLK_96M)
|
|
|
|
#define AUD_FREQ_TGL_BROKEN (AUD_FREQ_8T | AUD_FREQ_PULLCLKS(2) | AUD_FREQ_BCLK_96M)
|
|
|
|
|
2015-01-08 17:54:14 +02:00
|
|
|
/**
|
2025-01-08 16:04:15 +02:00
|
|
|
* intel_audio_component_init - initialize and register the audio component
|
2025-01-08 16:04:13 +02:00
|
|
|
* @display: display device
|
2015-01-08 17:54:14 +02:00
|
|
|
*
|
|
|
|
* This will register with the component framework a child component which
|
|
|
|
* will bind dynamically to the snd_hda_intel driver's corresponding master
|
|
|
|
* component when the latter is registered. During binding the child
|
|
|
|
* initializes an instance of struct i915_audio_component which it receives
|
|
|
|
* from the master. The master can then start to use the interface defined by
|
|
|
|
* this struct. Each side can break the binding at any point by deregistering
|
|
|
|
* its own component after which each side's component unbind callback is
|
|
|
|
* called.
|
|
|
|
*
|
|
|
|
* We ignore any error during registration and continue with reduced
|
|
|
|
* functionality (i.e. without HDMI audio).
|
|
|
|
*/
|
2025-01-08 16:04:15 +02:00
|
|
|
static void intel_audio_component_init(struct intel_display *display)
|
2015-01-08 17:54:14 +02:00
|
|
|
{
|
2021-03-24 14:37:25 +02:00
|
|
|
u32 aud_freq, aud_freq_init;
|
2015-01-08 17:54:14 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (DISPLAY_VER(display) >= 9) {
|
|
|
|
aud_freq_init = intel_de_read(display, AUD_FREQ_CNTRL);
|
2021-03-24 14:37:25 +02:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
if (DISPLAY_VER(display) >= 12)
|
2021-03-24 14:37:25 +02:00
|
|
|
aud_freq = AUD_FREQ_GEN12;
|
|
|
|
else
|
|
|
|
aud_freq = aud_freq_init;
|
|
|
|
|
2021-09-06 12:12:59 +08:00
|
|
|
/* use BIOS provided value for TGL and RKL unless it is a known bad value */
|
2025-01-08 16:04:13 +02:00
|
|
|
if ((display->platform.tigerlake || display->platform.rocketlake) &&
|
2021-09-06 12:12:59 +08:00
|
|
|
aud_freq_init != AUD_FREQ_TGL_BROKEN)
|
2021-03-24 14:37:25 +02:00
|
|
|
aud_freq = aud_freq_init;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_dbg_kms(display->drm,
|
|
|
|
"use AUD_FREQ_CNTRL of 0x%x (init value 0x%x)\n",
|
2021-03-24 14:37:25 +02:00
|
|
|
aud_freq, aud_freq_init);
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
display->audio.freq_cntrl = aud_freq;
|
2019-09-20 11:39:18 +03:00
|
|
|
}
|
|
|
|
|
2021-10-21 13:59:15 +03:00
|
|
|
/* init with current cdclk */
|
2025-01-08 16:04:13 +02:00
|
|
|
intel_audio_cdclk_change_post(display);
|
2024-05-21 17:30:22 +03:00
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:15 +02:00
|
|
|
static void intel_audio_component_register(struct intel_display *display)
|
2024-05-21 17:30:22 +03:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
ret = component_add_typed(display->drm->dev,
|
2025-01-08 16:04:15 +02:00
|
|
|
&intel_audio_component_bind_ops,
|
2024-05-21 17:30:22 +03:00
|
|
|
I915_COMPONENT_AUDIO);
|
|
|
|
if (ret < 0) {
|
2025-01-08 16:04:13 +02:00
|
|
|
drm_err(display->drm,
|
2024-05-21 17:30:22 +03:00
|
|
|
"failed to add audio component (%d)\n", ret);
|
|
|
|
/* continue with reduced functionality */
|
|
|
|
return;
|
|
|
|
}
|
2021-10-21 13:59:15 +03:00
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
display->audio.component_registered = true;
|
2015-01-08 17:54:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2025-01-08 16:04:15 +02:00
|
|
|
* intel_audio_component_cleanup - deregister the audio component
|
2025-01-08 16:04:13 +02:00
|
|
|
* @display: display device
|
2015-01-08 17:54:14 +02:00
|
|
|
*
|
|
|
|
* Deregisters the audio component, breaking any existing binding to the
|
|
|
|
* corresponding snd_hda_intel driver's master component.
|
|
|
|
*/
|
2025-01-08 16:04:15 +02:00
|
|
|
static void intel_audio_component_cleanup(struct intel_display *display)
|
2015-01-08 17:54:14 +02:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
if (!display->audio.component_registered)
|
2015-01-08 17:54:14 +02:00
|
|
|
return;
|
|
|
|
|
2025-01-08 16:04:15 +02:00
|
|
|
component_del(display->drm->dev, &intel_audio_component_bind_ops);
|
2025-01-08 16:04:13 +02:00
|
|
|
display->audio.component_registered = false;
|
2015-01-08 17:54:14 +02:00
|
|
|
}
|
2017-01-25 04:27:49 +05:30
|
|
|
|
|
|
|
/**
|
|
|
|
* intel_audio_init() - Initialize the audio driver either using
|
|
|
|
* component framework or using lpe audio bridge
|
2025-01-08 16:04:13 +02:00
|
|
|
* @display: display device
|
2017-01-25 04:27:49 +05:30
|
|
|
*
|
|
|
|
*/
|
2025-01-08 16:04:13 +02:00
|
|
|
void intel_audio_init(struct intel_display *display)
|
2017-01-25 04:27:49 +05:30
|
|
|
{
|
2025-01-08 16:04:14 +02:00
|
|
|
if (intel_lpe_audio_init(display) < 0)
|
2025-01-08 16:04:15 +02:00
|
|
|
intel_audio_component_init(display);
|
2017-01-25 04:27:49 +05:30
|
|
|
}
|
|
|
|
|
2025-01-08 16:04:13 +02:00
|
|
|
void intel_audio_register(struct intel_display *display)
|
2024-05-21 17:30:22 +03:00
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
if (!display->audio.lpe.platdev)
|
2025-01-08 16:04:15 +02:00
|
|
|
intel_audio_component_register(display);
|
2024-05-21 17:30:22 +03:00
|
|
|
}
|
|
|
|
|
2017-01-25 04:27:49 +05:30
|
|
|
/**
|
|
|
|
* intel_audio_deinit() - deinitialize the audio driver
|
2025-01-08 16:04:13 +02:00
|
|
|
* @display: display device
|
2017-01-25 04:27:49 +05:30
|
|
|
*/
|
2025-01-08 16:04:13 +02:00
|
|
|
void intel_audio_deinit(struct intel_display *display)
|
2017-01-25 04:27:49 +05:30
|
|
|
{
|
2025-01-08 16:04:13 +02:00
|
|
|
if (display->audio.lpe.platdev)
|
2025-01-08 16:04:14 +02:00
|
|
|
intel_lpe_audio_teardown(display);
|
2017-01-25 04:27:49 +05:30
|
|
|
else
|
2025-01-08 16:04:15 +02:00
|
|
|
intel_audio_component_cleanup(display);
|
2017-01-25 04:27:49 +05:30
|
|
|
}
|