Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: intel-gfx@lists.freedesktop.org, alsa-devel@alsa-project.org,
	Takashi Iwai <tiwai@suse.de>
Subject: [PATCH 2/5] drm/i915: add component support
Date: Mon,  8 Dec 2014 18:42:06 +0200	[thread overview]
Message-ID: <1418056929-7977-3-git-send-email-imre.deak@intel.com> (raw)
In-Reply-To: <1418056929-7977-1-git-send-email-imre.deak@intel.com>

Register a component master to be used to interface with the
snd_hda_intel driver. This is meant to replace the same interface that
is currently based on module symbol lookup.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/i915_dma.c | 80 +++++++++++++++++++++++++++++++++++++++++
 include/drm/i915_component.h    | 38 ++++++++++++++++++++
 2 files changed, 118 insertions(+)
 create mode 100644 include/drm/i915_component.h

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 887d88f..6e0f3be 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -35,6 +35,8 @@
 #include <drm/drm_legacy.h>
 #include "intel_drv.h"
 #include <drm/i915_drm.h>
+#include <linux/component.h>
+#include <drm/i915_component.h>
 #include "i915_drv.h"
 #include "i915_trace.h"
 #include <linux/pci.h>
@@ -600,6 +602,80 @@ static void intel_device_info_runtime_init(struct drm_device *dev)
 	}
 }
 
