From patchwork Fri Feb 28 06:35:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Reid X-Patchwork-Id: 3739031 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 650059F2ED for ; Fri, 28 Feb 2014 06:49:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4985020138 for ; Fri, 28 Feb 2014 06:49:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id A797120260 for ; Fri, 28 Feb 2014 06:49:18 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8C289265D6E; Fri, 28 Feb 2014 07:49:15 +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 2EB9E26597D; Fri, 28 Feb 2014 07:38:27 +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 A5B192650CA; Fri, 28 Feb 2014 07:38:22 +0100 (CET) Received: from mail-pd0-f201.google.com (mail-pd0-f201.google.com [209.85.192.201]) by alsa0.perex.cz (Postfix) with ESMTP id 1CAA52650D1 for ; Fri, 28 Feb 2014 07:37:13 +0100 (CET) Received: by mail-pd0-f201.google.com with SMTP id x10so33852pdj.4 for ; Thu, 27 Feb 2014 22:37:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bvRdAe2so7fJM1WvV4kNtPEUUhKVv2jGp/tkgLyzuug=; b=e/zXf8pIVoc5QMUK+YXrgflTml4tX9r+GC6evuws3OdWVrIjtmB7BnwkEP4dV4wOlc 3NQAy9pY8Uohd0WHJD4SZML3FRJIZBhFkTgKXH6NfyNrGsXRqhEwsgCBwu50WMefWQZY 1Dne9ULWe7WHlwHk20Rmlx/vnYUPCNdbZLFqn2C9MFLfTgDtJnp/JUV/cpD2xj33Sza+ QL26XY7qUwjsIrytWxOb8U7eHKJmDupohWuqAL8OAnWVMnWFftoNqKeTAyV/7IhYT7oT oWxM6Ymxa7H1XYTIxm39tYi6ScttQhBPavii7l4w3p83U4T7QCe6mmDAQ1dw5WAlRvKJ TozQ== X-Gm-Message-State: ALoCoQng1LGlqHOuHNsIKEjvixDjNJpWeZTUGnVm1mMyPciQOCi1VLyq588RiUbAl1bldCmNvRhQ0twEQGtiMQ6vg9ihxh55uIIv1L88FsZKSE/tReqPqOurrPHzQMmvky8Cgvbv2nqjy/6k9tU5+4oI0E/7IVFSXeyENFBQRJjDqx3NdHoYn/Rto2w9XU2Uc9J3UG1S+har8S0A8bnrM7JN8XaSePB3gpKWNaNXlkcsIQNCWWfbJxs= X-Received: by 10.66.150.106 with SMTP id uh10mr468522pab.13.1393569432791; Thu, 27 Feb 2014 22:37:12 -0800 (PST) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id k45si113841yhn.4.2014.02.27.22.37.12 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Feb 2014 22:37:12 -0800 (PST) Received: from hojo20.mtv.corp.google.com (hojo20.mtv.corp.google.com [172.22.72.28]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 87FBC31C2CE; Thu, 27 Feb 2014 22:37:12 -0800 (PST) Received: by hojo20.mtv.corp.google.com (Postfix, from userid 123195) id 3901B18113D; Thu, 27 Feb 2014 22:37:12 -0800 (PST) From: Dylan Reid To: alsa-devel@alsa-project.org Date: Thu, 27 Feb 2014 22:35:56 -0800 Message-Id: <1393569362-27285-14-git-send-email-dgreid@chromium.org> X-Mailer: git-send-email 1.8.1.3.605.g02339dd In-Reply-To: <1393569362-27285-1-git-send-email-dgreid@chromium.org> References: <1393569362-27285-1-git-send-email-dgreid@chromium.org> Cc: tiwai@suse.de, Dylan Reid , swarren@wwwdotorg.org Subject: [alsa-devel] [RFC 13/19] ALSA: hda - Move azx_interrupt to hda_shared 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 This code will be reused by an hda_platform driver as it has no PCI dependencies. This allows update_rirb to be static as all users are now in hda_shared.c. Signed-off-by: Dylan Reid --- sound/pci/hda/hda_intel.c | 124 ------------------------------------------ sound/pci/hda/hda_shared.c | 131 ++++++++++++++++++++++++++++++++++++++++++++- sound/pci/hda/hda_shared.h | 5 +- 3 files changed, 132 insertions(+), 128 deletions(-) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 00f4482..da5c7d2 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -393,77 +393,6 @@ static void azx_init_pci(struct azx *chip) } } - -/* - * interrupt handler - */ -static irqreturn_t azx_interrupt(int irq, void *dev_id) -{ - struct azx *chip = dev_id; - struct azx_dev *azx_dev; - u32 status; - u8 sd_status; - int i, ok; - -#ifdef CONFIG_PM_RUNTIME - if (chip->driver_caps & AZX_DCAPS_PM_RUNTIME) - if (chip->card->dev->power.runtime_status != RPM_ACTIVE) - return IRQ_NONE; -#endif - - spin_lock(&chip->reg_lock); - - if (chip->disabled) { - spin_unlock(&chip->reg_lock); - return IRQ_NONE; - } - - status = azx_readl(chip, INTSTS); - if (status == 0 || status == 0xffffffff) { - spin_unlock(&chip->reg_lock); - return IRQ_NONE; - } - - for (i = 0; i < chip->num_streams; i++) { - azx_dev = &chip->azx_dev[i]; - if (status & azx_dev->sd_int_sta_mask) { - sd_status = azx_sd_readb(chip, azx_dev, SD_STS); - azx_sd_writeb(chip, azx_dev, SD_STS, SD_INT_MASK); - if (!azx_dev->substream || !azx_dev->running || - !(sd_status & SD_INT_COMPLETE)) - continue; - /* check whether this IRQ is really acceptable */ - ok = azx_position_ok(chip, azx_dev); - if (ok == 1) { - azx_dev->irq_pending = 0; - spin_unlock(&chip->reg_lock); - snd_pcm_period_elapsed(azx_dev->substream); - spin_lock(&chip->reg_lock); - } else if (ok == 0 && chip->bus && chip->bus->workq) { - /* bogus IRQ, process it later */ - azx_dev->irq_pending = 1; - queue_work(chip->bus->workq, - &chip->irq_pending_work); - } - } - } - - /* clear rirb int */ - status = azx_readb(chip, RIRBSTS); - if (status & RIRB_INT_MASK) { - if (status & RIRB_INT_RESPONSE) { - if (chip->driver_caps & AZX_DCAPS_RIRB_PRE_DELAY) - udelay(80); - azx_update_rirb(chip); - } - azx_writeb(chip, RIRBSTS, RIRB_INT_MASK); - } - - spin_unlock(&chip->reg_lock); - - return IRQ_HANDLED; -} - /* * Probe the given codec address */ @@ -631,59 +560,6 @@ static int azx_codec_configure(struct azx *chip) } /* - * The work for pending PCM period updates. - */ -static void azx_irq_pending_work(struct work_struct *work) -{ - struct azx *chip = container_of(work, struct azx, irq_pending_work); - int i, pending, ok; - - if (!chip->irq_pending_warned) { - dev_info(chip->card->dev, - "IRQ timing workaround is activated for card #%d. Suggest a bigger bdl_pos_adj.\n", - chip->card->number); - chip->irq_pending_warned = 1; - } - - for (;;) { - pending = 0; - spin_lock_irq(&chip->reg_lock); - for (i = 0; i < chip->num_streams; i++) { - struct azx_dev *azx_dev = &chip->azx_dev[i]; - if (!azx_dev->irq_pending || - !azx_dev->substream || - !azx_dev->running) - continue; - ok = azx_position_ok(chip, azx_dev); - if (ok > 0) { - azx_dev->irq_pending = 0; - spin_unlock(&chip->reg_lock); - snd_pcm_period_elapsed(azx_dev->substream); - spin_lock(&chip->reg_lock); - } else if (ok < 0) { - pending = 0; /* too early */ - } else - pending++; - } - spin_unlock_irq(&chip->reg_lock); - if (!pending) - return; - msleep(1); - } -} - -/* clear irq_pending flags and assure no on-going workq */ -static void azx_clear_irq_pending(struct azx *chip) -{ - int i; - - spin_lock_irq(&chip->reg_lock); - for (i = 0; i < chip->num_streams; i++) - chip->azx_dev[i].irq_pending = 0; - spin_unlock_irq(&chip->reg_lock); -} - -/* * mixer creation - all stuff is implemented in hda module */ static int azx_mixer_create(struct azx *chip) diff --git a/sound/pci/hda/hda_shared.c b/sound/pci/hda/hda_shared.c index de39752..2821363 100644 --- a/sound/pci/hda/hda_shared.c +++ b/sound/pci/hda/hda_shared.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -1095,7 +1096,7 @@ int azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec, * data is processed. So, we need to process it afterwords in a * workqueue. */ -int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev) +static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev) { u32 wallclk; unsigned int pos; @@ -1235,7 +1236,7 @@ static int azx_corb_send_cmd(struct hda_bus *bus, u32 val) #define ICH6_RIRB_EX_UNSOL_EV (1<<4) /* retrieve RIRB entry - called from interrupt handler */ -void azx_update_rirb(struct azx *chip) +static void azx_update_rirb(struct azx *chip) { unsigned int rp, wp; unsigned int addr; @@ -1826,5 +1827,131 @@ void azx_stop_chip(struct azx *chip) chip->initialized = 0; } +/* + * interrupt handler + */ +irqreturn_t azx_interrupt(int irq, void *dev_id) +{ + struct azx *chip = dev_id; + struct azx_dev *azx_dev; + u32 status; + u8 sd_status; + int i, ok; + +#ifdef CONFIG_PM_RUNTIME + if (chip->driver_caps & AZX_DCAPS_PM_RUNTIME) + if (chip->card->dev->power.runtime_status != RPM_ACTIVE) + return IRQ_NONE; +#endif + + spin_lock(&chip->reg_lock); + + if (chip->disabled) { + spin_unlock(&chip->reg_lock); + return IRQ_NONE; + } + + status = azx_readl(chip, INTSTS); + if (status == 0 || status == 0xffffffff) { + spin_unlock(&chip->reg_lock); + return IRQ_NONE; + } + + for (i = 0; i < chip->num_streams; i++) { + azx_dev = &chip->azx_dev[i]; + if (status & azx_dev->sd_int_sta_mask) { + sd_status = azx_sd_readb(chip, azx_dev, SD_STS); + azx_sd_writeb(chip, azx_dev, SD_STS, SD_INT_MASK); + if (!azx_dev->substream || !azx_dev->running || + !(sd_status & SD_INT_COMPLETE)) + continue; + /* check whether this IRQ is really acceptable */ + ok = azx_position_ok(chip, azx_dev); + if (ok == 1) { + azx_dev->irq_pending = 0; + spin_unlock(&chip->reg_lock); + snd_pcm_period_elapsed(azx_dev->substream); + spin_lock(&chip->reg_lock); + } else if (ok == 0 && chip->bus && chip->bus->workq) { + /* bogus IRQ, process it later */ + azx_dev->irq_pending = 1; + queue_work(chip->bus->workq, + &chip->irq_pending_work); + } + } + } + + /* clear rirb int */ + status = azx_readb(chip, RIRBSTS); + if (status & RIRB_INT_MASK) { + if (status & RIRB_INT_RESPONSE) { + if (chip->driver_caps & AZX_DCAPS_RIRB_PRE_DELAY) + udelay(80); + azx_update_rirb(chip); + } + azx_writeb(chip, RIRBSTS, RIRB_INT_MASK); + } + + spin_unlock(&chip->reg_lock); + + return IRQ_HANDLED; +} +EXPORT_SYMBOL_GPL(azx_interrupt); + +/* + * The work for pending PCM period updates. + */ +void azx_irq_pending_work(struct work_struct *work) +{ + struct azx *chip = container_of(work, struct azx, irq_pending_work); + int i, pending, ok; + + if (!chip->irq_pending_warned) { + dev_info(chip->card->dev, + "IRQ timing workaround is activated for card #%d. Suggest a bigger bdl_pos_adj.\n", + chip->card->number); + chip->irq_pending_warned = 1; + } + + for (;;) { + pending = 0; + spin_lock_irq(&chip->reg_lock); + for (i = 0; i < chip->num_streams; i++) { + struct azx_dev *azx_dev = &chip->azx_dev[i]; + if (!azx_dev->irq_pending || + !azx_dev->substream || + !azx_dev->running) + continue; + ok = azx_position_ok(chip, azx_dev); + if (ok > 0) { + azx_dev->irq_pending = 0; + spin_unlock(&chip->reg_lock); + snd_pcm_period_elapsed(azx_dev->substream); + spin_lock(&chip->reg_lock); + } else if (ok < 0) { + pending = 0; /* too early */ + } else + pending++; + } + spin_unlock_irq(&chip->reg_lock); + if (!pending) + return; + msleep(1); + } +} +EXPORT_SYMBOL_GPL(azx_irq_pending_work); + +/* clear irq_pending flags and assure no on-going workq */ +void azx_clear_irq_pending(struct azx *chip) +{ + int i; + + spin_lock_irq(&chip->reg_lock); + for (i = 0; i < chip->num_streams; i++) + chip->azx_dev[i].irq_pending = 0; + spin_unlock_irq(&chip->reg_lock); +} +EXPORT_SYMBOL_GPL(azx_clear_irq_pending); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Common HDA driver funcitons"); diff --git a/sound/pci/hda/hda_shared.h b/sound/pci/hda/hda_shared.h index 4a35b46..8eed8cb 100644 --- a/sound/pci/hda/hda_shared.h +++ b/sound/pci/hda/hda_shared.h @@ -23,7 +23,6 @@ /* PCM setup */ int azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec, struct hda_pcm *cpcm); -int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev); static inline struct azx_dev *get_azx_dev(struct snd_pcm_substream *substream) { return substream->runtime->private_data; @@ -51,11 +50,13 @@ void azx_free_stream_pages(struct azx *chip); int azx_send_cmd(struct hda_bus *bus, unsigned int val); unsigned int azx_get_response(struct hda_bus *bus, unsigned int addr); -void azx_update_rirb(struct azx *chip); /* Low level azx interface */ void azx_init_chip(struct azx *chip, int full_reset); void azx_stop_chip(struct azx *chip); void azx_enter_link_reset(struct azx *chip); +irqreturn_t azx_interrupt(int irq, void *dev_id); +void azx_irq_pending_work(struct work_struct *work); +void azx_clear_irq_pending(struct azx *chip); #endif /* __SOUND_HDA_SHARED_H */