Received: by 10.223.164.202 with SMTP id h10csp409392wrb; Tue, 7 Nov 2017 08:14:14 -0800 (PST) X-Google-Smtp-Source: ABhQp+ST5rhuD2xbG09UiPrhQXxeBktNN4kp1hhRW0py++h0av4jR8izXj8xQ5fFcozkzVm0f5Ug X-Received: by 10.84.133.132 with SMTP id f4mr18530040plf.197.1510071254346; Tue, 07 Nov 2017 08:14:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510071254; cv=none; d=google.com; s=arc-20160816; b=p4Grup4oCiNl5l4MJiFNDktnL9QQA+RGC31ZNm62vnfg1GCowOgXOaXzZ6iy4xEvRq /mg2tBkKt96hbU9Y+/m0B9urGZPxyH9AfTTllF7uKTfdtRKIqMtW4iuU6lDq/KrItFeX vuxqjM0np/1jBboGh/v2aaiEsoRA69qb5Abfct0KUwBZfZSXYULCyDfTRCDFMoiry2tL fsrCC+y1r+yLNSjh9SZ6M4291bCGLQKIRp3prckfhtTrgdZrXLCfuO0zuTDgExSIIV6m sBg/jPGw40CWtmutIQ1lJmWJOqmwuT4ArkS3lyU6VfKglcNsx8EhWEHGOpdBGp/+q/QC Mlqw== 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:arc-authentication-results; bh=qw3npRPfXapR3AkWx9665P00AafymJn40iq9ArfGl7Q=; b=J9N3EFbLl4QQ7mVCks0upqIyqaMlFxuzLRlpQIlj4q1vBuqUwjMaTTihBoja/YG5Bu rZj7rsXWXcRO3FmLU7EgK4onYW9Ylus1OGRfecgNHc1ZE4vlBWdGLJ7UAt0h8jQqJRLo 6FG5MogsjmEO05NuA4nIjcH6ZpKYSoz9vnV6hF7fW+qb6OzWlBFT0PGxwiGGzHyx+D4v aPCz0pc6byyFg5OtU11/0g9Wb9waXl+bgC4GudF3e+BQAL+tc9Qnp+eM6wZ40W8BFVYL f8QRTxRXqPcDC46qwiHcEIUCyH494yHhAhqJe4yXoi8lRhyb5ggHyHsThIDW1U/jsIOi KIFg== 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 4si1502630ple.534.2017.11.07.08.14.00; Tue, 07 Nov 2017 08:14:14 -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 S1756064AbdKGHr1 (ORCPT + 91 others); Tue, 7 Nov 2017 02:47:27 -0500 Received: from lb1-smtp-cloud8.xs4all.net ([194.109.24.21]:40678 "EHLO lb1-smtp-cloud8.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755341AbdKGHrZ (ORCPT ); Tue, 7 Nov 2017 02:47:25 -0500 Received: from [192.168.2.10] ([212.251.195.8]) by smtp-cloud8.xs4all.net with ESMTPA id BybOedqCLg5cRBybSebHd2; Tue, 07 Nov 2017 08:47:23 +0100 Subject: Re: [PATCH v2 3/4] media: i2c: Add TDA1997x HDMI receiver driver To: Tim Harvey Cc: linux-media , alsa-devel@alsa-project.org, "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Shawn Guo , Steve Longerbeam , Philipp Zabel , Hans Verkuil , Mauro Carvalho Chehab References: <1507783506-3884-1-git-send-email-tharvey@gateworks.com> <1507783506-3884-4-git-send-email-tharvey@gateworks.com> <230ceb18-1d69-7fa8-acb0-c810094f8e50@xs4all.nl> From: Hans Verkuil Message-ID: <82454b04-1664-423b-2b9e-36b3ae76e83a@xs4all.nl> Date: Tue, 7 Nov 2017 08:47:18 +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: MS4wfM8SVDvkAay1NkLGCLRIc/mTWpuJU40SxdvZy/8/NMt8NWng1Ww3wJbVSm+kwsDgRFg29VatKYEM2FDnFJcaZKbpvBs+FgqTAJqelAsR4TFaSfxv9yGQ GtuZ2H34UmGsrMdbdxn3F9e5kaMhqLxhJUpztauA/aPL/neOWdTc4PDHSzxg/OfASDPrUqnQ97FKGguni62JALvCsPXtGvI45z2aanLI4QnvtKbyJvLxZ/TX OZ+83+Dak+ZeFB5kKltK1HmfGa8rJeMq1633HPKNzMUCZOwl/8zaIdIAHJiHBzF9ooX7wU21gtgDRht8HanHYfdffKCi3W4HQsQHeE9XEORVHnDBc6S68Eh7 FDqIKs9n/s4j5wR2J7E3s4Zo0V7On0PEthcvscwSaXAb5eW3MYpT2MFZtw04yA21dDYA9akcH4bJCOF42oFHQMke0tYkf45hjObKVB6OBfaVDkDW86s= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/07/2017 07:04 AM, Tim Harvey wrote: > On Fri, Oct 20, 2017 at 7:00 AM, Tim Harvey wrote: >> On Thu, Oct 19, 2017 at 12:39 AM, Hans Verkuil wrote: >> >>>> >>>> Regarding video standard detection where this chip provides me with >>>> vertical-period, horizontal-period, and horizontal-pulse-width I >>>> should be able to detect the standard simply based off of >>>> vertical-period (framerate) and horizontal-period (line width >>>> including blanking) right? I wasn't sure if my method of matching >>>> these within 14% tolerance made sense. I will be removing the hsmatch >>>> logic from that as it seems the horizontal-pulse-width should be >>>> irrelevant. >>> >>> For proper video detection you ideally need: >>> >>> h/v sync size >>> h/v back/front porch size >>> h/v polarity >>> pixelclock (usually an approximation) >>> >>> The v4l2_find_dv_timings_cap() helper can help you find the corresponding >>> timings, allowing for pixelclock variation. >>> >>> That function assumes that the sync/back/frontporch values are all known. >>> But not all devices can actually discover those values. What can your >>> hardware detect? Can it tell front and backporch apart? Can it determine >>> the sync size? >>> >>> I've been considering for some time to improve that helper function to be >>> able to handle hardware that isn't able separate sync/back/frontporch values. >>> >> >> The TDA1997x provides only the vertical/horizontal periods and the >> horizontal pulse >> width (section 8.3.4 of datasheet [1]). >> >> Can you point me to a good primer on the relationship between these >> values and the h/v back/front porch? >> >> Currently I iterate over the list of known formats calculating hper >> (bt->pixelclock / V4L2_DV_BT_FRAME_WIDTH(bt)) and vper (hper / >> V4L2_DV_BT_FRAME_HEIGHT(bt)) (framerate) and find the closest match >> within +/- 7% tolerance. The list of supported formats is sorted by >> framerate then width. >> >> /* look for matching timings */ >> for (i = 0; i < ARRAY_SIZE(tda1997x_hdmi_modes); i++) { >> const struct tda1997x_video_std *std = &tda1997x_hdmi_modes[i]; >> const struct v4l2_bt_timings *bt = &std->timings.bt; >> int _hper, _vper, _hsper; >> int vmin, vmax, hmin, hmax, hsmin, hsmax; >> int vmatch, hsmatch; >> >> width = V4L2_DV_BT_FRAME_WIDTH(bt); >> lines = V4L2_DV_BT_FRAME_HEIGHT(bt); >> >> _hper = (int)bt->pixelclock / (int)width; >> _vper = _hper / lines; >> _hsper = (int)bt->pixelclock / (int)bt->hsync; >> if (bt->interlaced) >> _vper *= 2; >> /* vper +/- 0.7% */ >> vmin = 993 * (27000000 / _vper) / 1000; >> vmax = 1007 * (27000000 / _vper) / 1000; >> _hsper = (int)bt->pixelclock / (int)bt->hsync; >> if (bt->interlaced) >> _vper *= 2; >> /* vper +/- 0.7% */ >> vmin = 993 * (27000000 / _vper) / 1000; >> vmax = 1007 * (27000000 / _vper) / 1000; >> /* hper +/- 0.7% */ >> hmin = 993 * (27000000 / _hper) / 1000; >> hmax = 1007 * (27000000 / _hper) / 1000; >> >> /* vmatch matches the framerate */ >> vmatch = ((vper <= vmax) && (vper >= vmin)) ? 1 : 0; >> /* hmatch matches the width */ >> hmatch = ((hper <= hmax) && (hper >= hmin)) ? 1 : 0; >> if (vmatch && hsmatch) { >> v4l_info(state->client, >> "resolution: %dx%d%c@%d (%d/%d/%d) %dMHz %d\n", >> bt->width, bt->height, bt->interlaced?'i':'p', >> _vper, vper, hper, hsper, pixrate, hsmatch); >> state->fps = (int)bt->pixelclock / (width * lines); >> state->std = std; >> return 0; >> } >> } >> >> Note that I've thrown out any comparisons based on horizontal pulse >> width from my first patch as that didn't appear to fit well. So far >> the above works well however I do fail to recognize the following >> modes (using a Marshall SG4K HDMI test generator): >> > > Hans, > > I've found that I do indeed need to look at the 'hsper' that the TDA > provides above along with the vper/hper as there are several timings > that match a given vper/hper. However I haven't figured out how to > make sense of the hsper value that is returned. > > Here are some example timings and the vper/hper/hsper returned from the TDA: > V4L2_DV_BT_DMT_1280X960P60 449981/448/55 > V4L2_DV_BT_DMT_1280X1024P60 449833/420/27 > V4L2_DV_BT_DMT_1280X768P60 450021/568/11 > V4L2_DV_BT_DMT_1360X768P60 449867/564/34 > > Do you know what the hsper could be here? It doesn't appear to match > v4l2_bt_timings hsync ((27MHz/bt->pixelclock)*bt->hsync). Actually, all numbers except for the first match (assuming V4L2_DV_BT_DMT_1280X768P60 is really V4L2_DV_BT_DMT_1280X768P60_RB). Are you sure about the first one? Unfortunately, due to rounding errors the hsper is simply not accurate enough to use reliably. Furthermore, what is really needed if you want to add support for GTF and CVT standards is the vsync value, and that's not reported at all. I'd just give up on this and use your original code. Very poor hardware design :-( Regards, Hans From 1583128794146035928@xxx Sat Nov 04 09:54:30 +0000 2017 X-GM-THRID: 1581025700141870942 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread