Commit 14ee9fa8 authored by Jani Nikula's avatar Jani Nikula

drm/i915/audio: migrate away from kdev_to_i915()

Use to_intel_display() instead of kdev_to_i915() in the audio component
API hooks. Avoid further drive-by changes at this point, and just
convert the display pointer to i915, and leave the struct intel_display
conversion for later.
Reviewed-by: default avatarGustavo Sousa <gustavo.sousa@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/35ef00470db0088eb82b0406e4f7730154f54baf.1724942754.git.jani.nikula@intel.comSigned-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent 6a2161a1
...@@ -980,7 +980,8 @@ static void glk_force_audio_cdclk(struct drm_i915_private *i915, ...@@ -980,7 +980,8 @@ static void glk_force_audio_cdclk(struct drm_i915_private *i915,
static unsigned long i915_audio_component_get_power(struct device *kdev) static unsigned long i915_audio_component_get_power(struct device *kdev)
{ {
struct drm_i915_private *i915 = kdev_to_i915(kdev); struct intel_display *display = to_intel_display(kdev);
struct drm_i915_private *i915 = to_i915(display->drm);
intel_wakeref_t ret; intel_wakeref_t ret;
/* Catch potential impedance mismatches before they occur! */ /* Catch potential impedance mismatches before they occur! */
...@@ -1012,7 +1013,8 @@ static unsigned long i915_audio_component_get_power(struct device *kdev) ...@@ -1012,7 +1013,8 @@ static unsigned long i915_audio_component_get_power(struct device *kdev)
static void i915_audio_component_put_power(struct device *kdev, static void i915_audio_component_put_power(struct device *kdev,
unsigned long cookie) unsigned long cookie)
{ {
struct drm_i915_private *i915 = kdev_to_i915(kdev); struct intel_display *display = to_intel_display(kdev);
struct drm_i915_private *i915 = to_i915(display->drm);
/* Stop forcing CDCLK to 2*BCLK if no need for audio to be powered. */ /* Stop forcing CDCLK to 2*BCLK if no need for audio to be powered. */
if (--i915->display.audio.power_refcount == 0) if (--i915->display.audio.power_refcount == 0)
...@@ -1025,7 +1027,8 @@ static void i915_audio_component_put_power(struct device *kdev, ...@@ -1025,7 +1027,8 @@ static void i915_audio_component_put_power(struct device *kdev,
static void i915_audio_component_codec_wake_override(struct device *kdev, static void i915_audio_component_codec_wake_override(struct device *kdev,
bool enable) bool enable)
{ {
struct drm_i915_private *i915 = kdev_to_i915(kdev); struct intel_display *display = to_intel_display(kdev);
struct drm_i915_private *i915 = to_i915(display->drm);
unsigned long cookie; unsigned long cookie;
if (DISPLAY_VER(i915) < 9) if (DISPLAY_VER(i915) < 9)
...@@ -1053,7 +1056,8 @@ static void i915_audio_component_codec_wake_override(struct device *kdev, ...@@ -1053,7 +1056,8 @@ static void i915_audio_component_codec_wake_override(struct device *kdev,
/* Get CDCLK in kHz */ /* Get CDCLK in kHz */
static int i915_audio_component_get_cdclk_freq(struct device *kdev) static int i915_audio_component_get_cdclk_freq(struct device *kdev)
{ {
struct drm_i915_private *i915 = kdev_to_i915(kdev); struct intel_display *display = to_intel_display(kdev);
struct drm_i915_private *i915 = to_i915(display->drm);
if (drm_WARN_ON_ONCE(&i915->drm, !HAS_DDI(i915))) if (drm_WARN_ON_ONCE(&i915->drm, !HAS_DDI(i915)))
return -ENODEV; return -ENODEV;
...@@ -1112,7 +1116,8 @@ static struct intel_audio_state *find_audio_state(struct drm_i915_private *i915, ...@@ -1112,7 +1116,8 @@ static struct intel_audio_state *find_audio_state(struct drm_i915_private *i915,
static int i915_audio_component_sync_audio_rate(struct device *kdev, int port, static int i915_audio_component_sync_audio_rate(struct device *kdev, int port,
int cpu_transcoder, int rate) int cpu_transcoder, int rate)
{ {
struct drm_i915_private *i915 = kdev_to_i915(kdev); struct intel_display *display = to_intel_display(kdev);
struct drm_i915_private *i915 = to_i915(display->drm);
struct i915_audio_component *acomp = i915->display.audio.component; struct i915_audio_component *acomp = i915->display.audio.component;
const struct intel_audio_state *audio_state; const struct intel_audio_state *audio_state;
struct intel_encoder *encoder; struct intel_encoder *encoder;
...@@ -1154,7 +1159,8 @@ static int i915_audio_component_get_eld(struct device *kdev, int port, ...@@ -1154,7 +1159,8 @@ static int i915_audio_component_get_eld(struct device *kdev, int port,
int cpu_transcoder, bool *enabled, int cpu_transcoder, bool *enabled,
unsigned char *buf, int max_bytes) unsigned char *buf, int max_bytes)
{ {
struct drm_i915_private *i915 = kdev_to_i915(kdev); struct intel_display *display = to_intel_display(kdev);
struct drm_i915_private *i915 = to_i915(display->drm);
const struct intel_audio_state *audio_state; const struct intel_audio_state *audio_state;
int ret = 0; int ret = 0;
...@@ -1189,24 +1195,25 @@ static const struct drm_audio_component_ops i915_audio_component_ops = { ...@@ -1189,24 +1195,25 @@ static const struct drm_audio_component_ops i915_audio_component_ops = {
.get_eld = i915_audio_component_get_eld, .get_eld = i915_audio_component_get_eld,
}; };
static int i915_audio_component_bind(struct device *i915_kdev, static int i915_audio_component_bind(struct device *drv_kdev,
struct device *hda_kdev, void *data) struct device *hda_kdev, void *data)
{ {
struct intel_display *display = to_intel_display(drv_kdev);
struct drm_i915_private *i915 = to_i915(display->drm);
struct i915_audio_component *acomp = data; struct i915_audio_component *acomp = data;
struct drm_i915_private *i915 = kdev_to_i915(i915_kdev);
int i; int i;
if (drm_WARN_ON(&i915->drm, acomp->base.ops || acomp->base.dev)) if (drm_WARN_ON(&i915->drm, acomp->base.ops || acomp->base.dev))
return -EEXIST; return -EEXIST;
if (drm_WARN_ON(&i915->drm, if (drm_WARN_ON(&i915->drm,
!device_link_add(hda_kdev, i915_kdev, !device_link_add(hda_kdev, drv_kdev,
DL_FLAG_STATELESS))) DL_FLAG_STATELESS)))
return -ENOMEM; return -ENOMEM;
drm_modeset_lock_all(&i915->drm); drm_modeset_lock_all(&i915->drm);
acomp->base.ops = &i915_audio_component_ops; acomp->base.ops = &i915_audio_component_ops;
acomp->base.dev = i915_kdev; acomp->base.dev = drv_kdev;
BUILD_BUG_ON(MAX_PORTS != I915_MAX_PORTS); BUILD_BUG_ON(MAX_PORTS != I915_MAX_PORTS);
for (i = 0; i < ARRAY_SIZE(acomp->aud_sample_rate); i++) for (i = 0; i < ARRAY_SIZE(acomp->aud_sample_rate); i++)
acomp->aud_sample_rate[i] = 0; acomp->aud_sample_rate[i] = 0;
...@@ -1216,11 +1223,12 @@ static int i915_audio_component_bind(struct device *i915_kdev, ...@@ -1216,11 +1223,12 @@ static int i915_audio_component_bind(struct device *i915_kdev,
return 0; return 0;
} }
static void i915_audio_component_unbind(struct device *i915_kdev, static void i915_audio_component_unbind(struct device *drv_kdev,
struct device *hda_kdev, void *data) struct device *hda_kdev, void *data)
{ {
struct intel_display *display = to_intel_display(drv_kdev);
struct drm_i915_private *i915 = to_i915(display->drm);
struct i915_audio_component *acomp = data; struct i915_audio_component *acomp = data;
struct drm_i915_private *i915 = kdev_to_i915(i915_kdev);
drm_modeset_lock_all(&i915->drm); drm_modeset_lock_all(&i915->drm);
acomp->base.ops = NULL; acomp->base.ops = NULL;
...@@ -1228,7 +1236,7 @@ static void i915_audio_component_unbind(struct device *i915_kdev, ...@@ -1228,7 +1236,7 @@ static void i915_audio_component_unbind(struct device *i915_kdev,
i915->display.audio.component = NULL; i915->display.audio.component = NULL;
drm_modeset_unlock_all(&i915->drm); drm_modeset_unlock_all(&i915->drm);
device_link_remove(hda_kdev, i915_kdev); device_link_remove(hda_kdev, drv_kdev);
if (i915->display.audio.power_refcount) if (i915->display.audio.power_refcount)
drm_err(&i915->drm, "audio power refcount %d after unbind\n", drm_err(&i915->drm, "audio power refcount %d after unbind\n",
......
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