linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Krzysztof Hałasa" <khalasa@piap.pl>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH REPOST] TDA1997x: replace video detection routine
Date: Thu, 22 Jul 2021 08:43:33 +0200	[thread overview]
Message-ID: <m3im12df1m.fsf@t19.piap.pl> (raw)
In-Reply-To: <m3mtqedfsg.fsf@t19.piap.pl> ("Krzysztof =?utf-8?Q?Ha=C5=82as?= =?utf-8?Q?a=22's?= message of "Thu, 22 Jul 2021 08:27:27 +0200")

Also, I have spotted an interesting loop condition in
drivers/media/v4l2-core/v4l2-dv-timings.c (dated 2013,
d1c65ad6a44b0ff79d2f0bf726fa6fd9248991f4).
It obviously works (unless the table grows to 600+ entries), but I guess
I should make it "standard", shouldn't I?

The first case is pretty normal:
@@ -159,10 +161,10 @@ int v4l2_enum_dv_timings_cap(struct v4l2_enum_dv_timings *t,
     u32 i, idx;
 
     memset(t->reserved, 0, sizeof(t->reserved));
-    for (i = idx = 0; i < ARRAY_SIZE(timings); i++) {
-        if (v4l2_dv_valid_timings(timings + i, cap) &&
+    for (i = idx = 0; v4l2_dv_timings_presets[i].bt.width; i++) {
+        if (v4l2_dv_valid_timings(v4l2_dv_timings_presets + i, cap) &&
             idx++ == t->index) {
-            t->timings = timings[i];
+            t->timings = v4l2_dv_timings_presets[i];
             return 0;
         }
     }

This is the interesting part:
@@ -179,10 +181,10 @@ bool v4l2_find_dv_timings_cap(struct v4l2_dv_timings *t,
     if (!v4l2_dv_valid_timings(t, cap))
         return false;
 
-    for (i = 0; i < ARRAY_SIZE(timings); i++) {
-        if (v4l2_dv_valid_timings(timings + i, cap) &&
-            v4l2_match_dv_timings(t, timings + i, pclock_delta)) {
-            *t = timings[i];
+    for (i = 0; i < v4l2_dv_timings_presets[i].bt.width; i++) {
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+        if (v4l2_dv_valid_timings(v4l2_dv_timings_presets + i, cap) &&
+            v4l2_match_dv_timings(t, v4l2_dv_timings_presets + i, pclock_delta)) {
+            *t = v4l2_dv_timings_presets[i];
             return true;
         }
     }

-- 
Krzysztof "Chris" Hałasa

Sieć Badawcza Łukasiewicz
Przemysłowy Instytut Automatyki i Pomiarów PIAP
Al. Jerozolimskie 202, 02-486 Warszawa

  reply	other threads:[~2021-07-22  6:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-19  9:30 [PATCH REPOST] TDA1997x: replace video detection routine Krzysztof Hałasa
2021-07-21  7:12 ` Hans Verkuil
2021-07-21  7:56   ` Krzysztof Hałasa
2021-07-21 10:04     ` Hans Verkuil
2021-07-22  6:27   ` Krzysztof Hałasa
2021-07-22  6:43     ` Krzysztof Hałasa [this message]
2021-07-23  8:24       ` Hans Verkuil
2021-07-23  8:49     ` Hans Verkuil
2021-07-23 11:57       ` Krzysztof Hałasa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3im12df1m.fsf@t19.piap.pl \
    --to=khalasa@piap.pl \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).