From patchwork Fri Jun 17 23:56:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 582700 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAF23C433EF for ; Fri, 17 Jun 2022 23:56:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383150AbiFQX4U (ORCPT ); Fri, 17 Jun 2022 19:56:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232294AbiFQX4P (ORCPT ); Fri, 17 Jun 2022 19:56:15 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68B1656C13 for ; Fri, 17 Jun 2022 16:56:14 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id ej4so4094229edb.7 for ; Fri, 17 Jun 2022 16:56:14 -0700 (PDT) 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=XGyvgzMv/o67vUhjuadDgOPqP6bhpgbwlijxZc2E+uw=; b=LP7WqlQcTCQrr6X3k4GSlkNW2hhRAOd5wxFafKA1jUlJdUy1jJq6cRySyriytN2jpJ 0eT2HeQYXGlDjosKyRxec2chetVVzCU0czgjx9jhEHPmbwOAVsEnVgVk2DW/3jaYrxoZ epT1EqBf7K2r4ZiLv3bVKwg6u+Lz5KiEhb2w4= 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=XGyvgzMv/o67vUhjuadDgOPqP6bhpgbwlijxZc2E+uw=; b=zIiRF7I7be4fYVgoDqiO7sbnjnZjSv9H2bkZODuc3+vr8eQR5jQntb2PZ5ItPoOkPa tdOKJ0iP+PrPQ4NSsHHML+ALIQ2BSU4kxFBPc24a/6FOjpdgX1XM5gK0ij2ZAvBq2yvZ HyZ911QtKB/Ly5mp16aFij/y96m4l64PikFUadIJ9E2TmNuJMEPCyihOkM5u8/o66r/B NZ5BoL06HFuJZvbsgC6fEMMC/a31hreebm7cFMORD1l1bzYyKHL1uIWKt0yS7X5K+FMX mDeQzxoqRvrNRUl37Iynmw4MjAJTO3sMR2tCV/uH+3Hq+PbSZff0bAHxjAiEaZePyx+A F+pg== X-Gm-Message-State: AJIora9+wgqAm57PMA+i7REh+KXjPcMnwnRBVYtokAMwSXq0tHqZQ9qu vyZ1bx6gY8+Jdt5LSElsGo4vLQ== X-Google-Smtp-Source: AGRyM1tJGH6oMZrjLMSMpk5XR2asvL1lPSg4xxY9zB68xl7XOrnUIZwfRaIBY/JEhCXSiXdH4cDbEw== X-Received: by 2002:a05:6402:2211:b0:42d:cb9e:cbf with SMTP id cq17-20020a056402221100b0042dcb9e0cbfmr15566816edb.76.1655510172931; Fri, 17 Jun 2022 16:56:12 -0700 (PDT) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id z21-20020aa7d415000000b0043566884333sm1452538edq.63.2022.06.17.16.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 16:56:12 -0700 (PDT) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org, senozhatsky@chromium.org, yunkec@google.com Cc: Ricardo Ribalda Subject: [PATCH v8 1/9] media: uvcvideo: Add missing value for power_line_frequency Date: Sat, 18 Jun 2022 01:56:02 +0200 Message-Id: <20220617235610.321917-2-ribalda@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220617235610.321917-1-ribalda@chromium.org> References: <20220617235610.321917-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org UVC 1.5 class defines 4 values for this control on: 4.2.2.3.6 Power Line Frequency Control Add the missing value when the UVC version is 1.5. Signed-off-by: Ricardo Ribalda Signed-off-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_ctrl.c | 56 +++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 0e78233fc8a0..a709ebbb4d69 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -366,6 +366,7 @@ static const struct uvc_menu_info power_line_frequency_controls[] = { { 0, "Disabled" }, { 1, "50 Hz" }, { 2, "60 Hz" }, + { 3, "Auto" }, }; static const struct uvc_menu_info exposure_auto_controls[] = { @@ -504,17 +505,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { .v4l2_type = V4L2_CTRL_TYPE_INTEGER, .data_type = UVC_CTRL_DATA_TYPE_UNSIGNED, }, - { - .id = V4L2_CID_POWER_LINE_FREQUENCY, - .entity = UVC_GUID_UVC_PROCESSING, - .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, - .size = 2, - .offset = 0, - .v4l2_type = V4L2_CTRL_TYPE_MENU, - .data_type = UVC_CTRL_DATA_TYPE_ENUM, - .menu_info = power_line_frequency_controls, - .menu_count = ARRAY_SIZE(power_line_frequency_controls), - }, { .id = V4L2_CID_HUE_AUTO, .entity = UVC_GUID_UVC_PROCESSING, @@ -730,6 +720,34 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, }; +static const struct uvc_control_mapping uvc_ctrl_mappings_uvc11[] = { + { + .id = V4L2_CID_POWER_LINE_FREQUENCY, + .entity = UVC_GUID_UVC_PROCESSING, + .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, + .size = 2, + .offset = 0, + .v4l2_type = V4L2_CTRL_TYPE_MENU, + .data_type = UVC_CTRL_DATA_TYPE_ENUM, + .menu_info = power_line_frequency_controls, + .menu_count = ARRAY_SIZE(power_line_frequency_controls) - 1, + }, +}; + +static const struct uvc_control_mapping uvc_ctrl_mappings_uvc15[] = { + { + .id = V4L2_CID_POWER_LINE_FREQUENCY, + .entity = UVC_GUID_UVC_PROCESSING, + .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, + .size = 2, + .offset = 0, + .v4l2_type = V4L2_CTRL_TYPE_MENU, + .data_type = UVC_CTRL_DATA_TYPE_ENUM, + .menu_info = power_line_frequency_controls, + .menu_count = ARRAY_SIZE(power_line_frequency_controls), + }, +}; + /* ------------------------------------------------------------------------ * Utility functions */ @@ -2415,6 +2433,22 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, if (!ctrl->initialized) return; + /* Process common mappings first. */ + for (; mapping < mend; ++mapping) { + if (uvc_entity_match_guid(ctrl->entity, mapping->entity) && + ctrl->info.selector == mapping->selector) + __uvc_ctrl_add_mapping(chain, ctrl, mapping); + } + + /* And then version-specific mappings. */ + if (chain->dev->uvc_version < 0x0150) { + mapping = uvc_ctrl_mappings_uvc11; + mend = mapping + ARRAY_SIZE(uvc_ctrl_mappings_uvc11); + } else { + mapping = uvc_ctrl_mappings_uvc15; + mend = mapping + ARRAY_SIZE(uvc_ctrl_mappings_uvc15); + } + for (; mapping < mend; ++mapping) { if (uvc_entity_match_guid(ctrl->entity, mapping->entity) && ctrl->info.selector == mapping->selector) From patchwork Fri Jun 17 23:56:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 583094 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F10FEC43334 for ; Fri, 17 Jun 2022 23:56:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383637AbiFQX4b (ORCPT ); Fri, 17 Jun 2022 19:56:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237569AbiFQX4Q (ORCPT ); Fri, 17 Jun 2022 19:56:16 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41A0C583BA for ; Fri, 17 Jun 2022 16:56:15 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id u12so11347029eja.8 for ; Fri, 17 Jun 2022 16:56:15 -0700 (PDT) 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=cTvpiA1ZR8U86goCmlr+HfJiNGZOCmT5oj2favFUYLQ=; b=mmZtlQMGzNCjNQcv1eiLgD4N0okaAEzkDLg2T816Ydsp/aqrt1gynFn9IbR10J0kMK ZoKHJuJqwJvu/rKGd2qhUtN/kEtd0v6DRVKf7SIHAGsfzA5XdOPfUmtK9a68uBKB30kO nhS15u+yddeKPuOaAZd8sPI/m9mK5nJbw//7U= 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=cTvpiA1ZR8U86goCmlr+HfJiNGZOCmT5oj2favFUYLQ=; b=Oen7W1e6PrVamn7EGcZlSeSI82u3/fzfE5wlfAL8FN/6ro879lqRztFtUxxvGBicWr IdmQ9Z7Y9As+LU9kY26xjaj4sOxz+WtScUzgHW3Sa7PfFJZXcrA96XZ9L2u+EGKFxUh7 qHQZOhTcKoOu5dXvyjkx8MCUMZOd8n7I+zvnb0+JLbQHLNjUFSWwCy2EjOoLvnWDt0Sm znWXpYEVGhfUeeYpWK4RF89Gw9KHX7bcA7wtQ6t5LfVIRsTlFw2J3Mno1+/GLzmOyOVM SecqR2zI/Y8M5o+K8YOlxsPmwLspmWhZygXkscLFeAKISgCgqKQkMaXA2M2jsYSIFD8O 7wOg== X-Gm-Message-State: AJIora+IP3eJKdAHuLfQycuOwCvTH5FzXluwgZZsjDbJwvMIMC64FX5Z 6n7XKt1TEKbE3uUZDRvEk+dObg== X-Google-Smtp-Source: AGRyM1vse0uGK1yWxGhb3BsOpxdtQXZjfNnlbuQsl4ZsUJZ7mUmiQA7UCBYBt+R7/6rjeT2czFMlDw== X-Received: by 2002:a17:907:9005:b0:715:76ce:4476 with SMTP id ay5-20020a170907900500b0071576ce4476mr11643302ejc.560.1655510173781; Fri, 17 Jun 2022 16:56:13 -0700 (PDT) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id z21-20020aa7d415000000b0043566884333sm1452538edq.63.2022.06.17.16.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 16:56:13 -0700 (PDT) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org, senozhatsky@chromium.org, yunkec@google.com Cc: Ricardo Ribalda Subject: [PATCH v8 2/9] media: uvcvideo: Add support for per-device control mapping overrides Date: Sat, 18 Jun 2022 01:56:03 +0200 Message-Id: <20220617235610.321917-3-ribalda@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220617235610.321917-1-ribalda@chromium.org> References: <20220617235610.321917-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Some devices do not implement all their controls in a way that complies with the UVC specification. This is for instance the case for several devices that do not support the disabled mode for the power line frequency control. Add a mechanism to allow per-device control mapping overrides to avoid errors when accessing non-compliant controls. Signed-off-by: Ricardo Ribalda Signed-off-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_ctrl.c | 34 +++++++++++++++++++++++++++----- drivers/media/usb/uvc/uvcvideo.h | 1 + 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index a709ebbb4d69..38e35e369ddf 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -2403,9 +2403,8 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, { const struct uvc_control_info *info = uvc_ctrls; const struct uvc_control_info *iend = info + ARRAY_SIZE(uvc_ctrls); - const struct uvc_control_mapping *mapping = uvc_ctrl_mappings; - const struct uvc_control_mapping *mend = - mapping + ARRAY_SIZE(uvc_ctrl_mappings); + const struct uvc_control_mapping *mapping; + const struct uvc_control_mapping *mend; /* XU controls initialization requires querying the device for control * information. As some buggy UVC devices will crash when queried @@ -2433,14 +2432,39 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, if (!ctrl->initialized) return; - /* Process common mappings first. */ + /* + * First check if the device provides a custom mapping for this control, + * used to override standard mappings for non-conformant devices. Don't + * process standard mappings if a custom mapping is found. This + * mechanism doesn't support combining standard and custom mappings for + * a single control. + */ + if (chain->dev->info->mappings) { + bool custom = false; + unsigned int i; + + for (i = 0; (mapping = chain->dev->info->mappings[i]); ++i) { + if (uvc_entity_match_guid(ctrl->entity, mapping->entity) && + ctrl->info.selector == mapping->selector) { + __uvc_ctrl_add_mapping(chain, ctrl, mapping); + custom = true; + } + } + + if (custom) + return; + } + + /* Process common mappings next. */ + mapping = uvc_ctrl_mappings; + mend = mapping + ARRAY_SIZE(uvc_ctrl_mappings); for (; mapping < mend; ++mapping) { if (uvc_entity_match_guid(ctrl->entity, mapping->entity) && ctrl->info.selector == mapping->selector) __uvc_ctrl_add_mapping(chain, ctrl, mapping); } - /* And then version-specific mappings. */ + /* Finally process version-specific mappings. */ if (chain->dev->uvc_version < 0x0150) { mapping = uvc_ctrl_mappings_uvc11; mend = mapping + ARRAY_SIZE(uvc_ctrl_mappings_uvc11); diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index c5b4febd2d94..fff5c5c99a3d 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -667,6 +667,7 @@ struct uvc_device_info { u32 quirks; u32 meta_format; u16 uvc_version; + const struct uvc_control_mapping **mappings; }; struct uvc_device { From patchwork Fri Jun 17 23:56:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 582699 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F88CCCA479 for ; Fri, 17 Jun 2022 23:56:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383733AbiFQX4d (ORCPT ); Fri, 17 Jun 2022 19:56:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347078AbiFQX4R (ORCPT ); Fri, 17 Jun 2022 19:56:17 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 184FD5A5B5 for ; Fri, 17 Jun 2022 16:56:16 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id b8so8015675edj.11 for ; Fri, 17 Jun 2022 16:56:16 -0700 (PDT) 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=jzUksJeBIzpsy16UnewiZbK9lVKFqzRfDsj2A+v5TqE=; b=Aqcio3+OisfYLPjsZkAJKSDbmJUrEQObnag1l5b3iiryXcpoj/AzYByWjPa7XmotVb 3Udj1arHXw5FldLsfjkY3r3XK3Tv8oHTJ/zxgHkZKS/YBBZ1jj81q+0Xj7+Xe/fz4srz cqgqum6vhWyih0CIe9y0AFr+DzXsP7UUFo+yc= 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=jzUksJeBIzpsy16UnewiZbK9lVKFqzRfDsj2A+v5TqE=; b=zrkglKa7gLKLvpuu+NeQ9fAJtb3d8llZ02zhhCT65+zQ/axxyi+SgqRBsLuRvs7rbd bJSlVLOAH03spWyI1tXwIZfuhPXhVVJpSejJcfkuPqDfj9TP0OU3kjlZ2LeLJNVaC0N/ Sy7PatR4J2wm6hsqxEDUk6jAGpJ/bvmK8MNHWnFRXVMUJzQ+w+QwsndonH1rDD2OiPK0 470l4h8FaJ4v8Cl/o8An/cGgmKRJwOTDCDU75sb+5yzL+K0jmv5bo2vm9AXsQxEGasKL A7JaTKR4Lo+sciuWanjxtL+y/Tfkcse1k29j0Ffvt2zYDZoPrGbsrTXGIIzyxAkALvCw Rozg== X-Gm-Message-State: AJIora8Dnau/t9YuqUace0CDXemrPFTndDi0lte3AGJ234muwu0eh0hV gORQntR8tce6w0ViaFZvb7gzWw== X-Google-Smtp-Source: AGRyM1v1BXRQH1QU7y1eRqMlDrpZIcr1QOY200xBGU0eoON+62vb30JkTD1Vhq7N6dpOxtL8S7WF5w== X-Received: by 2002:aa7:df19:0:b0:435:5eb7:5e31 with SMTP id c25-20020aa7df19000000b004355eb75e31mr6980994edy.418.1655510174636; Fri, 17 Jun 2022 16:56:14 -0700 (PDT) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id z21-20020aa7d415000000b0043566884333sm1452538edq.63.2022.06.17.16.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 16:56:14 -0700 (PDT) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org, senozhatsky@chromium.org, yunkec@google.com Cc: Ricardo Ribalda Subject: [PATCH v8 3/9] media: uvcvideo: Implement mask for V4L2_CTRL_TYPE_MENU Date: Sat, 18 Jun 2022 01:56:04 +0200 Message-Id: <20220617235610.321917-4-ribalda@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220617235610.321917-1-ribalda@chromium.org> References: <20220617235610.321917-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Replace the count with a mask field that let us choose not only the max value, but also the minimum value and what values are valid in between. Signed-off-by: Ricardo Ribalda Suggested-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_ctrl.c | 32 ++++++++++++++++++++++---------- drivers/media/usb/uvc/uvc_v4l2.c | 2 +- drivers/media/usb/uvc/uvcvideo.h | 2 +- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 38e35e369ddf..a03714c3a265 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -524,7 +524,8 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { .v4l2_type = V4L2_CTRL_TYPE_MENU, .data_type = UVC_CTRL_DATA_TYPE_BITMASK, .menu_info = exposure_auto_controls, - .menu_count = ARRAY_SIZE(exposure_auto_controls), + .menu_mask = + BIT_MASK(ARRAY_SIZE(exposure_auto_controls)), .slave_ids = { V4L2_CID_EXPOSURE_ABSOLUTE, }, }, { @@ -730,7 +731,8 @@ static const struct uvc_control_mapping uvc_ctrl_mappings_uvc11[] = { .v4l2_type = V4L2_CTRL_TYPE_MENU, .data_type = UVC_CTRL_DATA_TYPE_ENUM, .menu_info = power_line_frequency_controls, - .menu_count = ARRAY_SIZE(power_line_frequency_controls) - 1, + .menu_mask = + BIT_MASK(ARRAY_SIZE(power_line_frequency_controls) - 1), }, }; @@ -744,7 +746,8 @@ static const struct uvc_control_mapping uvc_ctrl_mappings_uvc15[] = { .v4l2_type = V4L2_CTRL_TYPE_MENU, .data_type = UVC_CTRL_DATA_TYPE_ENUM, .menu_info = power_line_frequency_controls, - .menu_count = ARRAY_SIZE(power_line_frequency_controls), + .menu_mask = + BIT_MASK(ARRAY_SIZE(power_line_frequency_controls)), }, }; @@ -970,7 +973,9 @@ static s32 __uvc_ctrl_get_value(struct uvc_control_mapping *mapping, const struct uvc_menu_info *menu = mapping->menu_info; unsigned int i; - for (i = 0; i < mapping->menu_count; ++i, ++menu) { + for (i = 1; BIT(i) <= mapping->menu_mask; ++i, ++menu) { + if (!test_bit(i, &mapping->menu_mask)) + continue; if (menu->value == value) { value = i; break; @@ -1144,12 +1149,14 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, switch (mapping->v4l2_type) { case V4L2_CTRL_TYPE_MENU: - v4l2_ctrl->minimum = 0; - v4l2_ctrl->maximum = mapping->menu_count - 1; + v4l2_ctrl->minimum = ffs(mapping->menu_mask) - 1; + v4l2_ctrl->maximum = fls(mapping->menu_mask) - 1; v4l2_ctrl->step = 1; menu = mapping->menu_info; - for (i = 0; i < mapping->menu_count; ++i, ++menu) { + for (i = 1; BIT(i) <= mapping->menu_mask; ++i, ++menu) { + if (!test_bit(i, &mapping->menu_mask)) + continue; if (menu->value == v4l2_ctrl->default_value) { v4l2_ctrl->default_value = i; break; @@ -1264,7 +1271,7 @@ int uvc_query_v4l2_menu(struct uvc_video_chain *chain, goto done; } - if (query_menu->index >= mapping->menu_count) { + if (!test_bit(query_menu->index, &mapping->menu_mask)) { ret = -EINVAL; goto done; } @@ -1769,8 +1776,13 @@ int uvc_ctrl_set(struct uvc_fh *handle, break; case V4L2_CTRL_TYPE_MENU: - if (xctrl->value < 0 || xctrl->value >= mapping->menu_count) + if (xctrl->value < (ffs(mapping->menu_mask) - 1) || + xctrl->value > (fls(mapping->menu_mask) - 1)) return -ERANGE; + + if (!test_bit(xctrl->value, &mapping->menu_mask)) + return -EINVAL; + value = mapping->menu_info[xctrl->value].value; /* Valid menu indices are reported by the GET_RES request for @@ -2217,7 +2229,7 @@ static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain, INIT_LIST_HEAD(&map->ev_subs); - size = sizeof(*mapping->menu_info) * mapping->menu_count; + size = sizeof(*mapping->menu_info) * fls(mapping->menu_mask); map->menu_info = kmemdup(mapping->menu_info, size, GFP_KERNEL); if (map->menu_info == NULL) { kfree(map->name); diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 648dcd579e81..85aced173daa 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -79,7 +79,7 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain, goto free_map; } - map->menu_count = xmap->menu_count; + map->menu_mask = BIT_MASK(xmap->menu_count); break; default: diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index fff5c5c99a3d..0736b8815d79 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -254,7 +254,7 @@ struct uvc_control_mapping { u32 data_type; const struct uvc_menu_info *menu_info; - u32 menu_count; + unsigned long menu_mask; u32 master_id; s32 master_manual; From patchwork Fri Jun 17 23:56:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 582698 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 730EBCCA47E for ; Fri, 17 Jun 2022 23:56:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236372AbiFQX4g (ORCPT ); Fri, 17 Jun 2022 19:56:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379698AbiFQX4S (ORCPT ); Fri, 17 Jun 2022 19:56:18 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13CAC532C4 for ; Fri, 17 Jun 2022 16:56:17 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id g25so11327394ejh.9 for ; Fri, 17 Jun 2022 16:56:17 -0700 (PDT) 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=M05mXEEsCUtqw0Yy5vlYj0mxj1VIm7h4Q0ugvilopUQ=; b=MYqD5c5PmVQ3vLo24PfyqQTI2LSm3WSKDIOTiSWiP9/wPfKHfDPb1fhnamNLyk8lrG X+BqbEOmWkDWKnFgh+YtFObJEs1sJtOtI8Hcu9FPEGZ76enJivSLXaKZQ38x7QwqZ4Cl JDCEUWnhKJEZc7sNYYfcAeud+GtRx0Ge9DmOI= 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=M05mXEEsCUtqw0Yy5vlYj0mxj1VIm7h4Q0ugvilopUQ=; b=M4aESykbyALTl6Sye3oeHQTJaanpxraCbw5WGzTvimpB9Kmnuo5kiXEN33UCBJhoRm latq8w3U1mEsqeM1Sgc+k73DEVeUUERKqbpjckaMhCRBEOrdyBhBV/icoHbUIrT/djWJ Mdtc1ZEwnXyWA6Vkzxg2N/wIl2RzZx82DyEfSEnH8+k8fOdH6NNc0HVsPpeEMrTKQjO0 8qs4pbfvAxSejSUECKzPFeM1TfmR7jCer6Owlehs7gFunSv0EsjKuuIck53v2btyDXzR ISRL+BDcOcSQByyoNp8rUzy2rHfAFFaT00RBaoFXiQPDxFpx0RYTN7swMu2IK2hRTDIL vBog== X-Gm-Message-State: AJIora8fpetdCFtptg5qI3Vg8VGWSWWUxrgZjbx8qRYqs0i5x6WPWI+z rEpjFHA7NV1MfsDTHfxtFEJuxQ== X-Google-Smtp-Source: AGRyM1vueI4Kl7zXsaG4DyZPoxK7P8LQhQyg2HcRdwuyEtMZ41FPn5m0lBPJgAL3x2WdOsfAkUAjVQ== X-Received: by 2002:a17:906:9c82:b0:6e1:2c94:1616 with SMTP id fj2-20020a1709069c8200b006e12c941616mr11421842ejc.64.1655510175518; Fri, 17 Jun 2022 16:56:15 -0700 (PDT) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id z21-20020aa7d415000000b0043566884333sm1452538edq.63.2022.06.17.16.56.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 16:56:15 -0700 (PDT) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org, senozhatsky@chromium.org, yunkec@google.com Cc: Ricardo Ribalda Subject: [PATCH v8 4/9] media: uvcvideo: Use standard names for menus Date: Sat, 18 Jun 2022 01:56:05 +0200 Message-Id: <20220617235610.321917-5-ribalda@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220617235610.321917-1-ribalda@chromium.org> References: <20220617235610.321917-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Instead of duplicating the menu info, use the one from the core. Also, do not use extra memory for 1:1 mappings. Signed-off-by: Ricardo Ribalda Suggested-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_ctrl.c | 116 +++++++++++++++++++++---------- drivers/media/usb/uvc/uvc_v4l2.c | 80 ++++++++++++++++----- drivers/media/usb/uvc/uvcvideo.h | 3 +- include/uapi/linux/uvcvideo.h | 3 +- 4 files changed, 144 insertions(+), 58 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index a03714c3a265..1a3021a16b76 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -362,19 +362,31 @@ static const u32 uvc_control_classes[] = { V4L2_CID_USER_CLASS, }; -static const struct uvc_menu_info power_line_frequency_controls[] = { - { 0, "Disabled" }, - { 1, "50 Hz" }, - { 2, "60 Hz" }, - { 3, "Auto" }, -}; +static const int exposure_auto_mapping[] = { 2, 1, 4, 8 }; -static const struct uvc_menu_info exposure_auto_controls[] = { - { 2, "Auto Mode" }, - { 1, "Manual Mode" }, - { 4, "Shutter Priority Mode" }, - { 8, "Aperture Priority Mode" }, -}; +static u32 uvc_mapping_get_menu_value(struct uvc_control_mapping *mapping, + u32 idx) +{ + if (!test_bit(idx, &mapping->menu_mask)) + return 0; + + if (mapping->menu_mapping) + return mapping->menu_mapping[idx]; + + return idx; +} + +static const char +*uvc_mapping_get_menu_name(struct uvc_control_mapping *mapping, u32 idx) +{ + if (!test_bit(idx, &mapping->menu_mask)) + return NULL; + + if (mapping->menu_names) + return mapping->menu_names[idx]; + + return v4l2_ctrl_get_menu(mapping->id)[idx]; +} static s32 uvc_ctrl_get_zoom(struct uvc_control_mapping *mapping, u8 query, const u8 *data) @@ -523,9 +535,9 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { .offset = 0, .v4l2_type = V4L2_CTRL_TYPE_MENU, .data_type = UVC_CTRL_DATA_TYPE_BITMASK, - .menu_info = exposure_auto_controls, + .menu_mapping = exposure_auto_mapping, .menu_mask = - BIT_MASK(ARRAY_SIZE(exposure_auto_controls)), + GENMASK(ARRAY_SIZE(exposure_auto_mapping) - 1, 0), .slave_ids = { V4L2_CID_EXPOSURE_ABSOLUTE, }, }, { @@ -730,9 +742,8 @@ static const struct uvc_control_mapping uvc_ctrl_mappings_uvc11[] = { .offset = 0, .v4l2_type = V4L2_CTRL_TYPE_MENU, .data_type = UVC_CTRL_DATA_TYPE_ENUM, - .menu_info = power_line_frequency_controls, .menu_mask = - BIT_MASK(ARRAY_SIZE(power_line_frequency_controls) - 1), + GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_60HZ, 0), }, }; @@ -745,9 +756,8 @@ static const struct uvc_control_mapping uvc_ctrl_mappings_uvc15[] = { .offset = 0, .v4l2_type = V4L2_CTRL_TYPE_MENU, .data_type = UVC_CTRL_DATA_TYPE_ENUM, - .menu_info = power_line_frequency_controls, .menu_mask = - BIT_MASK(ARRAY_SIZE(power_line_frequency_controls)), + GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_AUTO, 0), }, }; @@ -970,13 +980,17 @@ static s32 __uvc_ctrl_get_value(struct uvc_control_mapping *mapping, s32 value = mapping->get(mapping, UVC_GET_CUR, data); if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) { - const struct uvc_menu_info *menu = mapping->menu_info; unsigned int i; - for (i = 1; BIT(i) <= mapping->menu_mask; ++i, ++menu) { + for (i = 1; BIT(i) <= mapping->menu_mask; ++i) { + u32 menu_value; + if (!test_bit(i, &mapping->menu_mask)) continue; - if (menu->value == value) { + + menu_value = uvc_mapping_get_menu_value(mapping, i); + + if (menu_value == value) { value = i; break; } @@ -1108,7 +1122,6 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, { struct uvc_control_mapping *master_map = NULL; struct uvc_control *master_ctrl = NULL; - const struct uvc_menu_info *menu; unsigned int i; memset(v4l2_ctrl, 0, sizeof(*v4l2_ctrl)); @@ -1153,11 +1166,15 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, v4l2_ctrl->maximum = fls(mapping->menu_mask) - 1; v4l2_ctrl->step = 1; - menu = mapping->menu_info; - for (i = 1; BIT(i) <= mapping->menu_mask; ++i, ++menu) { + for (i = 1; BIT(i) <= mapping->menu_mask; ++i) { + u32 menu_value; + if (!test_bit(i, &mapping->menu_mask)) continue; - if (menu->value == v4l2_ctrl->default_value) { + + menu_value = uvc_mapping_get_menu_value(mapping, i); + + if (menu_value == v4l2_ctrl->default_value) { v4l2_ctrl->default_value = i; break; } @@ -1250,11 +1267,11 @@ int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, int uvc_query_v4l2_menu(struct uvc_video_chain *chain, struct v4l2_querymenu *query_menu) { - const struct uvc_menu_info *menu_info; struct uvc_control_mapping *mapping; struct uvc_control *ctrl; u32 index = query_menu->index; u32 id = query_menu->id; + const char *name; int ret; memset(query_menu, 0, sizeof(*query_menu)); @@ -1276,11 +1293,10 @@ int uvc_query_v4l2_menu(struct uvc_video_chain *chain, goto done; } - menu_info = &mapping->menu_info[query_menu->index]; - if (mapping->data_type == UVC_CTRL_DATA_TYPE_BITMASK && (ctrl->info.flags & UVC_CTRL_FLAG_GET_RES)) { s32 bitmap; + u32 menu_value; if (!ctrl->cached) { ret = uvc_ctrl_populate_cache(chain, ctrl); @@ -1288,15 +1304,22 @@ int uvc_query_v4l2_menu(struct uvc_video_chain *chain, goto done; } + menu_value = uvc_mapping_get_menu_value(mapping, + query_menu->index); + bitmap = mapping->get(mapping, UVC_GET_RES, uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES)); - if (!(bitmap & menu_info->value)) { + if (!(bitmap & menu_value)) { ret = -EINVAL; goto done; } } - strscpy(query_menu->name, menu_info->name, sizeof(query_menu->name)); + name = uvc_mapping_get_menu_name(mapping, query_menu->index); + if (name) + strscpy(query_menu->name, name, sizeof(query_menu->name)); + else + ret = -EINVAL; done: mutex_unlock(&chain->ctrl_mutex); @@ -1783,7 +1806,7 @@ int uvc_ctrl_set(struct uvc_fh *handle, if (!test_bit(xctrl->value, &mapping->menu_mask)) return -EINVAL; - value = mapping->menu_info[xctrl->value].value; + value = uvc_mapping_get_menu_value(mapping, xctrl->value); /* Valid menu indices are reported by the GET_RES request for * UVC controls that support it. @@ -2229,12 +2252,28 @@ static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain, INIT_LIST_HEAD(&map->ev_subs); - size = sizeof(*mapping->menu_info) * fls(mapping->menu_mask); - map->menu_info = kmemdup(mapping->menu_info, size, GFP_KERNEL); - if (map->menu_info == NULL) { - kfree(map->name); - kfree(map); - return -ENOMEM; + if (mapping->menu_mapping && mapping->menu_mask) { + size = sizeof(mapping->menu_mapping[0]) * + fls(mapping->menu_mask); + map->menu_mapping = kmemdup(mapping->menu_mapping, size, + GFP_KERNEL); + if (!map->menu_mapping) { + kfree(map->name); + kfree(map); + return -ENOMEM; + } + } + if (mapping->menu_names && mapping->menu_mask) { + size = sizeof(mapping->menu_names[0]) * + fls(mapping->menu_mask); + map->menu_names = kmemdup(mapping->menu_names, size, + GFP_KERNEL); + if (!map->menu_names) { + kfree(map->menu_mapping); + kfree(map->name); + kfree(map); + return -ENOMEM; + } } if (map->get == NULL) @@ -2577,7 +2616,8 @@ static void uvc_ctrl_cleanup_mappings(struct uvc_device *dev, list_for_each_entry_safe(mapping, nm, &ctrl->info.mappings, list) { list_del(&mapping->list); - kfree(mapping->menu_info); + kfree(mapping->menu_names); + kfree(mapping->menu_mapping); kfree(mapping->name); kfree(mapping); } diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 85aced173daa..0ba1eb92df8e 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -25,6 +25,64 @@ #include "uvcvideo.h" +static int uvc_control_xu_2_mapping(struct uvc_control_mapping *map, + struct uvc_xu_control_mapping *xmap) +{ + char (*names)[UVC_MENU_NAME_LEN]; + unsigned int i; + u32 *mapping; + size_t size; + + /* Prevent excessive memory consumption, as well as integer + * overflows. + */ + if (xmap->menu_count == 0 || + xmap->menu_count > UVC_MAX_CONTROL_MENU_ENTRIES) + return -EINVAL; + + map->menu_mask = BIT_MASK(xmap->menu_count); + + size = xmap->menu_count * sizeof(*map->menu_mapping); + mapping = kzalloc(size, GFP_KERNEL); + if (!mapping) + return -ENOMEM; + + for (i = 0; i < xmap->menu_count ; i++) + if (copy_from_user(&mapping[i], &xmap->menu_info[i].value, + sizeof(mapping[i]))) { + kfree(mapping); + return -ENOMEM; + } + + map->menu_mapping = mapping; + + /* + * Always use the standard naming if available. + */ + if (v4l2_ctrl_get_menu(map->id)) + return 0; + + size = xmap->menu_count * sizeof(map->menu_names[0]); + names = kzalloc(size, GFP_KERNEL); + if (!names) { + kfree(mapping); + return -ENOMEM; + } + + for (i = 0; i < xmap->menu_count ; i++) { + /* sizeof(names[i]) - 1: to take care of \0 */ + if (copy_from_user(&names[i], &xmap->menu_info[i].name, + sizeof(names[i]) - 1)) { + kfree(names); + kfree(mapping); + return -ENOMEM; + } + } + map->menu_names = names; + + return 0; +} + /* ------------------------------------------------------------------------ * UVC ioctls */ @@ -32,7 +90,6 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain, struct uvc_xu_control_mapping *xmap) { struct uvc_control_mapping *map; - unsigned int size; int ret; map = kzalloc(sizeof(*map), GFP_KERNEL); @@ -63,23 +120,9 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain, break; case V4L2_CTRL_TYPE_MENU: - /* Prevent excessive memory consumption, as well as integer - * overflows. - */ - if (xmap->menu_count == 0 || - xmap->menu_count > UVC_MAX_CONTROL_MENU_ENTRIES) { - ret = -EINVAL; - goto free_map; - } - - size = xmap->menu_count * sizeof(*map->menu_info); - map->menu_info = memdup_user(xmap->menu_info, size); - if (IS_ERR(map->menu_info)) { - ret = PTR_ERR(map->menu_info); + ret = uvc_control_xu_2_mapping(map, xmap); + if (ret) goto free_map; - } - - map->menu_mask = BIT_MASK(xmap->menu_count); break; default: @@ -91,7 +134,8 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain, ret = uvc_ctrl_add_mapping(chain, map); - kfree(map->menu_info); + kfree(map->menu_names); + kfree(map->menu_mapping); free_map: kfree(map); diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 0736b8815d79..b702f1c8547b 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -253,7 +253,8 @@ struct uvc_control_mapping { enum v4l2_ctrl_type v4l2_type; u32 data_type; - const struct uvc_menu_info *menu_info; + const u32 *menu_mapping; + const char (*menu_names)[UVC_MENU_NAME_LEN]; unsigned long menu_mask; u32 master_id; diff --git a/include/uapi/linux/uvcvideo.h b/include/uapi/linux/uvcvideo.h index 8288137387c0..1b64b6aa40b5 100644 --- a/include/uapi/linux/uvcvideo.h +++ b/include/uapi/linux/uvcvideo.h @@ -36,9 +36,10 @@ UVC_CTRL_FLAG_GET_MAX | UVC_CTRL_FLAG_GET_RES | \ UVC_CTRL_FLAG_GET_DEF) +#define UVC_MENU_NAME_LEN 32 struct uvc_menu_info { __u32 value; - __u8 name[32]; + __u8 name[UVC_MENU_NAME_LEN]; }; struct uvc_xu_control_mapping { From patchwork Fri Jun 17 23:56:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 583093 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35C7AC433EF for ; Fri, 17 Jun 2022 23:56:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383444AbiFQX4e (ORCPT ); Fri, 17 Jun 2022 19:56:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382738AbiFQX4S (ORCPT ); Fri, 17 Jun 2022 19:56:18 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA5976129A for ; Fri, 17 Jun 2022 16:56:17 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id s12so11380464ejx.3 for ; Fri, 17 Jun 2022 16:56:17 -0700 (PDT) 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=+5NDpsm7942F8ZAmDt1/U3OvWgy4XsdEFDVSVEbFO9s=; b=nVc1TlGRzm+6zidFMBS9tzR7dsyWC9GpBonuqwNbiK1F8F0kYLpp++P6ranijiHZl6 z812PWhsI0Wgc3cdj7Ye2gLpye5PLOEQWMOWkNvpwc72n/wflQVNpgFJhswrm7QL/wc5 +56RwvzIfBf2LUgOv8PqSdkytqoJQXHO7yo5E= 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=+5NDpsm7942F8ZAmDt1/U3OvWgy4XsdEFDVSVEbFO9s=; b=QCN4ShGY04c6AIW6MgBT/eIk+n29xnDTItrQkTJlfZW9A3ownKpeW77rH0b/yLgj9P Lq+25EpoufdzQoaWcu/RrzSy610W1R0Rwh0mRkWPhXS08fGFGlCMr+7P6/N0ieG2Q8+P UiOB5rKQIInF7P3zoTcEYoUFExvf75Kh7M6MXLBkeIhB6bsV0Xb/ubq6bmMXVZF5gE7M kuCD7JfiW5iJ56IRwYFkygTRnTNw737V32nc2ze5O0A5sboufj899Otk47q7tpAgW+h5 trZjGf2SehBe1/mzdh7Jv2M973uSomFfX2zj4uTAWT24Zcfxa2VTId1jX6qWCglPQ6Mx CQ+A== X-Gm-Message-State: AJIora8TKxMW+pnu6lkDloC0zEJTI9uxboK+YhjCONfmrsflND1ZT+5p V2QrIQsNOzNZbuIachpof8FZ5A== X-Google-Smtp-Source: AGRyM1sjg2BOhrpcR/L31d1agtFPImts7SKC/0t9bER+Rl1EmJAIC4owlQjbMXcYeutidfMIL+I7vA== X-Received: by 2002:a17:906:c041:b0:718:c984:d9ee with SMTP id bm1-20020a170906c04100b00718c984d9eemr12078098ejb.722.1655510176399; Fri, 17 Jun 2022 16:56:16 -0700 (PDT) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id z21-20020aa7d415000000b0043566884333sm1452538edq.63.2022.06.17.16.56.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 16:56:16 -0700 (PDT) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org, senozhatsky@chromium.org, yunkec@google.com Cc: Ricardo Ribalda Subject: [PATCH v8 5/9] media: uvcvideo: Limit power line control for Quanta UVC Webcam Date: Sat, 18 Jun 2022 01:56:06 +0200 Message-Id: <20220617235610.321917-6-ribalda@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220617235610.321917-1-ribalda@chromium.org> References: <20220617235610.321917-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The device does not implement the power line control correctly. Add a corresponding control mapping override. Bus 001 Device 003: ID 0408:3090 Quanta Computer, Inc. USB2.0 HD UVC WebCam Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 239 Miscellaneous Device bDeviceSubClass 2 bDeviceProtocol 1 Interface Association bMaxPacketSize0 64 idVendor 0x0408 Quanta Computer, Inc. idProduct 0x3090 bcdDevice 0.04 iManufacturer 3 Quanta iProduct 1 USB2.0 HD UVC WebCam iSerial 2 0x0001 bNumConfigurations 1 Signed-off-by: Ricardo Ribalda Signed-off-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_driver.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 6c86faecbea2..ea8f0bb7a20c 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2643,6 +2643,24 @@ MODULE_PARM_DESC(timeout, "Streaming control requests timeout"); * Driver initialization and cleanup */ +static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited = { + .id = V4L2_CID_POWER_LINE_FREQUENCY, + .entity = UVC_GUID_UVC_PROCESSING, + .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, + .size = 2, + .offset = 0, + .v4l2_type = V4L2_CTRL_TYPE_MENU, + .data_type = UVC_CTRL_DATA_TYPE_ENUM, + .menu_mask = 0x6, +}; + +static const struct uvc_device_info uvc_ctrl_power_line_limited = { + .mappings = (const struct uvc_control_mapping *[]) { + &uvc_ctrl_power_line_mapping_limited, + NULL, /* Sentinel */ + }, +}; + static const struct uvc_device_info uvc_quirk_probe_minmax = { .quirks = UVC_QUIRK_PROBE_MINMAX, }; @@ -2673,6 +2691,15 @@ static const struct uvc_device_info uvc_quirk_force_y8 = { * though they are compliant. */ static const struct usb_device_id uvc_ids[] = { + /* Quanta USB2.0 HD UVC Webcam */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x0408, + .idProduct = 0x3090, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited }, /* LogiLink Wireless Webcam */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO, From patchwork Fri Jun 17 23:56:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 583092 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90F4CC43334 for ; Fri, 17 Jun 2022 23:56:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383403AbiFQX4h (ORCPT ); Fri, 17 Jun 2022 19:56:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382985AbiFQX4T (ORCPT ); Fri, 17 Jun 2022 19:56:19 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6581754195 for ; Fri, 17 Jun 2022 16:56:18 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id x5so8066124edi.2 for ; Fri, 17 Jun 2022 16:56:18 -0700 (PDT) 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=/jnwN8/6Kw9QXkQJc/fBYupKgOyKif9IBYZXUyF1l04=; b=LaHFGJ+vmI7vv9p7PqJtdxNqnbBKiL9mPRLDO8EhOI0iQb4IxPUSAwaflGgrMLqZuB 4zxG26tGBO/+MCqzmKBkXVqDw5lmgsRbF2KQbmmSOmCpSMT/2Lliq3MwwUlNE6OoGO9A ov/dWDMTltr38aasOErN1b1gGrvXNhm93rDLQ= 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=/jnwN8/6Kw9QXkQJc/fBYupKgOyKif9IBYZXUyF1l04=; b=YVuGpm60Nfbb71megibwKtMHXlq7ywq0tURIYXLe3iuskciKQpUXPVGboUShUhYGf8 0Rm/mEP9CaAi+4NV/qWWZjCIxnzFphtU39MuyUx05PfkULKKHoTfAwIlmAlyjMFKSJ4O BLqNNHZtIPdIVhWq1OB/99fHhtMHhNdya+SkWpLqGnBxwVWua07LP+U5TEcJ/qp0y7nA gs88rdwq8t1OeNdqtqeqWacTz9oC5WBNpAsciGaJkZM9h8jvwg6qgf923DKiPr1c0piv W0jExuiIYyvcIxRJloHvvBte+J8pFtlz/MlqQk/GQ6liFmg66s1NBNtIt2DzPTcxzkLJ Xmpg== X-Gm-Message-State: AJIora8aO+G1fHgSOkKJOsut6VgblWBzYIoRw3TgbU6qOgf3YcJgXnXu 87Pl+p/Pcr/FH/t6nOzSBB35UQ== X-Google-Smtp-Source: AGRyM1t/2FyFec2b3mG0O30RSB+BxB3GsPTeg3wEUIRsx8xxj7AhhzUhk7WcsvxUSz4DDhdSSDnThA== X-Received: by 2002:a05:6402:b8c:b0:435:6d4b:37e4 with SMTP id cf12-20020a0564020b8c00b004356d4b37e4mr1124518edb.109.1655510177029; Fri, 17 Jun 2022 16:56:17 -0700 (PDT) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id z21-20020aa7d415000000b0043566884333sm1452538edq.63.2022.06.17.16.56.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 16:56:16 -0700 (PDT) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org, senozhatsky@chromium.org, yunkec@google.com Cc: Ricardo Ribalda Subject: [PATCH v8 6/9] media: uvcvideo: Limit power line control for Chicony Easycamera Date: Sat, 18 Jun 2022 01:56:07 +0200 Message-Id: <20220617235610.321917-7-ribalda@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220617235610.321917-1-ribalda@chromium.org> References: <20220617235610.321917-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Two different Easycamera devices do not implement the power line control correctly. Add a corresponding control mapping override. Bus 001 Device 003: ID 04f2:b6ba Chicony Electronics Co., Ltd EasyCamera Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 239 Miscellaneous Device bDeviceSubClass 2 bDeviceProtocol 1 Interface Association bMaxPacketSize0 64 idVendor 0x04f2 Chicony Electronics Co., Ltd idProduct 0xb6ba bcdDevice 10.70 iManufacturer 3 Chicony Electronics Co.,Ltd. iProduct 1 EasyCamera iSerial 2 0001 bNumConfigurations 1 Bus 001 Device 003: ID 04f2:b746 Chicony Electronics Co., Ltd EasyCamera Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 239 Miscellaneous Device bDeviceSubClass 2 bDeviceProtocol 1 Interface Association bMaxPacketSize0 64 idVendor 0x04f2 Chicony Electronics Co., Ltd idProduct 0xb746 bcdDevice 97.57 iManufacturer 3 Chicony Electronics Co.,Ltd. iProduct 1 EasyCamera iSerial 2 0001 bNumConfigurations 1 Signed-off-by: Ricardo Ribalda Signed-off-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_driver.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index ea8f0bb7a20c..b22d083833ee 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2811,6 +2811,24 @@ static const struct usb_device_id uvc_ids[] = { .bInterfaceSubClass = 1, .bInterfaceProtocol = 0, .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_RESTRICT_FRAME_RATE) }, + /* Chicony EasyCamera */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x04f2, + .idProduct = 0xb6ba, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited }, + /* Chicony EasyCamera */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x04f2, + .idProduct = 0xb746, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited }, /* Alcor Micro AU3820 (Future Boy PC USB Webcam) */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO, From patchwork Fri Jun 17 23:56:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 582696 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74466C43334 for ; Fri, 17 Jun 2022 23:56:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383083AbiFQX4l (ORCPT ); Fri, 17 Jun 2022 19:56:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380778AbiFQX4a (ORCPT ); Fri, 17 Jun 2022 19:56:30 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76A8764D30 for ; Fri, 17 Jun 2022 16:56:19 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id y19so11354754ejq.6 for ; Fri, 17 Jun 2022 16:56:19 -0700 (PDT) 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=scX391f5blpJybIeBstalb8q/E+bG9Wz4cWkWDEOBNM=; b=WZ25gGhFa6piGaIAblr/7+DjWPKrFrCiYrhva2rjbsBCWQkVv8JG0shVuTPmm4a78Y 5oUqPdiKh8Iopv/haFtV9Fvxg20fPQHUVTN4P5TRhETIt+HM1tyVhbOBj+9kSl9MsSIW Fr0D36hT+p/cFaQkJgwyAKlW8wuNzg/LuTeQo= 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=scX391f5blpJybIeBstalb8q/E+bG9Wz4cWkWDEOBNM=; b=Q5BQIDolzrC4i7sCBlaAgVfP/gQHOtNAnmZ8eLLuF8aBYDHD/0s6241JCH95/9WeFE YZ8/TH6nlCZnzf8eqXPP3acRc7KXNFRWXDtbJQDjc3n/c7XkOuQ2JqsXNfWLPUZR9/zy +4L/MTI1qZ7GaaDsmVCh8C5llzWVUvL4Jxkt/EQbAvDUbK9Vlt6DLxUVSJpVFlDoZupb /rAJspELL/JBQSpZJl5W50hUd89vudMWJj58Udce6JX630IDznw3qjWDgOTUpgWcITNn VzHd1MkSvw2/I7Y7XPo9aT7EAQnNui8kNiWqkyTdd7e7izbWRfFM5vMzGPF8pnaS/F5R bviQ== X-Gm-Message-State: AJIora+JW7bk+1iQC/gvFAHZ7AxMyPGOWZJ5jKwR49iG0+XrslBiQK2d j3Zcgh2SK80iJdAkRli/9VUVKw== X-Google-Smtp-Source: AGRyM1vxunrryRLKRZB0tZ5E/wpySmxklz+mBU9GpldYHFwnCyJousJygAXN+QATaDteTf4N0dO/gg== X-Received: by 2002:a17:907:7da5:b0:711:c9cd:61e0 with SMTP id oz37-20020a1709077da500b00711c9cd61e0mr11257153ejc.443.1655510177994; Fri, 17 Jun 2022 16:56:17 -0700 (PDT) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id z21-20020aa7d415000000b0043566884333sm1452538edq.63.2022.06.17.16.56.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 16:56:17 -0700 (PDT) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org, senozhatsky@chromium.org, yunkec@google.com Cc: Ricardo Ribalda Subject: [PATCH v8 7/9] media: uvcvideo: Limit power line control for Chicony Easycamera Date: Sat, 18 Jun 2022 01:56:08 +0200 Message-Id: <20220617235610.321917-8-ribalda@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220617235610.321917-1-ribalda@chromium.org> References: <20220617235610.321917-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Another Chicony camera device does not implement the power line control correctly. Add a corresponding control mapping override. Bus 001 Device 003: ID 04f2:b5eb Chicony Electronics Co., Ltd EasyCamera Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 239 Miscellaneous Device bDeviceSubClass 2 bDeviceProtocol 1 Interface Association bMaxPacketSize0 64 idVendor 0x04f2 Chicony Electronics Co., Ltd idProduct 0xb5eb bcdDevice 90.45 iManufacturer 3 Chicony Electronics Co.,Ltd. iProduct 1 EasyCamera iSerial 2 0001 bNumConfigurations 1 Signed-off-by: Ricardo Ribalda Signed-off-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_driver.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index b22d083833ee..425520f06ce4 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2812,6 +2812,15 @@ static const struct usb_device_id uvc_ids[] = { .bInterfaceProtocol = 0, .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_RESTRICT_FRAME_RATE) }, /* Chicony EasyCamera */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x04f2, + .idProduct = 0xb5eb, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited }, + /* Chicony EasyCamera */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO, .idVendor = 0x04f2, From patchwork Fri Jun 17 23:56:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 583091 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE360CCA479 for ; Fri, 17 Jun 2022 23:56:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383584AbiFQX4k (ORCPT ); Fri, 17 Jun 2022 19:56:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383083AbiFQX4a (ORCPT ); Fri, 17 Jun 2022 19:56:30 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 742CD663C0 for ; Fri, 17 Jun 2022 16:56:20 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id me5so11382648ejb.2 for ; Fri, 17 Jun 2022 16:56:20 -0700 (PDT) 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=Re2uASyH1bxPGXC+tDXunHL1crXE28nbgdRRf+VAYZE=; b=dv/67EKp8F/1FkEq91cv5Q4jIKiMwID0vD2/5uqR9o4uUiOxZgHzT6LstOsaskky/J WGDN7EMDoaomFN0fBEMNM0Y7iwFhZ2O3saSdjwjQDm4GMNVpZXaUouVWWTj/A/WmUiOV +3Xac8jnuhxdMsIU/sQna8MF3t6CiPRYN1tOU= 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=Re2uASyH1bxPGXC+tDXunHL1crXE28nbgdRRf+VAYZE=; b=Fo6oq2qr26v6Vl7a+fmIrrCVwern0QbjwUQ+X+Cazmwum2wz+3/30EXHECYPB8b6Hj +vziHfAJM1XIAIF1manFflYWpDztbFm4tih0wqN5JE7UGqPOiTmt2KtRkdLo4WcSHTZ9 jcCi9KA0RKPR70k2WU0I6fIfG1xKSEAmDk7ecRI7NK2aKOCsyO0Qsb7dF+/0bh0KzJ6P fOclDdI94D91iFT0Z40QA1YLlHllUuTjMBQEwyEjzZkWg/vUsecvXat2+Vo0PikRWA1s f/HoDUSWfo/VSZph3PY4DjCdv4kiIP3qaFc2NOspYcT4WkWU0UyEXs9srO2JekNkJsXS 8y6A== X-Gm-Message-State: AJIora+gKaGXZFKX/xJN83QaszGFWZ4iHKtq+ejQpGrSK22f559JFOgQ hHTXE0LTivV/NbBDTHvrHEB9pw== X-Google-Smtp-Source: AGRyM1v8NNGOwt6zPLVre6A6tr6YO5BFOQ8XbrWj1JrPm0JWr/omugcPjs24nr/YT0hTh4LUZ699sA== X-Received: by 2002:a17:906:7c0c:b0:6f9:1fc:ebf3 with SMTP id t12-20020a1709067c0c00b006f901fcebf3mr11637584ejo.403.1655510179108; Fri, 17 Jun 2022 16:56:19 -0700 (PDT) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id z21-20020aa7d415000000b0043566884333sm1452538edq.63.2022.06.17.16.56.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 16:56:18 -0700 (PDT) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org, senozhatsky@chromium.org, yunkec@google.com Cc: Ricardo Ribalda Subject: [PATCH v8 8/9] media: uvcvideo: Limit power line control for Quanta cameras Date: Sat, 18 Jun 2022 01:56:09 +0200 Message-Id: <20220617235610.321917-9-ribalda@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220617235610.321917-1-ribalda@chromium.org> References: <20220617235610.321917-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Two more cameras do not implement the power line control correctly. Add a corresponding control mapping override. Bus 001 Device 003: ID 0408:4034 Quanta Computer, Inc. ACER HD User Facing Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.01 bDeviceClass 239 Miscellaneous Device bDeviceSubClass 2 bDeviceProtocol 1 Interface Association bMaxPacketSize0 64 idVendor 0x0408 Quanta Computer, Inc. idProduct 0x4034 bcdDevice 0.01 iManufacturer 1 Quanta iProduct 2 ACER HD User Facing iSerial 3 01.00.00 bNumConfigurations 1 Bus 001 Device 003: ID 0408:4030 Quanta Computer, Inc. HD User Facing Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.01 bDeviceClass 239 Miscellaneous Device bDeviceSubClass 2 bDeviceProtocol 1 Interface Association bMaxPacketSize0 64 idVendor 0x0408 Quanta Computer, Inc. idProduct 0x4030 bcdDevice 0.02 iManufacturer 1 Quanta iProduct 2 HD User Facing iSerial 3 01.00.00 bNumConfigurations 1 Signed-off-by: Ricardo Ribalda Signed-off-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_driver.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 425520f06ce4..387b85fa1998 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2700,6 +2700,24 @@ static const struct usb_device_id uvc_ids[] = { .bInterfaceSubClass = 1, .bInterfaceProtocol = 0, .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited }, + /* Quanta USB2.0 HD UVC Webcam */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x0408, + .idProduct = 0x4030, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 1, + .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited }, + /* Quanta USB2.0 HD UVC Webcam */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x0408, + .idProduct = 0x4034, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited }, /* LogiLink Wireless Webcam */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO, From patchwork Fri Jun 17 23:56:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 582697 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59431C43334 for ; Fri, 17 Jun 2022 23:56:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234678AbiFQX4i (ORCPT ); Fri, 17 Jun 2022 19:56:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383440AbiFQX4b (ORCPT ); Fri, 17 Jun 2022 19:56:31 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C88866AF0 for ; Fri, 17 Jun 2022 16:56:22 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id h23so11327630ejj.12 for ; Fri, 17 Jun 2022 16:56:22 -0700 (PDT) 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=smgH2pDBx1ofaZrM152FsxaiSpM+uoxslxM+FEyW34c=; b=BeEQ4TJ+StpwEeRKtNhqEWyR6951KbaWIfursLBbX0/XJas5D2wzyKEk+BS1ToHLhM 1yea3fbBN1B05sTYEYC0j/VfjOmSdYMqyx6WBpE3PX4Z0Biddp9iTb4t/I3JF47MWy4u x8QhELQHJrISgpvWPiEKiKy7EQUp1igOTHMzw= 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=smgH2pDBx1ofaZrM152FsxaiSpM+uoxslxM+FEyW34c=; b=scevGXBi/3+lV6enVu9p7K/Qq56OPHAUEbt9HfriC4Sm/eDl8sVKjcnYjSRberWw4x JpJlq6lmmTLpCRZyMsLeKtq+qegZtEUKqOd29L5VwMahECQcSInY24wiHePgKNJ0ap6p P3ocrDko85YwTbweb/0dS6MMi99lmaHavRgEpbromoDMWSccYUXoYFPCUVyNMhjqyGqr z+S36wJuo2YWJVywWVibVbUeGAghs7FtX1DCQS8yRlNoHdphpuyTEpNalJigthLJkq0+ DcK69WgBE9kzFZIsAk2LgK/OgjDnW8KLZD7UYFJ5mzgPXIk899BkzJNUmQTTuohjxEOD Ws8Q== X-Gm-Message-State: AJIora/NTdHMN0+xuN/vnGhhQww/962e8dRghCz5HH3H1B8f9slU31Pp JEZLhYYxJam2tIiPrsq8Y/fauA== X-Google-Smtp-Source: AGRyM1usF0zfm/ieUT9r1lbPRPzma4aEocNyIUPWHG/uKyyHfOm2qkqIawRoshKy0ZEENfPGxPRgyw== X-Received: by 2002:a17:907:1dd1:b0:715:73d2:df1f with SMTP id og17-20020a1709071dd100b0071573d2df1fmr11536181ejc.46.1655510180195; Fri, 17 Jun 2022 16:56:20 -0700 (PDT) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id z21-20020aa7d415000000b0043566884333sm1452538edq.63.2022.06.17.16.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 16:56:19 -0700 (PDT) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org, senozhatsky@chromium.org, yunkec@google.com Cc: Ricardo Ribalda Subject: [PATCH v8 9/9] media: uvcvideo: Limit power line control for Acer EasyCamera Date: Sat, 18 Jun 2022 01:56:10 +0200 Message-Id: <20220617235610.321917-10-ribalda@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220617235610.321917-1-ribalda@chromium.org> References: <20220617235610.321917-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The device does not implement the power line control correctly. Add a corresponding control mapping override. Bus 001 Device 003: ID 5986:1172 Acer, Inc EasyCamera Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 239 Miscellaneous Device bDeviceSubClass 2 bDeviceProtocol 1 Interface Association bMaxPacketSize0 64 idVendor 0x5986 Acer, Inc idProduct 0x1172 bcdDevice 56.04 iManufacturer 3 Bison iProduct 1 EasyCamera iSerial 2 bNumConfigurations 1 Signed-off-by: Ricardo Ribalda Signed-off-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_driver.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 387b85fa1998..e037d46b958e 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -3240,6 +3240,15 @@ static const struct usb_device_id uvc_ids[] = { .bInterfaceSubClass = 1, .bInterfaceProtocol = 0, .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_FORCE_BPP) }, + /* Acer EasyCamera */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x5986, + .idProduct = 0x1172, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited }, /* Intel RealSense D4M */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,