From patchwork Fri Feb 28 23:41:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Reid X-Patchwork-Id: 3745381 X-Patchwork-Delegate: tiwai@suse.de 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 654BABF13A for ; Fri, 28 Feb 2014 23:46:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8B30C2024D for ; Fri, 28 Feb 2014 23:46:04 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 4E1A5202E9 for ; Fri, 28 Feb 2014 23:46:03 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5DE57265D72; Sat, 1 Mar 2014 00:46:02 +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,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id DF8D2265A28; Sat, 1 Mar 2014 00:43:08 +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 705FD2659A1; Sat, 1 Mar 2014 00:43:06 +0100 (CET) Received: from mail-ob0-f201.google.com (mail-ob0-f201.google.com [209.85.214.201]) by alsa0.perex.cz (Postfix) with ESMTP id 6C1EA2659AA for ; Sat, 1 Mar 2014 00:42:52 +0100 (CET) Received: by mail-ob0-f201.google.com with SMTP id gq1so921999obb.0 for ; Fri, 28 Feb 2014 15:42:51 -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=GlaxCCOcZVqxjMEmvfsptgMR1L0CJgb9ZG1MN2sgrnY=; b=LTrBhMXr/xIJFPgD4zshfaeMqzbLhXZ6bB35/aJlPHzejBZt833yzKgOFpvnhO5IxT 4JFg1CQ60GwyqLewp3xCYQYeyniTOnhNios2gP2ocMzMk/vkZgNAsQGfXWZYfoPs0bbA l+YfjWVvYOJ8acFR1OWQIUHu94o/2b+j2Y8pDw7ayHgVJM9TRdKWqSaeA6SSCMNwe7jT f6EVkdbE+aTApMbJrb0Oxwaw1o6KTuFPqZ88jZWMvc2Jb3a8n1VM1hTzKzz48keh1ZB2 KjX5AGS1Kyy/Iki1HWZyaAl94p2Z87jzF3DPMqCjotSVAW3h87J5sD+eFTshyIQ/6O6f QcfA== X-Gm-Message-State: ALoCoQkO4DbrZvFhg+pLd5oVZPrdJ/vc/usjfPsKEexvrMoIo5E24lAnQBWA3E0xMRyNY5cb7D2dewO4b1TJqsVdLc1ZUrU7bR8I2/S28hY04iq55KNVB9H29u3BNPvLYcwAi/GV0kRJvHL/7JtU9S6/eZjCPukTWIyVq44q6tHKridL7VSgT42WCZ2T9w/Mt6Pz9sh3LnteK5Ui2A0UzfH7GSF3E5Qn0a7E6kXkCXqLYq1/yKL55wI= X-Received: by 10.50.56.39 with SMTP id x7mr2997145igp.6.1393630971598; Fri, 28 Feb 2014 15:42:51 -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 x29si545911yha.0.2014.02.28.15.42.51 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Feb 2014 15:42:51 -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 6D07B31C1E3; Fri, 28 Feb 2014 15:42:51 -0800 (PST) Received: by hojo20.mtv.corp.google.com (Postfix, from userid 123195) id 48862181DD6; Fri, 28 Feb 2014 15:42:51 -0800 (PST) From: Dylan Reid To: alsa-devel@alsa-project.org Date: Fri, 28 Feb 2014 15:41:28 -0800 Message-Id: <1393630893-29010-18-git-send-email-dgreid@chromium.org> X-Mailer: git-send-email 1.8.1.3.605.g02339dd In-Reply-To: <1393630893-29010-1-git-send-email-dgreid@chromium.org> References: <1393630893-29010-1-git-send-email-dgreid@chromium.org> Cc: tiwai@suse.de, Dylan Reid , swarren@wwwdotorg.org Subject: [alsa-devel] [RFCv2 17/22] ALSA: hda - Add position_check op 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 op will be used by hda_intel to do the position check. Takashi wisely suggested adding this before moving the interrupt handler to common HDA code. Having this callback prevents the need to move the hda_intel specific delayed interrupt handling with the irq. Signed-off-by: Dylan Reid --- sound/pci/hda/hda_intel.c | 30 +++++++++++++++++++++--------- sound/pci/hda/hda_priv.h | 2 ++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 4f693ef..53e4b40 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -416,6 +416,23 @@ static void azx_init_pci(struct azx *chip) static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev); +/* called from IRQ */ +static int azx_position_check(struct azx *chip, struct azx_dev *azx_dev) +{ + int ok; + + ok = azx_position_ok(chip, azx_dev); + if (ok == 1) { + azx_dev->irq_pending = 0; + return ok; + } 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); + } + return 0; +} + /* * interrupt handler */ @@ -425,7 +442,7 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id) struct azx_dev *azx_dev; u32 status; u8 sd_status; - int i, ok; + int i; #ifdef CONFIG_PM_RUNTIME if (chip->driver_caps & AZX_DCAPS_PM_RUNTIME) @@ -455,17 +472,11 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id) !(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; + if (!chip->ops->position_check || + chip->ops->position_check(chip, azx_dev)) { 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); } } } @@ -1821,6 +1832,7 @@ static const struct hda_controller_ops pci_hda_ops = { .substream_alloc_pages = substream_alloc_pages, .substream_free_pages = substream_free_pages, .pcm_mmap_prepare = pcm_mmap_prepare, + .position_check = azx_position_check, }; static int azx_probe(struct pci_dev *pci, diff --git a/sound/pci/hda/hda_priv.h b/sound/pci/hda/hda_priv.h index edbe2eb..bf3cb33 100644 --- a/sound/pci/hda/hda_priv.h +++ b/sound/pci/hda/hda_priv.h @@ -311,6 +311,8 @@ struct hda_controller_ops { struct snd_pcm_substream *substream); void (*pcm_mmap_prepare)(struct snd_pcm_substream *substream, struct vm_area_struct *area); + /* Check if current position is acceptable */ + int (*position_check)(struct azx *chip, struct azx_dev *azx_dev); }; struct azx_pcm {