From patchwork Wed Nov 11 11:58:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 7595131 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E9C1F9F2E9 for ; Wed, 11 Nov 2015 11:59:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 28AC820631 for ; Wed, 11 Nov 2015 11:59:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3DA61205EA for ; Wed, 11 Nov 2015 11:59:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752398AbbKKL6l (ORCPT ); Wed, 11 Nov 2015 06:58:41 -0500 Received: from mail-lb0-f175.google.com ([209.85.217.175]:36231 "EHLO mail-lb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752368AbbKKL6j (ORCPT ); Wed, 11 Nov 2015 06:58:39 -0500 Received: by lbblt2 with SMTP id lt2so15497236lbb.3; Wed, 11 Nov 2015 03:58:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=BsaLCh52JozWeFGH4vDz3l+hxgBOm3TOjQgm2SW6AQU=; b=n3qCjJ7aMQKku5hUYNHUIYVu0VLYqAoArmLm3Qk8K21MhsrynEgzW0HPYpqK6j7kaS Hksfhblp6pt8tnkyn6/bOHEPURU6oGvkDaLdpmyzSLx0DdJol2p6G+2vi3URYkTLZ1JI ZjSe8gazcPf30wGkkApxkLP5KLwscBwWCEzREyxO/ifFfy6U/WSOGuGv9eoORoqyGDem jhliaWD/dHuz2G0VSoQjtDMGF32nSYR+9kwNDn0/zUysfnbw7XgjuCxIyLv8sgbQXaA/ mdOcl/0+lOJmv9TZEFncQbp1evkQWCoeBUWvtczBCSeb6b7zzOkHG9M0Bibz1D001bdH erfw== X-Received: by 10.112.53.167 with SMTP id c7mr4169570lbp.20.1447243118243; Wed, 11 Nov 2015 03:58:38 -0800 (PST) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id jj4sm1402986lbc.14.2015.11.11.03.58.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Nov 2015 03:58:35 -0800 (PST) From: Ricardo Ribalda Delgado To: Hans Verkuil , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Dimitrios Katsaros Cc: Ricardo Ribalda Delgado Subject: [PATCH] v4l2-core/v4l2-ctrls: Filter NOOP CH_RANGE events Date: Wed, 11 Nov 2015 12:58:34 +0100 Message-Id: <1447243114-1011-1-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.6.2 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If modify_range is called but no range is changed, do not send the CH_RANGE event. Reported-by: Dimitrios Katsaros Signed-off-by: Ricardo Ribalda Delgado --- drivers/media/v4l2-core/v4l2-ctrls.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 4a1d9fdd14bb..f9c0e8150bd1 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -3300,7 +3300,8 @@ EXPORT_SYMBOL(v4l2_ctrl_notify); int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, s64 min, s64 max, u64 step, s64 def) { - bool changed; + bool value_changed; + bool range_changed = false; int ret; lockdep_assert_held(ctrl->handler->lock); @@ -3324,10 +3325,14 @@ int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, default: return -EINVAL; } - ctrl->minimum = min; - ctrl->maximum = max; - ctrl->step = step; - ctrl->default_value = def; + if ((ctrl->minimum != min) || (ctrl->maximum != max) || + (ctrl->step != step) || ctrl->default_value != def) { + range_changed = true; + ctrl->minimum = min; + ctrl->maximum = max; + ctrl->step = step; + ctrl->default_value = def; + } cur_to_new(ctrl); if (validate_new(ctrl, ctrl->p_new)) { if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) @@ -3337,12 +3342,12 @@ int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, } if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) - changed = *ctrl->p_new.p_s64 != *ctrl->p_cur.p_s64; + value_changed = *ctrl->p_new.p_s64 != *ctrl->p_cur.p_s64; else - changed = *ctrl->p_new.p_s32 != *ctrl->p_cur.p_s32; - if (changed) + value_changed = *ctrl->p_new.p_s32 != *ctrl->p_cur.p_s32; + if (value_changed) ret = set_ctrl(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); - else + else if (range_changed) send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); return ret; }