Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp979887pxb; Tue, 14 Sep 2021 13:08:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxhGrfRMQHSHay0V+qpr1RM01dvM5v1UPdd4vmj9oX6XDSfEsq3W92dc44MkiTh/TZtZvU X-Received: by 2002:a6b:3b8c:: with SMTP id i134mr14547540ioa.29.1631650137645; Tue, 14 Sep 2021 13:08:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631650137; cv=none; d=google.com; s=arc-20160816; b=I5RnIm1cc/PqrFngQDrq07cG+pRU4mvN0T9NRqbIquEa+H73nf4vDfhE3BB5v6POLR jFjGh0T9CjrOYX1zp0xMS9YhgWLOpx+RK62+Wpm4vJTJ0fkZmCGGMj0BiQHV7qYswlxg mM3mwdJ6axYPtGWvotf4V1ooALZF8Nl1/4BOqT/yayGPp1+GnyayDbbzZ6utqADeFND7 H2HRHhG2g/Y55BbtqPnPQmF5eWr63Ng5h6d2MDFNEq9LvA0fm0MEsNcUg6+PIr9T0zFn hjMNP0veRgjndKfoJVoTT6yh93zLiO5yz2JnwYgDCmckgyD41alCkeeTVEOCd42R0DL4 or/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2K42Cco3VEzvh5/q/0m2XAwxpLXefoWzF9vdOC1B4Gw=; b=H6b6FBYvmjInnycs7P2+3ATaLWQLpwvERgCQ/UifibUaeTeEMpX+U/hUjI4nk0Lz/g 8teQ+hgFyRnSfW2+NK6SWP7vZBZZPchNQfMZGiHTU/M4mdUGAah9U3TTlh4sr7kyoyKB 3u2451Nu6Wxe25ypb1QqNXVnOicyeOcw6aps+ySNbofL3CxJZoMVTJtU5Kg0BjLRWr3u QPMvh8v6tiaPog1lBuTMxx8szEjvqiVwWVdp40Z5pEEEQCCt2DNAuHD/CsCJ/5F3h+Kc s69uZ+H08coZbgRW5XCUvpj/C742waUenB3wWSxE5sQ+gFBGehPG/EzDjuU7GP8ohZB6 khsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BJhND6MG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n20si11113327iod.5.2021.09.14.13.08.45; Tue, 14 Sep 2021 13:08:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BJhND6MG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233349AbhINUJH (ORCPT + 99 others); Tue, 14 Sep 2021 16:09:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232545AbhINUJG (ORCPT ); Tue, 14 Sep 2021 16:09:06 -0400 Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73D84C061574 for ; Tue, 14 Sep 2021 13:07:48 -0700 (PDT) Received: by mail-qk1-x732.google.com with SMTP id a10so780990qka.12 for ; Tue, 14 Sep 2021 13:07:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2K42Cco3VEzvh5/q/0m2XAwxpLXefoWzF9vdOC1B4Gw=; b=BJhND6MG+JUZihcXSCVNsVkdDkscbXLe8kths9jHgjS4SLgYrqGaQp9OPqfXejdGA/ ZIntkKlQZztXJwl/c/22qlX12SBrSu9xI7kd5YDbYcDWkLHLSQisKoAr972kYDUnT241 jPCyXtIrFjVVOZz3sqJrKkZeNMO/myXFIEVEc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2K42Cco3VEzvh5/q/0m2XAwxpLXefoWzF9vdOC1B4Gw=; b=Lemw6+bSl4nsvf1RDQ5bf4f7qX3ruhhCcCytMj8m8xRg8JADYmxHGKIkQ8sI1lvQpi tCYGnAIZR0mheOGiQMBljuECskEdHiIAIVXnl4OPJGWKgLMnzLpgitr4Qyx/uI1SiU7G WDTOEtvxrhZRfncsaroRw3NWEBm+l/eOkteFbHB8gxsPlOTxR3Lr7QtakO5+MdXetBMt X6ikFIVxlpT7Bq5YK3WR+aV8P561CtWDyZxTclBYyyy6BtQMGTjPt7YhtEflzB1UumZ4 UnqVOCtTpv1uBvSwn09zrU+X/35Mo6ph/VhVoofu05qYSSYq4hxQj4PnMLDkzjNceDB4 hs1g== X-Gm-Message-State: AOAM5337CfrEHWU/y5E91goZY0s7i9IJP/ICZvR9xoOT3h3HKL+PFv82 2dgGcV6v1ZwXfc4WmO1a3/5cI4sfEUKAzg== X-Received: by 2002:a37:741:: with SMTP id 62mr6768249qkh.490.1631650067422; Tue, 14 Sep 2021 13:07:47 -0700 (PDT) Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com. [209.85.222.175]) by smtp.gmail.com with ESMTPSA id v14sm8296004qkb.88.2021.09.14.13.07.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Sep 2021 13:07:47 -0700 (PDT) Received: by mail-qk1-f175.google.com with SMTP id y144so825558qkb.6 for ; Tue, 14 Sep 2021 13:07:47 -0700 (PDT) X-Received: by 2002:a05:6638:dc8:: with SMTP id m8mr16281460jaj.93.1631649751964; Tue, 14 Sep 2021 13:02:31 -0700 (PDT) MIME-Version: 1.0 References: <20210909210032.465570-1-dianders@chromium.org> <20210909135838.v4.4.I6103ce2b16e5e5a842b14c7022a034712b434609@changeid> <87ee9r10qw.fsf@intel.com> <87y27zyodw.fsf@intel.com> <5af6cd50-0ed3-1a70-d7d0-66ca18a83d65@samsung.com> In-Reply-To: <5af6cd50-0ed3-1a70-d7d0-66ca18a83d65@samsung.com> From: Doug Anderson Date: Tue, 14 Sep 2021 13:02:20 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 04/15] drm/edid: Use new encoded panel id style for quirks matching To: Andrzej Hajda Cc: Jani Nikula , Thierry Reding , Rob Herring , Sam Ravnborg , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Maxime Ripard , Thomas Zimmermann , Linus W , Daniel Vetter , linux-arm-msm , Steev Klimaszewski , Maarten Lankhorst , Bjorn Andersson , David Airlie , dri-devel , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Sep 14, 2021 at 12:36 PM Andrzej Hajda wrote: > > > W dniu 14.09.2021 o 20:59, Jani Nikula pisze: > > On Tue, 14 Sep 2021, Doug Anderson wrote: > >> Hi, > >> > >> On Tue, Sep 14, 2021 at 11:16 AM Jani Nikula > >> wrote: > >>> On Thu, 09 Sep 2021, Douglas Anderson wrote: > >>>> In the patch ("drm/edid: Allow the querying/working with the panel ID > >>>> from the EDID") we introduced a different way of working with the > >>>> panel ID stored in the EDID. Let's use this new way for the quirks > >>>> code. > >>>> > >>>> Advantages of the new style: > >>>> * Smaller data structure size. Saves 4 bytes per panel. > >>>> * Iterate through quirks structure with just "==" instead of strncmp() > >>>> * In-kernel storage is more similar to what's stored in the EDID > >>>> itself making it easier to grok that they are referring to the same > >>>> value. > >>>> > >>>> The quirk table itself is arguably a bit less readable in the new > >>>> style but not a ton less and it feels like the above advantages make > >>>> up for it. > >>> I suppose you could pass vendor as a string to EDID_QUIRK() to retain > >>> better readability? > >> I would love to, but I couldn't figure out how to do this and have it > >> compile! Notably I need the compiler to be able to do math at compile > >> time to compute the final u32 to store in the init data. I don't think > >> the compiler can dereference strings (even constant strings) and do > >> math on the result at compile time. > > Ah, right. > > > What about: > > +#define drm_edid_encode_panel_id(vend, product_id) \ > + ((((u32)((vend)[0]) - '@') & 0x1f) << 26 | \ > + (((u32)((vend)[1]) - '@') & 0x1f) << 21 | \ > + (((u32)((vend)[2]) - '@') & 0x1f) << 16 | \ > + ((product_id) & 0xffff)) Wow, I _swear_ I tried exactly that syntax, but clearly I didn't. It works great and it looks _sooo_ much nicer now. Thanks! I'll send out a v5 shortly with this. -Doug