From patchwork Sat Oct 20 14:26:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 10650549 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0649590 for ; Sat, 20 Oct 2018 14:26:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEAB72862C for ; Sat, 20 Oct 2018 14:26:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D359528632; Sat, 20 Oct 2018 14:26:53 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 7D98A2862C for ; Sat, 20 Oct 2018 14:26:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727470AbeJTWhc (ORCPT ); Sat, 20 Oct 2018 18:37:32 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44148 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727373AbeJTWhb (ORCPT ); Sat, 20 Oct 2018 18:37:31 -0400 Received: by mail-pg1-f195.google.com with SMTP id w3-v6so1475308pgs.11 for ; Sat, 20 Oct 2018 07:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OmqeoU0XuCmw5YovbS2vtReQ4AfstqagcRGgJk+aRVQ=; b=EWUuxYWihwNq1bFfZYjv7ez1XgX57rHm9NEyEF21ocrDo7tV0CyUd7R25UYwyMmbcl iFv60MkNeDI4MYeHWsQfDrB1+IsBC1oj/KM6toy+DXp0dOE845ic8cMr6Jd1kkdOPfvj U3TlADgCgPoaj4RN1km4UKrK5OYmu0dnrRG6RrCkGBOtSbd77fOqP6TaJJh664Du7agn mNF/SBwZeyqVbIKkqj+RXHMsuuBRP6Qo8Op79NwDhEmQaCKPOS3VkxCWTI79BGAUMgvV sJKlab8WNcu38eoTnUnKh1nk/1Ul9D4daNl0YzFFlbQ232gRZfTEQ9RuNgvSsg6zLCCP jt6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OmqeoU0XuCmw5YovbS2vtReQ4AfstqagcRGgJk+aRVQ=; b=qTrd9R4xNUNIq85OjkzpvSWuJZTdV4HYbg1NyoNfAD+HjQrZUQe0o0xRTaMGQUdAIB ppvpX6afuwCy5E52qU4XxZZE5aKVqMdoIvFGwoabSBLcjFsX0wf5a9lICN3Ld+1uVXGM 47S4WspFTenAXQv60JRFi8MWmovzbi4GJls+hor+QzF9eXASkYdLugx09e7jda9kr2uz RZwzUyRjONreUWNeBb7lFn2aiDQo1LiQYbmiEU7AmL2rGFMesnCq8WYl4XEd/e2iudvT YexFPg0Eafa3AEkMzwfdBcqZuTCpHdygGZGDnY3L2nfoLRcgsdT4MhKMAUzcLNpsebxz lx3w== X-Gm-Message-State: ABuFfoh7dfBIGNzK9j2P5J9i84VTDyqVSNZqmBlY5+9tsOq6B5P3AEdy QMMIFQ2UgdWwp5tYVRuGEGA5WmQT X-Google-Smtp-Source: ACcGV62L+1Hr3bsYJJoocV+kgwPzx21HXQRYwbt3mjJCP0nzT6Z4Swd/oh3rpbsLpR29nL6hPJPegw== X-Received: by 2002:a63:2447:: with SMTP id k68-v6mr7135948pgk.156.1540045611542; Sat, 20 Oct 2018 07:26:51 -0700 (PDT) Received: from mita-MS-7A45.lan ([240f:34:212d:1:28d8:ef69:4040:67dc]) by smtp.gmail.com with ESMTPSA id q68-v6sm28624799pfb.160.2018.10.20.07.26.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 20 Oct 2018 07:26:50 -0700 (PDT) From: Akinobu Mita To: linux-media@vger.kernel.org Cc: Akinobu Mita , Matt Ranostay , Sakari Ailus , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH v4 4/6] media: vivid: use V4L2_FRACT_COMPARE Date: Sat, 20 Oct 2018 23:26:26 +0900 Message-Id: <1540045588-9091-5-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540045588-9091-1-git-send-email-akinobu.mita@gmail.com> References: <1540045588-9091-1-git-send-email-akinobu.mita@gmail.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 Now the equivalent of FRACT_CMP() is added in v4l2 common internal API header. Cc: Matt Ranostay Cc: Sakari Ailus Cc: Hans Verkuil Cc: Mauro Carvalho Chehab Acked-by: Sakari Ailus Signed-off-by: Akinobu Mita --- * v4 - No changes from v3 drivers/media/platform/vivid/vivid-vid-cap.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c index 1599159..f19c701 100644 --- a/drivers/media/platform/vivid/vivid-vid-cap.c +++ b/drivers/media/platform/vivid/vivid-vid-cap.c @@ -1824,9 +1824,6 @@ int vivid_vid_cap_g_parm(struct file *file, void *priv, return 0; } -#define FRACT_CMP(a, OP, b) \ - ((u64)(a).numerator * (b).denominator OP (u64)(b).numerator * (a).denominator) - int vivid_vid_cap_s_parm(struct file *file, void *priv, struct v4l2_streamparm *parm) { @@ -1847,14 +1844,14 @@ int vivid_vid_cap_s_parm(struct file *file, void *priv, if (tpf.denominator == 0) tpf = webcam_intervals[ival_sz - 1]; for (i = 0; i < ival_sz; i++) - if (FRACT_CMP(tpf, >=, webcam_intervals[i])) + if (V4L2_FRACT_COMPARE(tpf, >=, webcam_intervals[i])) break; if (i == ival_sz) i = ival_sz - 1; dev->webcam_ival_idx = i; tpf = webcam_intervals[dev->webcam_ival_idx]; - tpf = FRACT_CMP(tpf, <, tpf_min) ? tpf_min : tpf; - tpf = FRACT_CMP(tpf, >, tpf_max) ? tpf_max : tpf; + tpf = V4L2_FRACT_COMPARE(tpf, <, tpf_min) ? tpf_min : tpf; + tpf = V4L2_FRACT_COMPARE(tpf, >, tpf_max) ? tpf_max : tpf; /* resync the thread's timings */ dev->cap_seq_resync = true;