From e2a7f0e8206cef5ac3bf279c28a5023d80a51c11 Mon Sep 17 00:00:00 2001
From: Timo Aaltonen <timo.aaltonen@canonical.com>
Date: Thu, 9 Jul 2015 17:58:27 +0300
Subject: [PATCH] Revert "drm/i915: add component support"

This reverts commit 58fddc288b5cec192ad9eb9221da7ed14d974a27.

Conflicts:
	drivers/gpu/drm/i915/intel_audio.c
	include/drm/i915_component.h
---
 drivers/gpu/drm/i915/i915_dma.c    |   4 --
 drivers/gpu/drm/i915/i915_drv.h    |   3 -
 drivers/gpu/drm/i915/intel_audio.c | 138 -------------------------------------
 drivers/gpu/drm/i915/intel_drv.h   |   2 -
 4 files changed, 147 deletions(-)

--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -967,8 +967,6 @@ int i915_driver_load(struct drm_device *
 
 	intel_runtime_pm_enable(dev_priv);
 
-	i915_audio_component_init(dev_priv);
-
 	return 0;
 
 out_power_well:
@@ -1016,8 +1014,6 @@ int i915_driver_unload(struct drm_device
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	int ret;
 
-	i915_audio_component_cleanup(dev_priv);
-
 	ret = i915_gem_suspend(dev);
 	if (ret) {
 		DRM_ERROR("failed to idle hardware: %d\n", ret);
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1807,9 +1807,6 @@ struct drm_i915_private {
 	struct drm_property *broadcast_rgb_property;
 	struct drm_property *force_audio_property;
 
-	/* hda/i915 audio component */
-	bool audio_component_registered;
-
 	uint32_t hw_context_size;
 	struct list_head context_list;
 
--- a/drivers/gpu/drm/i915/intel_audio.c
+++ b/drivers/gpu/drm/i915/intel_audio.c
@@ -22,9 +22,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/component.h>
-#include <drm/i915_component.h>
-#include "intel_drv.h"
 
 #include <drm/drmP.h>
 #include <drm/drm_edid.h>
@@ -459,138 +456,3 @@ void intel_init_audio(struct drm_device
 		dev_priv->display.audio_codec_disable = ilk_audio_codec_disable;
 	}
 }
-
-static void i915_audio_component_get_power(struct device *dev)
-{
-	intel_display_power_get(dev_to_i915(dev), POWER_DOMAIN_AUDIO);
-}
-
-static void i915_audio_component_put_power(struct device *dev)
-{
-	intel_display_power_put(dev_to_i915(dev), POWER_DOMAIN_AUDIO);
-}
-
-static void i915_audio_component_codec_wake_override(struct device *dev,
-						     bool enable)
-{
-	struct drm_i915_private *dev_priv = dev_to_i915(dev);
-	u32 tmp;
-
-	if (!IS_SKYLAKE(dev_priv))
-		return;
-
-	/*
-	 * Enable/disable generating the codec wake signal, overriding the
-	 * internal logic to generate the codec wake to controller.
-	 */
-	tmp = I915_READ(HSW_AUD_CHICKENBIT);
-	tmp &= ~SKL_AUD_CODEC_WAKE_SIGNAL;
-	I915_WRITE(HSW_AUD_CHICKENBIT, tmp);
-	usleep_range(1000, 1500);
-
-	if (enable) {
-		tmp = I915_READ(HSW_AUD_CHICKENBIT);
-		tmp |= SKL_AUD_CODEC_WAKE_SIGNAL;
-		I915_WRITE(HSW_AUD_CHICKENBIT, tmp);
-		usleep_range(1000, 1500);
-	}
-}
-
-/* Get CDCLK in kHz  */
-static int i915_audio_component_get_cdclk_freq(struct device *dev)
-{
-	struct drm_i915_private *dev_priv = dev_to_i915(dev);
-	int ret;
-
-	if (WARN_ON_ONCE(!HAS_DDI(dev_priv)))
-		return -ENODEV;
-
-	intel_display_power_get(dev_priv, POWER_DOMAIN_AUDIO);
-	ret = dev_priv->display.get_display_clock_speed(dev_priv->dev);
-
-	intel_display_power_put(dev_priv, POWER_DOMAIN_AUDIO);
-
-	return ret;
-}
-
-static const struct i915_audio_component_ops i915_audio_component_ops = {
-	.owner		= THIS_MODULE,
-	.get_power	= i915_audio_component_get_power,
-	.put_power	= i915_audio_component_put_power,
-	.codec_wake_override = i915_audio_component_codec_wake_override,
-	.get_cdclk_freq	= i915_audio_component_get_cdclk_freq,
-};
-
-static int i915_audio_component_bind(struct device *i915_dev,
-				     struct device *hda_dev, void *data)
-{
-	struct i915_audio_component *acomp = data;
-
-	if (WARN_ON(acomp->ops || acomp->dev))
-		return -EEXIST;
-
-	acomp->ops = &i915_audio_component_ops;
-	acomp->dev = i915_dev;
-
-	return 0;
-}
-
-static void i915_audio_component_unbind(struct device *i915_dev,
-					struct device *hda_dev, void *data)
-{
-	struct i915_audio_component *acomp = data;
-
-	acomp->ops = NULL;
-	acomp->dev = NULL;
-}
-
-static const struct component_ops i915_audio_component_bind_ops = {
-	.bind	= i915_audio_component_bind,
-	.unbind	= i915_audio_component_unbind,
-};
-
-/**
- * i915_audio_component_init - initialize and register the audio component
- * @dev_priv: i915 device instance
- *
- * 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).
- */
-void i915_audio_component_init(struct drm_i915_private *dev_priv)
-{
-	int ret;
-
-	ret = component_add(dev_priv->dev->dev, &i915_audio_component_bind_ops);
-	if (ret < 0) {
-		DRM_ERROR("failed to add audio component (%d)\n", ret);
-		/* continue with reduced functionality */
-		return;
-	}
-
-	dev_priv->audio_component_registered = true;
-}
-
-/**
- * i915_audio_component_cleanup - deregister the audio component
- * @dev_priv: i915 device instance
- *
- * Deregisters the audio component, breaking any existing binding to the
- * corresponding snd_hda_intel driver's master component.
- */
-void i915_audio_component_cleanup(struct drm_i915_private *dev_priv)
-{
-	if (!dev_priv->audio_component_registered)
-		return;
-
-	component_del(dev_priv->dev->dev, &i915_audio_component_bind_ops);
-	dev_priv->audio_component_registered = false;
-}
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -984,8 +984,6 @@ u32 intel_fb_stride_alignment(struct drm
 void intel_init_audio(struct drm_device *dev);
 void intel_audio_codec_enable(struct intel_encoder *encoder);
 void intel_audio_codec_disable(struct intel_encoder *encoder);
-void i915_audio_component_init(struct drm_i915_private *dev_priv);
-void i915_audio_component_cleanup(struct drm_i915_private *dev_priv);
 
 /* intel_display.c */
 extern const struct drm_plane_funcs intel_plane_funcs;
