From patchwork Sun Sep 23 16:34:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 10611821 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 8CF83174A for ; Sun, 23 Sep 2018 16:35:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A5B22925E for ; Sun, 23 Sep 2018 16:35:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6EE4D292ED; Sun, 23 Sep 2018 16:35:23 +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 1951D2925E for ; Sun, 23 Sep 2018 16:35:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726497AbeIWWdY (ORCPT ); Sun, 23 Sep 2018 18:33:24 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:32808 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726230AbeIWWdY (ORCPT ); Sun, 23 Sep 2018 18:33:24 -0400 Received: by mail-pg1-f193.google.com with SMTP id y18-v6so4824286pge.0 for ; Sun, 23 Sep 2018 09:35:20 -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=P7lNpBVo1pJ7U/uMVCSCu8fyt5PmBEeY11dXCnF7D9E=; b=tjKAphl6yg0incNQ/iMcUeD3JzkUzOaxjprhGIq6kRJpQQOzWF+A4xLPbwEUtKkx4U 6tHDgSUI6G3nAl1xu50wRhQqcE7jFgsoLS8WHrZuZpYiDhdrX4Jzxv4MzIVzrmlo14H7 W0G9H3xWKW2MEHRUma0I0jFWkQjTAnpDJNDdhxrlMBv5KZA6s67lXEVYQjbSUF43VtmQ dumsyj0KcnS2EpTq8rur0Dnj5qzc0GhQNlugq1qwM208HIrvCxuX/0Kes2YEeSMAx8cm IaYEDObj9MaRCYtN6j+Kx7HoungwdKTFc+NtJuLvPFd8PctO4d/iXxdukD75DHnceble 7EOw== 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=P7lNpBVo1pJ7U/uMVCSCu8fyt5PmBEeY11dXCnF7D9E=; b=PtrmVq4xX9L1/s7rh8u+jMCksoZkhI2v7O6Lu1p2jBkf1J/E/5fSlOf+uyQIVja0yd hlRXdSrpEJaLm4O3xUZQ+0EHLjk5+R9RTMvYQpCSU6WQdNYW6caRloYFY5u9FaZf67yp 5guMNNZRvW4Fwi8i2Q8S6IBxUUxebrLKfnfAN8Cdkbo3VXnQw4SCmunjyByLnlxA8rq9 GGQsg6fL3ECNTL3JMMQ2g74mGU+iyhdadR6jiSUHIU9msv8p5EoP/bOzC2OtxeeMKsz4 mAA9BODQJcGsk8HvJC7oF5WL29VA8p3dy63+h+8piOihrXWMc20c5N8SBfGyHMhepzPB E+hg== X-Gm-Message-State: APzg51C61cG6J0SlwAG3Fo4s3CUWEWLlTihOkDqr/J5ALuvzVCfwtfSp K6aQul3VPceINxpfJ574SDlNqI4P X-Google-Smtp-Source: ANB0Vda0iuirTm2WRf58IYB8495uoVKkqBCluoU0Z5dcKImcLsLibde27rmDWPmY04Ag9chzeh0JlA== X-Received: by 2002:a62:435c:: with SMTP id q89-v6mr7032640pfa.135.1537720520299; Sun, 23 Sep 2018 09:35:20 -0700 (PDT) Received: from mita-MS-7A45.lan ([240f:34:212d:1:9f:aa8:eeac:60f7]) by smtp.gmail.com with ESMTPSA id d129-v6sm18286250pga.69.2018.09.23.09.35.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Sep 2018 09:35:19 -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 v2 4/6] media: vivid: use V4L2_FRACT_COMPARE Date: Mon, 24 Sep 2018 01:34:50 +0900 Message-Id: <1537720492-31201-5-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537720492-31201-1-git-send-email-akinobu.mita@gmail.com> References: <1537720492-31201-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 Signed-off-by: Akinobu Mita --- * v2 - New patch 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;