From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7384CC04AB2 for ; Fri, 10 May 2019 16:25:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C95D216C4 for ; Fri, 10 May 2019 16:25:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Witk/hgU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727647AbfEJQZ3 (ORCPT ); Fri, 10 May 2019 12:25:29 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:39562 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727496AbfEJQZ3 (ORCPT ); Fri, 10 May 2019 12:25:29 -0400 Received: from [IPv6:2a02:c7f:1887:5d00:441c:7edf:7614:409b] (unknown [IPv6:2a02:c7f:1887:5d00:441c:7edf:7614:409b]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0F1E82DF; Fri, 10 May 2019 18:25:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1557505527; bh=Gj5pAB4saNBi9iWDk6JjMFXoNWlzw8tU5bUrF50NFuE=; h=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Witk/hgUi20PDDwUG/GBIp75GIlirfzzOhS/QvzPZDaJXvickM6xAamQJqLivtXd5 6iPAHX04MmKHTVfigqKPWzn4UCOkGbNLQqXtVjxa47lUru8chkUjCgBlY7FCTrRCqZ GU1Vp8jSCToE9JMlxc8gvbvOW8h5AvRscZJdJJlM= Reply-To: kieran.bingham@ideasonboard.com Subject: Re: [PATCH] media: i2c: adv748x: initialize bit 7 of csi_tx_top_reg_1f To: Michael Rodin , mchehab@kernel.org, linux-media@vger.kernel.org Cc: linux-kernel@vger.kernel.org, michael@rodin.online, =?UTF-8?Q?Niklas_S=c3=b6derlund?= , Linux-Renesas References: <1557502240-16274-1-git-send-email-mrodin@de.adit-jv.com> From: Kieran Bingham Openpgp: preference=signencrypt Autocrypt: addr=kieran.bingham@ideasonboard.com; keydata= mQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat V/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/SC rRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C potzWkXc1xmPzcQ1fvQMOfMwdS+4SNw4rY9f07Xb2K99rjMwZVDgESKIzhsDB5GY465sCsiQ cSAZRxqE49RTBq2+EQsbrQpIc8XiffAB8qexh5/QPzCmR4kJgCGeHIXBtgRj+nIkCJPZvZtf Kr2EAbc6tgg6DkAEHJb+1okosV09+0+TXywYvtEop/WUOWQ+zo+Y/OBd+8Ptgt1pDRyOBzL8 RXa8ZqRf0Mwg75D+dKntZeJHzPRJyrlfQokngAAs4PaFt6UfS+ypMAF37T6CeDArQC41V3ko lPn1yMsVD0p+6i3DPvA/GPIksDC4owjnzVX9kM8Zc5Cx+XoAN0w5Eqo4t6qEVbuettxx55gq 8K8FieAjgjMSxngo/HST8TpFeqI5nVeq0/lqtBRQKumuIqDg+Bkr4L1V/PSB6XgQcOdhtd36 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018z3ZLztFJKR3RD42VKVsrnNDKnoY0f4U0z7eJv2NeF8xHMuiU RCIzqxX1GVYaNkKTnb/Qja8hnYnkUzY1Lc+OtwiGmXTwYsPZjjAaDX35J/RSKAoy5wGo/YFA JxB1gWThL4kOTbsqqXj9GLcyOImkW0lJGGR3o/fV91Zh63S5TKnf2YGGGzxki+ADdxVQAm+Q sbsRB8KNNvVXBOVNwko86rQqF9drZuw= Organization: Ideas on Board Message-ID: <26e001a0-298f-e23b-9e46-98e62a8399c2@ideasonboard.com> Date: Fri, 10 May 2019 17:25:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1557502240-16274-1-git-send-email-mrodin@de.adit-jv.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Hi Michael, Thank you for the patch, Could the patch title be a bit better described? Perhaps: media: i2c: adv748x: Correct EAV F-bit handling On 10/05/2019 16:30, Michael Rodin wrote: > According to pages 188 and 193 of the "UG-747: ADV7481 Reference Manual" > [1], the bit 7 (FRAMENUMBER_INTERLACED) of the register csi_tx_top_reg_1f > "sets association of frame number in the FS and FE packets with the F bit > in the EAV/SAV codes". EAV/SAV codes are defined in [2]. > According to [2]: Could you detail where this reference is to help searching for it please? (it looks like Table 2, page 5) > F=0 for field 1 > F=1 for field 2 It would help to indent those lines to make the whole text a bit more readable... > The bit FRAMENUMBER_INTERLACED is not initialized anywhere in the current > version of the adv748x driver and therefore it is always 0, which is the > default value according to [1]. Therefore the current association of field > number from EAV/SAV code with the frame number in CSI FS and FE packets is: > field 1 (top field for PAL, bottom field for NTSC) -> CSI frame number 2 > field 2 (bottom field for PAL, top field for NTSC) -> CSI frame number 1 > But this breaks frame number based field detection of top/bottom fields > in CSI receivers. Therefore it makes sense to initialize the > FRAMENUMBER_INTERLACED bit to 1 so the association is as expected: > field 1 -> frame number 1 > field 2 -> frame number 2 I'm a bit worried by this patch, as it implies that we would have had our fields inverted in our testing, or if they are not - then applying this patch will then invert them! So either way we need to check this carefully. I can see the EAV:F values match the description above in the document... Niklas, how does RCar-CSI determine the top/bottom sequence? Do we have field inversion currently? (or one which is perhaps swapped somewhere along the pipeline in rcar-vin?) > [1] https://www.analog.com/en/products/adv7481.html > [2] https://www.itu.int/rec/R-REC-BT.656-5-200712-I/en > > Suggested-by: Steve Longerbeam > Signed-off-by: Michael Rodin > --- > drivers/media/i2c/adv748x/adv748x-core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c > index f57cd77..4dd1a13 100644 > --- a/drivers/media/i2c/adv748x/adv748x-core.c > +++ b/drivers/media/i2c/adv748x/adv748x-core.c > @@ -278,6 +278,9 @@ static int adv748x_power_up_tx(struct adv748x_csi2 *tx) > usleep_range(1000, 1500); > adv748x_write_check(state, page, 0x31, 0x80, &ret); > > + /* set bit 7 (FRAMENUMBER_INTERLACED) in csi_tx_top_reg_1f */ > + adv748x_write_check(state, page, 0x1f, 0x80, &ret); I think it would be nice to store the bit as macro defines in drivers/media/i2c/adv748x/adv748x.h I appreciate that the rest of this function does not (yet) do that however, (it has been derived from a table of ADI required writes) - but I think now that it is split from a table to a function it could be nice to clean up the 'magic numbers' along the way. Of course if you have time to convert the rest of the function as well (in a separate patch) that might be a nice cleanup, but not required. > + > return ret; > } > > -- Regards -- Kieran