From patchwork Fri Dec 22 12:52:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ughreja, Rakesh A" X-Patchwork-Id: 10130449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7CA2560318 for ; Fri, 22 Dec 2017 12:58:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6566229E34 for ; Fri, 22 Dec 2017 12:58:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 591FF29F11; Fri, 22 Dec 2017 12:58:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C58429E34 for ; Fri, 22 Dec 2017 12:58:50 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 90BD9267931; Fri, 22 Dec 2017 13:56:25 +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 DB9B7267968; Fri, 22 Dec 2017 13:56:16 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by alsa0.perex.cz (Postfix) with ESMTP id B9674267932 for ; Fri, 22 Dec 2017 13:48:23 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Dec 2017 04:48:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,441,1508828400"; d="scan'208";a="4029059" Received: from raughrej-desk.iind.intel.com ([10.223.84.131]) by fmsmga002.fm.intel.com with ESMTP; 22 Dec 2017 04:48:20 -0800 From: Rakesh Ughreja To: alsa-devel@alsa-project.org, broonie@kernel.org, tiwai@suse.de, liam.r.girdwood@linux.intel.com Date: Fri, 22 Dec 2017 18:22:50 +0530 Message-Id: <1513947172-28136-8-git-send-email-rakesh.a.ughreja@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513947172-28136-1-git-send-email-rakesh.a.ughreja@intel.com> References: <1513947172-28136-1-git-send-email-rakesh.a.ughreja@intel.com> Cc: vinod.koul@intel.com, patches.audio@intel.com, Rakesh Ughreja , pierre-louis.bossart@linux.intel.com Subject: [alsa-devel] [RFC v4 7/9] ALSA: hdac: add bus type and extended ops support in hdac_bus 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 Add add bus type field in hdac_bus structure to distinguish the bus instance. Bus allocated using snd_hdac_bus_init API sets the bus type to HDA_BUS_LEGACY and snd_hdac_ext_bus_init API sets it to HDA_BUS_EXT. codec drivers can identify the bus type by calling snd_hdac_get_bus_type API. Extended ops are used by the legacy codec drivers to call into hdac_hda library, in the subsequent patches.. Signed-off-by: Rakesh Ughreja --- include/sound/hdaudio.h | 24 ++++++++++++++++++++++++ include/sound/hdaudio_ext.h | 3 ++- sound/hda/ext/hdac_ext_bus.c | 5 ++++- sound/hda/hdac_bus.c | 1 + sound/soc/intel/skylake/skl.c | 2 +- 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index 30ec1b0..44e5514 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -97,6 +97,12 @@ enum { HDA_DEV_ASOC, }; +enum { + HDA_BUS_INVALID, + HDA_BUS_LEGACY, + HDA_BUS_EXT, +}; + /* direction */ enum { HDA_INPUT, HDA_OUTPUT @@ -212,6 +218,14 @@ struct hdac_bus_ops { }; /* + * ops used for ASoC HDA codec drivers + */ +struct hdac_ext_bus_ops { + int (*probe)(struct hdac_device *hdev); + int (*remove)(struct hdac_device *hdev); +}; + +/* * Lowlevel I/O operators */ struct hdac_io_ops { @@ -265,8 +279,10 @@ struct hdac_rb { */ struct hdac_bus { struct device *dev; + int type; const struct hdac_bus_ops *ops; const struct hdac_io_ops *io_ops; + const struct hdac_ext_bus_ops *ext_ops; /* h/w resources */ unsigned long addr; @@ -341,6 +357,14 @@ struct hdac_bus { }; +static inline int snd_hdac_get_bus_type(struct hdac_bus *bus) +{ + if (bus) + return bus->type; + else + return HDA_BUS_INVALID; +} + int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev, const struct hdac_bus_ops *ops, const struct hdac_io_ops *io_ops); diff --git a/include/sound/hdaudio_ext.h b/include/sound/hdaudio_ext.h index c188b80..f34aced 100644 --- a/include/sound/hdaudio_ext.h +++ b/include/sound/hdaudio_ext.h @@ -6,7 +6,8 @@ int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev, const struct hdac_bus_ops *ops, - const struct hdac_io_ops *io_ops); + const struct hdac_io_ops *io_ops, + const struct hdac_ext_bus_ops *ext_ops); void snd_hdac_ext_bus_exit(struct hdac_bus *bus); int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr, diff --git a/sound/hda/ext/hdac_ext_bus.c b/sound/hda/ext/hdac_ext_bus.c index e4bcb76..b68ef25 100644 --- a/sound/hda/ext/hdac_ext_bus.c +++ b/sound/hda/ext/hdac_ext_bus.c @@ -89,7 +89,8 @@ static const struct hdac_io_ops hdac_ext_default_io = { */ int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev, const struct hdac_bus_ops *ops, - const struct hdac_io_ops *io_ops) + const struct hdac_io_ops *io_ops, + const struct hdac_ext_bus_ops *ext_ops) { int ret; static int idx; @@ -102,6 +103,8 @@ int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev, if (ret < 0) return ret; + bus->type = HDA_BUS_EXT; + bus->ext_ops = ext_ops; INIT_LIST_HEAD(&bus->hlink_list); bus->idx = idx++; diff --git a/sound/hda/hdac_bus.c b/sound/hda/hdac_bus.c index 714a517..bb7567d 100644 --- a/sound/hda/hdac_bus.c +++ b/sound/hda/hdac_bus.c @@ -35,6 +35,7 @@ int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev, else bus->ops = &default_ops; bus->io_ops = io_ops; + bus->type = HDA_BUS_LEGACY; INIT_LIST_HEAD(&bus->stream_list); INIT_LIST_HEAD(&bus->codec_list); INIT_WORK(&bus->unsol_work, process_unsol_events); diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index d8fa403..050aa3c 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -776,7 +776,7 @@ static int skl_create(struct pci_dev *pci, hbus = skl_to_hbus(skl); bus = skl_to_bus(skl); - snd_hdac_ext_bus_init(bus, &pci->dev, &bus_core_ops, io_ops); + snd_hdac_ext_bus_init(bus, &pci->dev, &bus_core_ops, io_ops, NULL); bus->use_posbuf = 1; skl->pci = pci; INIT_WORK(&skl->probe_work, skl_probe_work);