From patchwork Wed Jul 20 00:03:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 9238527 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 8BC25602F0 for ; Wed, 20 Jul 2016 00:04:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C6452624D for ; Wed, 20 Jul 2016 00:04:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F6822793D; Wed, 20 Jul 2016 00:04:55 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00ABF2624D for ; Wed, 20 Jul 2016 00:04:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752777AbcGTAEM (ORCPT ); Tue, 19 Jul 2016 20:04:12 -0400 Received: from mail-pa0-f66.google.com ([209.85.220.66]:33621 "EHLO mail-pa0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752689AbcGTAEH (ORCPT ); Tue, 19 Jul 2016 20:04:07 -0400 Received: by mail-pa0-f66.google.com with SMTP id q2so2160473pap.0; Tue, 19 Jul 2016 17:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=W7X1I/YdpnSqJyLMnAPqzOSurcwO8iLZOfd2L+LlPdk=; b=Ypdqsh5xmGuLYb2Ie8X5oT8Kc7+rWDBghKRh3p+vZoEvHHbbFezqCWVJHAefUtdAYz lwIHXh9dEgdDvNfrirqRF/mD196Qw44l5ngPTakT9ZLZjUlItFyEbZKkV6UdD03xx/um HOBlf77pRtCU3r6ZxwKJa7pmJT1SKHcdBZOSl1kxQbaq5fEX2Ct/ub4QhXxFPhZgtrkt fs7O5h1HtL4BWfL8BNU6sNUD8R9TSZcc/J7xV7/hTIyNmbX1QINGSS7254kathh4TkdG 2Ls5v5X0R0QVpdeEEGsKHTUcqPFkT0IvmStW0fcZ0hOAjxBFtFQKvmF0V7zSyNy8aGok 8z3A== 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=W7X1I/YdpnSqJyLMnAPqzOSurcwO8iLZOfd2L+LlPdk=; b=JN5DHG4UdVGGuTUrSw83UwL5vbtgu9ist2cLO2CV2eEAZA5QsG/KTolxfr5k2+pqi8 W0VEI9Azvh5WjwT0TSf1n/vX1bT8Sx6MgBBCUiOKoWYvtw1ACQ03ystycTEVKrqMCXDM lrufYDGzYjoMtNvn0gCGIe+2GqSc4zwwRPYG7zM0RThJEbipjJOGpUviAhXmY9c7k+cm M304lYvCl/OVCcBHs18cDGt2k3gCScHC14/Gw74cDRFzu0J4nyE/eyg7tTkk8VPJTKbD c76p7DPD9sylBBgNn29BqFX2pZtb22zI1UrwiyoB1VBY2RcMgIXsb7PdYdUmLb565VjQ P3Xg== X-Gm-Message-State: ALyK8tLb7JLSB8IPmGN7d207jYZwHx6cpI6wCWIMhD7CEltUfgcvHd4J6UGQ2v9VKy7IAA== X-Received: by 10.66.162.4 with SMTP id xw4mr37719232pab.97.1468973046207; Tue, 19 Jul 2016 17:04:06 -0700 (PDT) Received: from mothership.sklembedded.com (c-73-241-2-21.hsd1.ca.comcast.net. [73.241.2.21]) by smtp.googlemail.com with ESMTPSA id ty6sm7107742pac.18.2016.07.19.17.04.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Jul 2016 17:04:05 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: lars@metafoo.de Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Steve Longerbeam Subject: [PATCH v2 09/10] media: adv7180: enable lock/unlock interrupts Date: Tue, 19 Jul 2016 17:03:36 -0700 Message-Id: <1468973017-17647-10-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468973017-17647-1-git-send-email-steve_longerbeam@mentor.com> References: <1467846004-12731-1-git-send-email-steve_longerbeam@mentor.com> <1468973017-17647-1-git-send-email-steve_longerbeam@mentor.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Enable the SD lock/unlock interrupts and send V4L2_EVENT_SRC_CH_LOCK_STATUS in the interrupt handler on a detected lock/unlock. Signed-off-by: Steve Longerbeam --- v2: - last version of this patch was based on the old reverted autodetect code. This version now only enables the interrupt and sends the event in the interrupt handler. --- drivers/media/i2c/adv7180.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index 0f0568c..61f2140 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -876,19 +876,29 @@ static const struct v4l2_subdev_ops adv7180_ops = { static irqreturn_t adv7180_irq(int irq, void *devid) { struct adv7180_state *state = devid; - u8 isr3; + u8 isr1, isr3; mutex_lock(&state->mutex); + isr1 = adv7180_read(state, ADV7180_REG_ISR1); isr3 = adv7180_read(state, ADV7180_REG_ISR3); /* clear */ + adv7180_write(state, ADV7180_REG_ICR1, isr1); adv7180_write(state, ADV7180_REG_ICR3, isr3); - if (isr3 & ADV7180_IRQ3_AD_CHANGE) { - static const struct v4l2_event src_ch = { + if ((isr3 & ADV7180_IRQ3_AD_CHANGE) || + (isr1 & (ADV7180_IRQ1_LOCK | ADV7180_IRQ1_UNLOCK))) { + static struct v4l2_event src_ch = { .type = V4L2_EVENT_SOURCE_CHANGE, - .u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION, }; + if (isr3 & ADV7180_IRQ3_AD_CHANGE) + src_ch.u.src_change.changes |= + V4L2_EVENT_SRC_CH_RESOLUTION; + + if (isr1 & (ADV7180_IRQ1_LOCK | ADV7180_IRQ1_UNLOCK)) + src_ch.u.src_change.changes |= + V4L2_EVENT_SRC_CH_LOCK_STATUS; + v4l2_subdev_notify_event(&state->sd, &src_ch); } mutex_unlock(&state->mutex); @@ -1289,7 +1299,9 @@ static int init_device(struct adv7180_state *state) if (ret < 0) goto out_unlock; - ret = adv7180_write(state, ADV7180_REG_IMR1, 0); + /* enable lock/unlock interrupts */ + ret = adv7180_write(state, ADV7180_REG_IMR1, + ADV7180_IRQ1_LOCK | ADV7180_IRQ1_UNLOCK); if (ret < 0) goto out_unlock;