From patchwork Wed Jul 6 23:00:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 9217389 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 9A46D60467 for ; Wed, 6 Jul 2016 23:13:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B95228524 for ; Wed, 6 Jul 2016 23:13:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FF8D28527; Wed, 6 Jul 2016 23:13:34 +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 EF6C828524 for ; Wed, 6 Jul 2016 23:13:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932487AbcGFXNc (ORCPT ); Wed, 6 Jul 2016 19:13:32 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33555 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932423AbcGFXNb (ORCPT ); Wed, 6 Jul 2016 19:13:31 -0400 Received: by mail-pf0-f194.google.com with SMTP id c74so114360pfb.0 for ; Wed, 06 Jul 2016 16:13:31 -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=vzmyqzvkrBJyyKb3Zh2b49PqBDGquBSfBlyTqWUqeeU=; b=xr7i1bvx3ZCnOxYTr710uIyEHdzN2LuI+LLnkk+gNJCdTtDE7alFQNlWnAXuecWqdT bWIbZh8Xf0MEfCCo80xYiCiLSDkdziZ+lL7Zy6HqQGD/+RS8nftG3ChPezG/Ef388ykM Pz9+5tXJ0uCzIjj3wGe6tcfZYs5vtQcAWC7tQI8o8kh/X3X/HO3mX9CEowM4sN9OfbCl 6T0NHvIbsDSuWY4llXGyUeWR9OK4Dm2TF7yZsyEULFJoBvxTqDRSB+2p0TUVQYCw1OQP a1pfIM5pZ0Lke8mCIB0koqndpPwLGvZI2u173d6a8LRnyMcnA63oIbYqEpFshLzr+nCU J2xQ== 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=vzmyqzvkrBJyyKb3Zh2b49PqBDGquBSfBlyTqWUqeeU=; b=hhqw1DyxH0C7im3gHGivC722sUThHLJVKv/DntVn32f/XoXRIjW2bxuAAhLjB8kv8V qKjjTaS6kLZMHIvCT5Sghm8QcsYeupnuZVc3ZbihHlARTOutTaMrFkV59/gBDYO40fW/ DJn8hFXiEalM+CdCMUZn4L78oFpvZQ5WuvAaHpXmGcjYbdlkqWADYSFVl5VPqQvYpORk lCTW5rclLnYEDvZwRqrXGvpTVwV35n2wEcVNtk3s7F9mmPYe88Q9TrLyUylbLG9pOul5 2EfecgrSJ16PuBLyd7cR/xfCeZLELOTWsQIunmcGbc7p9nSLVJlZEqZG0QGT9Rm/YjQT dAfQ== X-Gm-Message-State: ALyK8tLEZ9aQQkX2ujNZQOkDA006YuIHsAVXaGR32cfMHl4+eUfJ/ZNcaOH2SDTkary1Ow== X-Received: by 10.98.3.3 with SMTP id 3mr46751576pfd.8.1467846057392; Wed, 06 Jul 2016 16:00:57 -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 v126sm6915578pfb.60.2016.07.06.16.00.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Jul 2016 16:00:56 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH 08/11] adv7180: send V4L2_EVENT_SOURCE_CHANGE on std change Date: Wed, 6 Jul 2016 16:00:01 -0700 Message-Id: <1467846004-12731-9-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467846004-12731-1-git-send-email-steve_longerbeam@mentor.com> References: <1467846004-12731-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 Subscribe to the V4L2_EVENT_SOURCE_CHANGE event and send V4L2_EVENT_SRC_CH_RESOLUTION in the interrupt handler on a detected standard change. Signed-off-by: Steve Longerbeam Tested-by: Tim Harvey --- drivers/media/i2c/adv7180.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index 427695d..f76a0e7 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -824,6 +825,20 @@ static int adv7180_g_tvnorms(struct v4l2_subdev *sd, v4l2_std_id *norm) return 0; } +static int adv7180_subscribe_event(struct v4l2_subdev *sd, + struct v4l2_fh *fh, + struct v4l2_event_subscription *sub) +{ + switch (sub->type) { + case V4L2_EVENT_SOURCE_CHANGE: + return v4l2_src_change_event_subdev_subscribe(sd, fh, sub); + case V4L2_EVENT_CTRL: + return v4l2_ctrl_subdev_subscribe_event(sd, fh, sub); + default: + return -EINVAL; + } +} + static const struct v4l2_subdev_video_ops adv7180_video_ops = { .s_std = adv7180_s_std, .g_std = adv7180_g_std, @@ -838,6 +853,8 @@ static const struct v4l2_subdev_video_ops adv7180_video_ops = { static const struct v4l2_subdev_core_ops adv7180_core_ops = { .s_power = adv7180_s_power, + .subscribe_event = adv7180_subscribe_event, + .unsubscribe_event = v4l2_event_subdev_unsubscribe, }; static const struct v4l2_subdev_pad_ops adv7180_pad_ops = { @@ -862,8 +879,18 @@ static irqreturn_t adv7180_irq(int irq, void *devid) /* clear */ adv7180_write(state, ADV7180_REG_ICR3, isr3); - if (isr3 & ADV7180_IRQ3_AD_CHANGE && state->autodetect) - __adv7180_status(state, NULL, &state->curr_norm); + if (isr3 & ADV7180_IRQ3_AD_CHANGE) { + static const struct v4l2_event src_ch = { + .type = V4L2_EVENT_SOURCE_CHANGE, + .u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION, + }; + + v4l2_subdev_notify_event(&state->sd, &src_ch); + + if (state->autodetect) + __adv7180_status(state, NULL, &state->curr_norm); + } + mutex_unlock(&state->mutex); return IRQ_HANDLED; @@ -1403,7 +1430,7 @@ static int adv7180_probe(struct i2c_client *client, state->input = 0; sd = &state->sd; v4l2_i2c_subdev_init(sd, client, &adv7180_ops); - sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE; + sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; ret = adv7180_init_controls(state); if (ret)