Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68BFCC433EF for ; Thu, 18 Nov 2021 22:09:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 43CC661220 for ; Thu, 18 Nov 2021 22:09:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231911AbhKRWMX (ORCPT ); Thu, 18 Nov 2021 17:12:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231241AbhKRWMU (ORCPT ); Thu, 18 Nov 2021 17:12:20 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25A17C061748 for ; Thu, 18 Nov 2021 14:09:19 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id b12so14350381wrh.4 for ; Thu, 18 Nov 2021 14:09:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JTsp53tMG7c1WYigqpHa7U4JwCnUiTdLt5OKqZdpE/U=; b=ZrQrGOewZOM2JOZ0fc/lZhdfQjvkOFZS9t8wGvymD0J1R5JGn3xSwK5YDff0AixfvH muBRMYOWPymI3E5wwZkYd9K2Z3yGFzLn2VvlrJxP3fa7eqQ68K2A2h4VdOk6ce1m7a+B OPRq3Dx3ifRAZOHztRkopHTZrJIHjUP8MGUnc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JTsp53tMG7c1WYigqpHa7U4JwCnUiTdLt5OKqZdpE/U=; b=TMx1ULXVhQEypv6zXMp2C9IluREu71BLOuJ09zA6JPXz5gIbaNfQpjW5kIG68NgcVt WU3bNaag/OIYBuRuL4TQTFIMM3PbnZYN26Cr9JFpdC6LRjGI9eTpl2+8a6VMR0ZV354i HQSl3jU+c5Y/aSGuMS7mB7QlCyWW7ecIXGAYSLV0trrzuimiSzpQMzIgTsdwlA5mNmg2 OpeHYAg/rc1rRl+4FzUKHScZOz7q0244jxc9Zjgb2APxkaGvkVJA8ucOPcUCpPeOzRxm +hPFkYymp98G5pSpbvAQeTTEDsTTGmLAvFpv8NWWbU21h+1n4TGQqgaraESlmRX56itl rj8g== X-Gm-Message-State: AOAM532BlRSzb/A0fVOLrSCbnjtA+aCJZ69+7/k69D82Zjf4Xc3xFZgD Srfrynw9fWRaRAKlMGNv5lu1Hw== X-Google-Smtp-Source: ABdhPJxYWk2F67e5oLqA7SNo38Sf2FWRjG55q9cJZ9UDcqhJEYKCaehKtu7jjaPygK3HJCcTSBm+Cw== X-Received: by 2002:a5d:64af:: with SMTP id m15mr1037233wrp.267.1637273357738; Thu, 18 Nov 2021 14:09:17 -0800 (PST) Received: from beni.c.googlers.com.com (216.131.76.34.bc.googleusercontent.com. [34.76.131.216]) by smtp.gmail.com with ESMTPSA id f7sm13305180wmg.6.2021.11.18.14.09.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 14:09:17 -0800 (PST) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomasz Figa , Sergey Senozhatsky , "hn . chen" Cc: Ricardo Ribalda Subject: [PATCH 2/8] media: uvc: Allow quirking by entity guid Date: Thu, 18 Nov 2021 22:09:07 +0000 Message-Id: <20211118220913.299978-3-ribalda@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211118220913.299978-1-ribalda@chromium.org> References: <20211118220913.299978-1-ribalda@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When an IP is shared by multiple devices its erratas will be shared by all of them. Instead of creating a long list of device quirks, or waiting for the users to report errors in their hardware lets add a routine to add quirks based on the entity guid. Tested-by: hn.chen Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_driver.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 7c007426e0827..bb1cc8643161d 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1473,6 +1473,28 @@ static int uvc_parse_control(struct uvc_device *dev) return 0; } +static const struct uvc_entity_quirk { + u8 guid[16]; + u32 quirks; +} uvc_entity_quirk[] = { +}; + +static void uvc_entity_quirks(struct uvc_device *dev) +{ + struct uvc_entity *entity; + int i; + + list_for_each_entry(entity, &dev->entities, list) { + for (i = 0; i < ARRAY_SIZE(uvc_entity_quirk); i++) { + if (memcmp(entity->guid, uvc_entity_quirk[i].guid, + sizeof(entity->guid)) == 0) { + dev->quirks |= uvc_entity_quirk[i].quirks; + break; + } + } + } +} + /* ----------------------------------------------------------------------------- * Privacy GPIO */ @@ -2435,6 +2457,9 @@ static int uvc_probe(struct usb_interface *intf, goto error; } + /* Apply entity based quirks */ + uvc_entity_quirks(dev); + dev_info(&dev->udev->dev, "Found UVC %u.%02x device %s (%04x:%04x)\n", dev->uvc_version >> 8, dev->uvc_version & 0xff, udev->product ? udev->product : "", -- 2.34.0.rc2.393.gf8c9666880-goog