Message ID | 20210908003944.2972024-16-airlied@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | i915/display: split and constify vtable | expand |
On Wed, 08 Sep 2021, Dave Airlie <airlied@gmail.com> wrote: > From: Dave Airlie <airlied@redhat.com> > Reviewed-by: Jani Nikula <jani.nikula@intel.com> > --- > drivers/gpu/drm/i915/display/intel_audio.c | 43 ++++++++++++++-------- > drivers/gpu/drm/i915/i915_drv.h | 2 +- > 2 files changed, 28 insertions(+), 17 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_audio.c b/drivers/gpu/drm/i915/display/intel_audio.c > index f539826c0424..4707e1beb763 100644 > --- a/drivers/gpu/drm/i915/display/intel_audio.c > +++ b/drivers/gpu/drm/i915/display/intel_audio.c > @@ -848,10 +848,10 @@ void intel_audio_codec_enable(struct intel_encoder *encoder, > > connector->eld[6] = drm_av_sync_delay(connector, adjusted_mode) / 2; > > - if (dev_priv->audio_funcs.audio_codec_enable) > - dev_priv->audio_funcs.audio_codec_enable(encoder, > - crtc_state, > - conn_state); > + if (dev_priv->audio_funcs) > + dev_priv->audio_funcs->audio_codec_enable(encoder, > + crtc_state, > + conn_state); > > mutex_lock(&dev_priv->av_mutex); > encoder->audio_connector = connector; > @@ -893,10 +893,10 @@ void intel_audio_codec_disable(struct intel_encoder *encoder, > enum port port = encoder->port; > enum pipe pipe = crtc->pipe; > > - if (dev_priv->audio_funcs.audio_codec_disable) > - dev_priv->audio_funcs.audio_codec_disable(encoder, > - old_crtc_state, > - old_conn_state); > + if (dev_priv->audio_funcs) > + dev_priv->audio_funcs->audio_codec_disable(encoder, > + old_crtc_state, > + old_conn_state); > > mutex_lock(&dev_priv->av_mutex); > encoder->audio_connector = NULL; > @@ -915,6 +915,21 @@ void intel_audio_codec_disable(struct intel_encoder *encoder, > intel_lpe_audio_notify(dev_priv, pipe, port, NULL, 0, false); > } > > +static const struct drm_i915_display_audio_funcs g4x_audio_funcs = { > + .audio_codec_enable = g4x_audio_codec_enable, > + .audio_codec_disable = g4x_audio_codec_disable, > +}; > + > +static const struct drm_i915_display_audio_funcs ilk_audio_funcs = { > + .audio_codec_enable = ilk_audio_codec_enable, > + .audio_codec_disable = ilk_audio_codec_disable, > +}; > + > +static const struct drm_i915_display_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 > * @dev_priv: device private > @@ -922,17 +937,13 @@ void intel_audio_codec_disable(struct intel_encoder *encoder, > void intel_init_audio_hooks(struct drm_i915_private *dev_priv) > { > if (IS_G4X(dev_priv)) { > - dev_priv->audio_funcs.audio_codec_enable = g4x_audio_codec_enable; > - dev_priv->audio_funcs.audio_codec_disable = g4x_audio_codec_disable; > + dev_priv->audio_funcs = &g4x_audio_funcs; > } 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.audio_codec_disable = ilk_audio_codec_disable; > + dev_priv->audio_funcs = &ilk_audio_funcs; > } 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.audio_codec_disable = hsw_audio_codec_disable; > + dev_priv->audio_funcs = &hsw_audio_funcs; > } else if (HAS_PCH_SPLIT(dev_priv)) { > - dev_priv->audio_funcs.audio_codec_enable = ilk_audio_codec_enable; > - dev_priv->audio_funcs.audio_codec_disable = ilk_audio_codec_disable; > + dev_priv->audio_funcs = &ilk_audio_funcs; > } > } > > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h > index e82df3bf493b..8d14318c5708 100644 > --- a/drivers/gpu/drm/i915/i915_drv.h > +++ b/drivers/gpu/drm/i915/i915_drv.h > @@ -1018,7 +1018,7 @@ struct drm_i915_private { > const struct drm_i915_display_color_funcs *color_funcs; > > /* Display internal audio functions */ > - struct drm_i915_display_audio_funcs audio_funcs; > + const struct drm_i915_display_audio_funcs *audio_funcs; > > /* Display CDCLK functions */ > struct drm_i915_display_cdclk_funcs cdclk_funcs;
diff --git a/drivers/gpu/drm/i915/display/intel_audio.c b/drivers/gpu/drm/i915/display/intel_audio.c index f539826c0424..4707e1beb763 100644 --- a/drivers/gpu/drm/i915/display/intel_audio.c +++ b/drivers/gpu/drm/i915/display/intel_audio.c @@ -848,10 +848,10 @@ void intel_audio_codec_enable(struct intel_encoder *encoder, connector->eld[6] = drm_av_sync_delay(connector, adjusted_mode) / 2; - if (dev_priv->audio_funcs.audio_codec_enable) - dev_priv->audio_funcs.audio_codec_enable(encoder, - crtc_state, - conn_state); + if (dev_priv->audio_funcs) + dev_priv->audio_funcs->audio_codec_enable(encoder, + crtc_state, + conn_state); mutex_lock(&dev_priv->av_mutex); encoder->audio_connector = connector; @@ -893,10 +893,10 @@ void intel_audio_codec_disable(struct intel_encoder *encoder, enum port port = encoder->port; enum pipe pipe = crtc->pipe; - if (dev_priv->audio_funcs.audio_codec_disable) - dev_priv->audio_funcs.audio_codec_disable(encoder, - old_crtc_state, - old_conn_state); + if (dev_priv->audio_funcs) + dev_priv->audio_funcs->audio_codec_disable(encoder, + old_crtc_state, + old_conn_state); mutex_lock(&dev_priv->av_mutex); encoder->audio_connector = NULL; @@ -915,6 +915,21 @@ void intel_audio_codec_disable(struct intel_encoder *encoder, intel_lpe_audio_notify(dev_priv, pipe, port, NULL, 0, false); } +static const struct drm_i915_display_audio_funcs g4x_audio_funcs = { + .audio_codec_enable = g4x_audio_codec_enable, + .audio_codec_disable = g4x_audio_codec_disable, +}; + +static const struct drm_i915_display_audio_funcs ilk_audio_funcs = { + .audio_codec_enable = ilk_audio_codec_enable, + .audio_codec_disable = ilk_audio_codec_disable, +}; + +static const struct drm_i915_display_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 * @dev_priv: device private @@ -922,17 +937,13 @@ void intel_audio_codec_disable(struct intel_encoder *encoder, void intel_init_audio_hooks(struct drm_i915_private *dev_priv) { if (IS_G4X(dev_priv)) { - dev_priv->audio_funcs.audio_codec_enable = g4x_audio_codec_enable; - dev_priv->audio_funcs.audio_codec_disable = g4x_audio_codec_disable; + dev_priv->audio_funcs = &g4x_audio_funcs; } 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.audio_codec_disable = ilk_audio_codec_disable; + dev_priv->audio_funcs = &ilk_audio_funcs; } 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.audio_codec_disable = hsw_audio_codec_disable; + dev_priv->audio_funcs = &hsw_audio_funcs; } else if (HAS_PCH_SPLIT(dev_priv)) { - dev_priv->audio_funcs.audio_codec_enable = ilk_audio_codec_enable; - dev_priv->audio_funcs.audio_codec_disable = ilk_audio_codec_disable; + dev_priv->audio_funcs = &ilk_audio_funcs; } } diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index e82df3bf493b..8d14318c5708 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1018,7 +1018,7 @@ struct drm_i915_private { const struct drm_i915_display_color_funcs *color_funcs; /* Display internal audio functions */ - struct drm_i915_display_audio_funcs audio_funcs; + const struct drm_i915_display_audio_funcs *audio_funcs; /* Display CDCLK functions */ struct drm_i915_display_cdclk_funcs cdclk_funcs;
From: Dave Airlie <airlied@redhat.com> --- drivers/gpu/drm/i915/display/intel_audio.c | 43 ++++++++++++++-------- drivers/gpu/drm/i915/i915_drv.h | 2 +- 2 files changed, 28 insertions(+), 17 deletions(-)