Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6709325imu; Mon, 3 Dec 2018 01:17:27 -0800 (PST) X-Google-Smtp-Source: AFSGD/UmbFxQCE501Q8P2kLmRxjE8mGupUJCbgGeyNJIOE5wzrU6LTwhbdr/2+IhyLiodtT5uNRS X-Received: by 2002:a65:48c4:: with SMTP id o4mr12165880pgs.371.1543828646950; Mon, 03 Dec 2018 01:17:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543828646; cv=none; d=google.com; s=arc-20160816; b=Paqptmfd0dF4CL4/B8IeZ3H/Azi5kKxW7k7FGnTsYVEjOETQTwlSwqfCrvXnHS4I1j osrICcs0oQrxG6iRReCi2VSiKtKWkCsTcBmWkYkrckdnZTrMOoOQTtLxqoXfktWp1uQH 87V+I+MTd0QdN357ZEiSw5oNnnOIUaAgPxuAnrXCn9RLSUgX5+PJhwDDgk97MInJJP72 pIqWQqvkdfcC9fpZ0X+i0n/Xy+2zC9yYDLS1AMDBU2LgbT3Z3hYRRpZJPOBTcdh/UKSe xZIoV32d9RtTYMvYzj8YlXoDz/WmLTrESQnJOejtT3TwVW+0LxksybfMWPU+K0/5Nhze SnyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=7j+bgClSRVIAxROozQ4TIFUvyEMWKzMV52jPu2wFtcs=; b=ES08/d2VZqNCDwFvdIN7tUG6CebgpTrv4h/uwjh0lddzTxAIIViHLfRtK7r2mYypFj nK5b902mLyNX+nEKyOU/+W75ZPyDryUpLjWOkEVRxL7THH7c+UudjZjeNADJ1MTVx6cc 5gcrxZswol5D0NmDYtboMcaCQpCS/kJaoNVCKyd4e3F+BKik4OOosghelX1Z0Fq3ZZ0t lv6F4ACtNFUFrNaSsTQPwvSZSyy6cuJEln6cRw7nD2+m86l6jNi8CaUbfVTgS5ryJ9gO O6cFZH25n5FjRGYMyUW3tdZimp5IZQBHHA6ruYf2F9Lg2cPttaAtjgOqmZ0d6vVDcLXf WkKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7si13341782pfg.245.2018.12.03.01.17.11; Mon, 03 Dec 2018 01:17:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726029AbeLCJPb (ORCPT + 99 others); Mon, 3 Dec 2018 04:15:31 -0500 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]:51982 "EHLO lb1-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbeLCJPb (ORCPT ); Mon, 3 Dec 2018 04:15:31 -0500 Received: from [192.168.2.10] ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id TkJugpPYbfGaRTkJxghtet; Mon, 03 Dec 2018 10:15:19 +0100 Subject: Re: [PATCH v4] media: vivid: Improve timestamping To: Arnd Bergmann , gfmandaji@gmail.com Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Linux Kernel Mailing List , lkcamp@lists.libreplanetbr.org References: <20181202134538.GA18886@gfm-note> From: Hans Verkuil Message-ID: Date: Mon, 3 Dec 2018 10:15:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfGXTXu6KYqZC9C9nihSokyyPEsCttLnsNEtd/vtV6PeCX06GwTtDk4bEAlExgTEgy3et89k869cplOpquKScnDfO/bxqNsI9Dyj5xFaeECn53jgT6zYg 9GVaBGCkI6lKu3x7Zk2q2VfLYco5HIZRqz4cmQMmKN62WpenWYZ19a3RP1VBRMz/0M/XZ/OT0BFrivCLnDe0Dspr8xZMNEi5zqhYk7aDTyv8Ud9RY9KkdwCR BWrF7xoR43ZwaIf8+N8aOnoA5AEpDqFpJGMFzO6IutDJ2IMy9YxxyhUid0kKmxd0lR+0fm+/f8FZtMADsFJEUDhZe/3Q2xJ6KIwVB3I/YVeV8J91+wr+Rxp1 NG1T1yhr Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/02/2018 09:43 PM, Arnd Bergmann wrote: > On Sun, Dec 2, 2018 at 2:47 PM Gabriel Francisco Mandaji > wrote: > >> @@ -667,10 +653,28 @@ static void vivid_overlay(struct vivid_dev *dev, struct vivid_buffer *buf) >> } >> } >> >> +static void vivid_cap_update_frame_period(struct vivid_dev *dev) >> +{ >> + u64 f_period; >> + >> + f_period = (u64)dev->timeperframe_vid_cap.numerator * 1000000000; >> + do_div(f_period, dev->timeperframe_vid_cap.denominator); >> + if (dev->field_cap == V4L2_FIELD_ALTERNATE) >> + do_div(f_period, 2); >> + /* >> + * If "End of Frame", then offset the exposure time by 0.9 >> + * of the frame period. >> + */ >> + dev->cap_frame_eof_offset = f_period * 9; >> + do_div(dev->cap_frame_eof_offset, 10); >> + dev->cap_frame_period = f_period; >> +} > > Doing two or three do_div() operations is going to make this rather > expensive on 32-bit architectures, and it looks like this happens for > each frame? > > Since each one is a multiplication followed by a division, could this > be changed to using a different factor followed by a bit shift? The division by 2 can obviously be replaced by a shift, and the 'End of Frame' calculation can be simplified as well by multiplying by 7 and dividing by 8 (again a simple shift): this equals 0.875 which is close enough to 0.9 (so update the comment as well). It's all a bit overkill since this function isn't called very often, but these are easy changes to make. Regards, Hans