Commit 0a108bca authored by Dave Airlie's avatar Dave Airlie Committed by Jani Nikula

drm/i915: constify the audio function vtable

Move the functions into read-only tables.
Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/5a481307a5daab40a506c3b9a64b0b37e01a1a41.1632869550.git.jani.nikula@intel.com
parent c6d27046
...@@ -848,10 +848,10 @@ void intel_audio_codec_enable(struct intel_encoder *encoder, ...@@ -848,10 +848,10 @@ void intel_audio_codec_enable(struct intel_encoder *encoder,
connector->eld[6] = drm_av_sync_delay(connector, adjusted_mode) / 2; connector->eld[6] = drm_av_sync_delay(connector, adjusted_mode) / 2;
if (dev_priv->audio_funcs.audio_codec_enable) if (dev_priv->audio_funcs)
dev_priv->audio_funcs.audio_codec_enable(encoder, dev_priv->audio_funcs->audio_codec_enable(encoder,
crtc_state, crtc_state,
conn_state); conn_state);
mutex_lock(&dev_priv->av_mutex); mutex_lock(&dev_priv->av_mutex);
encoder->audio_connector = connector; encoder->audio_connector = connector;
...@@ -893,10 +893,10 @@ void intel_audio_codec_disable(struct intel_encoder *encoder, ...@@ -893,10 +893,10 @@ void intel_audio_codec_disable(struct intel_encoder *encoder,
enum port port = encoder->port; enum port port = encoder->port;
enum pipe pipe = crtc->pipe; enum pipe pipe = crtc->pipe;
if (dev_priv->audio_funcs.audio_codec_disable) if (dev_priv->audio_funcs)
dev_priv->audio_funcs.audio_codec_disable(encoder, dev_priv->audio_funcs->audio_codec_disable(encoder,
old_crtc_state, old_crtc_state,
old_conn_state); old_conn_state);
mutex_lock(&dev_priv->av_mutex); mutex_lock(&dev_priv->av_mutex);
encoder->audio_connector = NULL; encoder->audio_connector = NULL;
...@@ -915,6 +915,21 @@ void intel_audio_codec_disable(struct intel_encoder *encoder, ...@@ -915,6 +915,21 @@ void intel_audio_codec_disable(struct intel_encoder *encoder,
intel_lpe_audio_notify(dev_priv, pipe, port, NULL, 0, false); intel_lpe_audio_notify(dev_priv, pipe, port, NULL, 0, false);
} }
static const struct intel_audio_funcs g4x_audio_funcs = {
.audio_codec_enable = g4x_audio_codec_enable,
.audio_codec_disable = g4x_audio_codec_disable,
};
static const struct intel_audio_funcs ilk_audio_funcs = {
.audio_codec_enable = ilk_audio_codec_enable,
.audio_codec_disable = ilk_audio_codec_disable,
};
static const struct intel_audio_funcs hsw_audio_funcs = {
.audio_codec_enable = hsw_audio_codec_enable,
.audio_codec_disable = hsw_audio_codec_disable,
};
/** /**
* intel_init_audio_hooks - Set up chip specific audio hooks * intel_init_audio_hooks - Set up chip specific audio hooks
* @dev_priv: device private * @dev_priv: device private
...@@ -922,17 +937,13 @@ void intel_audio_codec_disable(struct intel_encoder *encoder, ...@@ -922,17 +937,13 @@ void intel_audio_codec_disable(struct intel_encoder *encoder,
void intel_init_audio_hooks(struct drm_i915_private *dev_priv) void intel_init_audio_hooks(struct drm_i915_private *dev_priv)
{ {
if (IS_G4X(dev_priv)) { if (IS_G4X(dev_priv)) {
dev_priv->audio_funcs.audio_codec_enable = g4x_audio_codec_enable; dev_priv->audio_funcs = &g4x_audio_funcs;
dev_priv->audio_funcs.audio_codec_disable = g4x_audio_codec_disable;
} else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
dev_priv->audio_funcs.audio_codec_enable = ilk_audio_codec_enable; dev_priv->audio_funcs = &ilk_audio_funcs;
dev_priv->audio_funcs.audio_codec_disable = ilk_audio_codec_disable;
} else if (IS_HASWELL(dev_priv) || DISPLAY_VER(dev_priv) >= 8) { } else if (IS_HASWELL(dev_priv) || DISPLAY_VER(dev_priv) >= 8) {
dev_priv->audio_funcs.audio_codec_enable = hsw_audio_codec_enable; dev_priv->audio_funcs = &hsw_audio_funcs;
dev_priv->audio_funcs.audio_codec_disable = hsw_audio_codec_disable;
} else if (HAS_PCH_SPLIT(dev_priv)) { } else if (HAS_PCH_SPLIT(dev_priv)) {
dev_priv->audio_funcs.audio_codec_enable = ilk_audio_codec_enable; dev_priv->audio_funcs = &ilk_audio_funcs;
dev_priv->audio_funcs.audio_codec_disable = ilk_audio_codec_disable;
} }
} }
......
...@@ -1003,7 +1003,7 @@ struct drm_i915_private { ...@@ -1003,7 +1003,7 @@ struct drm_i915_private {
const struct intel_color_funcs *color_funcs; const struct intel_color_funcs *color_funcs;
/* Display internal audio functions */ /* Display internal audio functions */
struct intel_audio_funcs audio_funcs; const struct intel_audio_funcs *audio_funcs;
/* Display CDCLK functions */ /* Display CDCLK functions */
struct intel_cdclk_funcs cdclk_funcs; struct intel_cdclk_funcs cdclk_funcs;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment