Received: by 10.223.164.202 with SMTP id h10csp980841wrb; Tue, 7 Nov 2017 19:00:57 -0800 (PST) X-Google-Smtp-Source: ABhQp+TmFf76NTsfEJopFYZnQdvqgJuJfk/OWSEc3vJ6Th6gWcTk+FdTVzmpxBKxC4SVcvMnz1/5 X-Received: by 10.101.65.75 with SMTP id x11mr796359pgp.388.1510110056909; Tue, 07 Nov 2017 19:00:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510110056; cv=none; d=google.com; s=arc-20160816; b=HLyjrDi12Y6q815xcsJWsIqHCrED8c+hlboblcmLR4mynbnkSf6ZmOje7iysjZynlo NYwGfoyx9KQa8zz9M+zCV8zymsok08SmbXJeuy1cDAffBjmv8hBDmvSjTICiHncRv/22 Q4Q0EeZPryjRSvkskvutC+3EiqEb5tssdTB1YZzZDyihe1q5bMQMQgAfZSoO4unUJQK1 ir3ieKZD6HUbQ8Z+BgWXlnqfYEXBcI8NtdXVp9iUchj4YGIdS4L2D1W6j1x8iOV5RK7h Kf7wZWY3FmchJ1QRcYMnZqkjSlVBjuZ12hJFASmdIRf4BxxPJuX1UF/IkF9AyugE3HPg 4jpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=C9NgKhPeOpOGb0xsPjgiSa2LeMcLhnUpC2fu8M+LCN8=; b=TavuUXiML6f2S/mLk1Pl6N1RVCKTT8LhXjwsyVh9WnSNxq7qU42PjMxGJmPpT+FwLV 42tyrTgznQaIhdyuuco8gbTMT55oEXs5zuOfEQd1Xz4UxGYkigFFEuv82pBI2mIrCtZh LUldT9VFb8TH+/pwOSHe+Fy75jS3UfhAh1MDhUaVVq6TB45znj61YJ0DcjuAvX9hAuAn K7xHZ58XE2dDVMZwO7ic0DHOErbTgZ5oR+VaXLmIXJjeINVHlz1kbazpqyUfbbpMZM4Q Uh6Thu//TA4ztAoLi011MwYP3UbbntLlNH3bhVipsrCyeclmm8ZI0dm6BDmFmCayl1WW 9LJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gateworks-com.20150623.gappssmtp.com header.s=20150623 header.b=uVPAwGXR; 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 o12si2496649plg.24.2017.11.07.19.00.44; Tue, 07 Nov 2017 19:00:56 -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; dkim=pass header.i=@gateworks-com.20150623.gappssmtp.com header.s=20150623 header.b=uVPAwGXR; 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 S1756225AbdKGWMU (ORCPT + 90 others); Tue, 7 Nov 2017 17:12:20 -0500 Received: from mail-wr0-f175.google.com ([209.85.128.175]:52452 "EHLO mail-wr0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756160AbdKGWMS (ORCPT ); Tue, 7 Nov 2017 17:12:18 -0500 Received: by mail-wr0-f175.google.com with SMTP id j23so640796wra.9 for ; Tue, 07 Nov 2017 14:12:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gateworks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=C9NgKhPeOpOGb0xsPjgiSa2LeMcLhnUpC2fu8M+LCN8=; b=uVPAwGXR66lbIJGLWT+++D2Gd1B3qkFgaNKDnloBDWYfiuxgqK3C20iviuLHTGx4Rf YW9SQv2aASy7tZEDYQk2r2Y457usM4b7dubTCwWSBkcBUCyogLhgeiYI4v4AcYuJPRjw 5jHeZlwqoppW/9rVfj16HkK9rYMll9g7pUYSBH7ySqvVqoNquSuTzaQOYmN2M8RYSRDd Qh5+iKWllYO1f38zTFMjIV4frr7ZGQZJjK9Pah6HyNKoriUhpKBZ2Wjwbo2nr4wL4ydX +c/BD/XW6TMBJnvdAX1x4+lYkLrxEU+ENQ02JERJ4pecLS1NgfwIxzMTiQsPWFI2y7CI /t6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=C9NgKhPeOpOGb0xsPjgiSa2LeMcLhnUpC2fu8M+LCN8=; b=XqYi26ojbH3k8JM89jaC8Io1U2LzHsTqf40rNR8g2N/DgOfhhfiq1CgN0+GZX8w4O1 BGLSf3Ghr2mlEtaHY3tW0Za0JMcoMzYP6A9dVtWyO4PJUv2LWAeyyclJl1iUND4kxcjq vbNXZsGQxUHBGnNmz9lnF30Kx0FJNj1MxJF/23DH4u+ALfNMibaXU4Ig1avljkJpVuS5 UMW5cTclRI7aP7A00v48e1vpJ72Kv8l67Svx5lB4dzChzLtp+LFoRvpJtND8tTGr9eub qIRDmCGeHLl70QsIMwdRVe7/zP0hKq9gLcsikpJMAO3v0HVIHoZvA1/mnrHR58bbIt7z FkfA== X-Gm-Message-State: AJaThX5AF5J7cQTyeYbpnsedySuWZLuxgjSMH1rNuWROXgU296twjVvU R0v8HbdzD+xE6d4RpJlX2mIYdonpjg4bay0r8GMaCA== X-Received: by 10.223.144.71 with SMTP id h65mr163197wrh.41.1510092736798; Tue, 07 Nov 2017 14:12:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.228.215 with HTTP; Tue, 7 Nov 2017 14:12:16 -0800 (PST) In-Reply-To: <82454b04-1664-423b-2b9e-36b3ae76e83a@xs4all.nl> 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> <82454b04-1664-423b-2b9e-36b3ae76e83a@xs4all.nl> From: Tim Harvey Date: Tue, 7 Nov 2017 14:12:16 -0800 Message-ID: Subject: Re: [PATCH v2 3/4] media: i2c: Add TDA1997x HDMI receiver driver To: Hans Verkuil 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 6, 2017 at 11:47 PM, Hans Verkuil wrote: > 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). Hans, These are actual timings that I'm feeding the TDA input from a Marshall V-SG4K-HDI HDMI test generator so they really are different timings and those are the vper/hper/hsper the TDA reports for them. Also, when I look at the original vendor code which had pre-calculated min/max numbers for vper/hper/hsper it matches the numbers above so I don't think the HDMI test generator is in error. Tim > > 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 1583429364848249064@xxx Tue Nov 07 17:31:57 +0000 2017 X-GM-THRID: 1581025700141870942 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread