From patchwork Wed Aug 3 18:03:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 9261715 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 6B7B160754 for ; Wed, 3 Aug 2016 18:06:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 609A5281F9 for ; Wed, 3 Aug 2016 18:06:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5588028236; Wed, 3 Aug 2016 18:06:04 +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=unavailable 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 DDFF4281F9 for ; Wed, 3 Aug 2016 18:06:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932653AbcHCSFu (ORCPT ); Wed, 3 Aug 2016 14:05:50 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33616 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932380AbcHCSEI (ORCPT ); Wed, 3 Aug 2016 14:04:08 -0400 Received: by mail-pf0-f195.google.com with SMTP id i6so15066232pfe.0; Wed, 03 Aug 2016 11:04:07 -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=YRoe9DpJ0iyC6cY9QznNxJhRRj5f1mlv7pC37abuRXw=; b=0qvQleETh1IqwGhHInO+x7XlkBQtJkn809mHtq9dxOJi6sAckL1kQqhsUCPB+YntdS wsG1cuf/XbJS5H4amlh6BqvXjyq3bVCK6wjqvCMnF1ENm2Iy9rm1OV1mQRZWLWgaq/xQ R7styspcWCrZJApHEkKVdCAYk0dN5rp9jENKw9dgCut6GgYyqotfAIqQaVh9S0nwGtmk G0/22xJiwTWb4D+sm3EeS3Hgp781dC9LhXY+6rC/xM2eicHUeM30zA+KRCt+g53nliKE jtWsRwP7yX16GdpXwaLv9rGS+NulcsZdS5BX2N6A/nEUBC3N1A9wxcy7wBfXLKPsHRCi UJaA== 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=YRoe9DpJ0iyC6cY9QznNxJhRRj5f1mlv7pC37abuRXw=; b=AImsIfMp9G/FqlrfBBPQQz00K39R03Jj4d7fSjw2UAaKk4Y7++K5pqTZ1JzkWVVlLj DSBO/Dxz+BS+vOdXDzbZP1FwPy89RsEw+BkVg9DRPGf8a5A3GJxyCY/sG4SwDfKidbgh IQhFWWW9ttBzAMZkSsggIqx7me+5+bTTYvyQmy3e0tp1wwaiPN2k3PSKSAVDMpqrxTT1 wtD7DUexXKh45csbB0cJeAyWHNpD0GFbq9P22wZVeF3el7SLuhbZEVFFEzbZjgxU8+Ko GQl9NkmIi8tej1bryqOP7bVGCCos3L82Uz7ABed4rJrqL6gtFzfhfWnCVQbHyOQAlPAD 8tWQ== X-Gm-Message-State: AEkoousi7WUD5uDPDxwNXYMe8cnwBm/HLcT3ur67Mg+5TdpAlM0bQ0x7eJd106go62Ba0g== X-Received: by 10.98.14.72 with SMTP id w69mr118644782pfi.119.1470247447483; Wed, 03 Aug 2016 11:04:07 -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 w64sm14219878pfb.93.2016.08.03.11.04.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Aug 2016 11:04:06 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: lars@metafoo.de Cc: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Steve Longerbeam Subject: [PATCH v4 8/8] media: adv7180: enable lock/unlock interrupts Date: Wed, 3 Aug 2016 11:03:50 -0700 Message-Id: <1470247430-11168-9-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1470247430-11168-1-git-send-email-steve_longerbeam@mentor.com> References: <1470247430-11168-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 --- v4: no changes v3: no changes 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 abdc519..d017b05 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -874,19 +874,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); @@ -1287,7 +1297,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;