+static void i915_component_get_power(struct device *dev)
+{
+	intel_display_power_get(dev_to_i915_priv(dev), POWER_DOMAIN_AUDIO);
+}
+
+static void i915_component_put_power(struct device *dev)
+{
+	intel_display_power_put(dev_to_i915_priv(dev), POWER_DOMAIN_AUDIO);
+}
+
+/* Get CDCLK in kHz  */
+static int i915_component_get_cdclk_freq(struct device *dev)
+{
+	struct drm_i915_private *dev_priv = dev_to_i915_priv(dev);
+	int ret;
+
+	if (WARN_ON_ONCE(!HAS_DDI(dev_priv)))
+		return -ENODEV;
+
+	intel_display_power_get(dev_priv, POWER_DOMAIN_AUDIO);
+	ret = intel_ddi_get_cdclk_freq(dev_priv);
+	intel_display_power_put(dev_priv, POWER_DOMAIN_AUDIO);
+
+	return ret;
+}
+
+static struct i915_component_ops component_ops = {
+	.owner		= THIS_MODULE,
+	.get_power	= i915_component_get_power,
+	.put_power	= i915_component_put_power,
+	.get_cdclk	= i915_component_get_cdclk_freq,
+};
+
+static int i915_component_master_bind(struct device *dev)
+{
+	return component_bind_all(dev, &component_ops);
+}
+
+static void i915_component_master_unbind(struct device *dev)
+{
+	return component_unbind_all(dev, &component_ops);
+}
+
+static const struct component_master_ops i915_component_master_ops = {
+	.bind	= i915_component_master_bind,
+	.unbind	= i915_component_master_unbind,
+};
+
+static int i915_component_master_match(struct device *dev, void *data)
+{
+	/* snd_hda_intel is the only supported component */
+	return !strcmp(dev->driver->name, "snd_hda_intel");
+}
+
+static void i915_component_master_init(struct drm_i915_private *dev_priv)
+{
+	struct device *dev = dev_priv->dev->dev;
+	struct component_match *match = NULL;
+	int ret;
+
+	component_match_add(dev, &match, i915_component_master_match, NULL);
+	ret = component_master_add_with_match(dev, &i915_component_master_ops,
+					      match);
+	if (ret < 0)
+		DRM_ERROR("failed to add component master (%d)\n", ret);
+	/* continue with reduced functionality */
+}
+
+static void i915_component_master_cleanup(struct drm_i915_private *dev_priv)
+{
+	/* the following is ok to call even if component_master_add failed */
+	component_master_del(dev_priv->dev->dev, &i915_component_master_ops);
+}
+
 /**
  * i915_driver_load - setup chip and create an initial config
  * @dev: DRM device
@@ -830,6 +906,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 
 	intel_runtime_pm_enable(dev_priv);
 
+	i915_component_master_init(dev_priv);
+
 	return 0;
 
 out_power_well:
@@ -870,6 +948,8 @@ int i915_driver_unload(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	int ret;
 
+	i915_component_master_cleanup(dev_priv);
+
 	ret = i915_gem_suspend(dev);
 	if (ret) {
 		DRM_ERROR("failed to idle hardware: %d\n", ret);
diff --git a/include/drm/i915_component.h b/include/drm/i915_component.h
new file mode 100644
index 0000000..44542c2
--- /dev/null
+++ b/include/drm/i915_component.h
@@ -0,0 +1,38 @@
+/**************************************************************************
+ *
+ * Copyright 2014 Intel Inc.
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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.
+ *
+ **************************************************************************/
+
+#ifndef _I915_COMPONENT_H_
+#define _I915_COMPONENT_H_
+
+struct i915_component_ops {
+	struct module *owner;
+	void (*get_power)(struct device *);
+	void (*put_power)(struct device *);
+	int (*get_cdclk)(struct device *);
+};
+
+#endif				/* _I915_COMPONENT_H_ */
-- 
1.8.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2014-12-08 16:42 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-08 16:42 [PATCH 0/5] sanitize hda/i915 interface using the component fw Imre Deak
2014-12-08 16:42 ` [PATCH 1/5] drm/i915: add dev_to_i915_priv helper Imre Deak
2014-12-08 18:36   ` Jani Nikula
2014-12-08 19:54     ` Imre Deak
2014-12-08 20:27   ` Daniel Vetter
2014-12-08 20:40   ` Chris Wilson
2014-12-08 21:26     ` Imre Deak
2014-12-09  9:41   ` [PATCH v2 1/5] drm/i915: add dev_to_i915 helper Imre Deak
2014-12-09 10:08     ` Daniel Vetter
2014-12-09 16:15     ` [PATCH v3 " Imre Deak
2014-12-08 16:42 ` Imre Deak [this message]
2014-12-08 18:44   ` [PATCH 2/5] drm/i915: add component support Jani Nikula
2014-12-08 20:23     ` Imre Deak
2014-12-09  9:41   ` [PATCH v2 " Imre Deak
2014-12-09 10:12     ` Daniel Vetter
2014-12-09 10:33       ` Jani Nikula
2014-12-10  9:24         ` Daniel Vetter
2014-12-09 16:15     ` [PATCH v3 " Imre Deak
2014-12-10  8:22       ` Jani Nikula
2014-12-10 13:18         ` Imre Deak
2014-12-08 16:42 ` [PATCH 3/5] ALSA: hda: pass chip to all i915 interface functions Imre Deak
2014-12-08 16:42 ` [PATCH 4/5] ALSA: hda: add component support Imre Deak
2014-12-09  9:41   ` [PATCH v2 " Imre Deak
2014-12-09 10:19     ` Daniel Vetter
2014-12-09 17:30       ` Takashi Iwai
2014-12-10  9:27         ` Daniel Vetter
2014-12-09 16:15     ` [PATCH v3 " Imre Deak
2014-12-08 16:42 ` [PATCH 5/5] drm/i915: remove unused power_well/get_cdclk_freq api Imre Deak
2014-12-08 18:46   ` Jani Nikula
2014-12-08 20:14 ` [PATCH 0/5] sanitize hda/i915 interface using the component fw Daniel Vetter
2014-12-09  8:59   ` Imre Deak
2014-12-09 10:03     ` Daniel Vetter
2014-12-09 16:56       ` Imre Deak
2014-12-09 17:33         ` Takashi Iwai
2015-01-05 15:29           ` Imre Deak
2015-01-05 15:35             ` Takashi Iwai
2015-01-05 17:25               ` Imre Deak
2015-01-06 10:25                 ` Takashi Iwai
2015-01-07 19:49                   ` Imre Deak
2015-01-08 14:35                     ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1418056929-7977-3-git-send-email-imre.deak@intel.com \
    --to=imre.deak@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox