From patchwork Mon Dec 8 16:42:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 5457641 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9A79EBEEA8 for ; Mon, 8 Dec 2014 16:48:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A664E2011D for ; Mon, 8 Dec 2014 16:48:55 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 3FA4E2010F for ; Mon, 8 Dec 2014 16:48:54 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 0BCDB261560; Mon, 8 Dec 2014 17:48:52 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 8658026149E; Mon, 8 Dec 2014 17:48:42 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id BF8C32614AC; Mon, 8 Dec 2014 17:48:41 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by alsa0.perex.cz (Postfix) with ESMTP id D593726149E for ; Mon, 8 Dec 2014 17:48:32 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 08 Dec 2014 08:44:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,539,1413270000"; d="scan'208";a="634507616" Received: from intelbox.fi.intel.com (HELO localhost) ([10.237.72.105]) by fmsmga001.fm.intel.com with ESMTP; 08 Dec 2014 08:44:22 -0800 From: Imre Deak To: intel-gfx@lists.freedesktop.org, alsa-devel@alsa-project.org, Takashi Iwai Date: Mon, 8 Dec 2014 18:42:06 +0200 Message-Id: <1418056929-7977-3-git-send-email-imre.deak@intel.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1418056929-7977-1-git-send-email-imre.deak@intel.com> References: <1418056929-7977-1-git-send-email-imre.deak@intel.com> Subject: [alsa-devel] [PATCH 2/5] drm/i915: add component support X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 #include "intel_drv.h" #include +#include +#include #include "i915_drv.h" #include "i915_trace.h" #include @@ -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_ */