From patchwork Mon Jun 10 23:09:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13692555 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23F261514DE for ; Mon, 10 Jun 2024 23:09:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718060997; cv=none; b=hE0/9+UmvOB3sNQyOmS7aQkkbU4qIUI0t8UMBj7GBM45oaxL9ZNNyEsyDEXoqU9axvPP+Zck0XFJpTHskL/BE8bk1nMtLtbmauSeTWdeGFwwcly5BTmis1pYq3vYNT1eCseuWYLqCoVe/LV66L6m+U6MtVelcXSFG8NZmfzuj8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718060997; c=relaxed/simple; bh=mmRiog2A0uIil7zCDWbDB/RKRQKrz+dasll7tr7FLWQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pl+y4Pw+LPlWV+evYfBBbI2l/9FUTuCG45DjaC5J6uPqwA3VnbswrH7dA8S6kDn5xrUsR0VXoFOn4ByQLBGmbiFiAu1/jWht/aebTL66Qcgct0oIoFDtJjkB/3ywpCPAPgW5Rc69SoCoQ+QF/z8RzDVDOerx1jee2/46v8ZyqLY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=MLHWCuCh; arc=none smtp.client-ip=209.85.219.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="MLHWCuCh" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-6b08857f3b8so3296756d6.2 for ; Mon, 10 Jun 2024 16:09:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718060995; x=1718665795; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Vu2oMVYEjcsFAa+zF1RhnzGy00bzVv1v7T1Od5qxCIk=; b=MLHWCuChNAbVxsAqb/olKWGzXJ5m80Ww2uKLaIjEhulDndbnxldWgzQDQiGiSUpyOa bNshPVMgKl8ljlR0WdRvSCFlDcPM3gZF2h2ogHjqRR10ahvU2qbiSZvMbc+NtUWYKQH5 5/23EfXkGFn4YVZCnJqU+Ng1Xe9T3ayNs90uQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718060995; x=1718665795; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vu2oMVYEjcsFAa+zF1RhnzGy00bzVv1v7T1Od5qxCIk=; b=g4lL3rDfg+hfVV2850isvXla2mh+j8dSpZEdfdYELUIVgEVaN4fl8mWd4rWCeODMQ9 iF7UZgdrXS5omuEmKyaTMlUlD0uGu18VofeOk0LiIKCZ8cQmhzaYwHV/qpiav14D3Amp 0lKsGQYO2ll0nvj3+zqLbDasv8J77bGKFAYAotbQhBezIHkaolDGEdQGrstpCztlUMak xAa/w4H08laa+g+KdlxmNuAQpIzxs0jWZUNFYXDdK7qF9Pmp8Kkk6ylPQU21BsZs1YG5 p7t8gnoCIt9sGzNpRGRBJAkTUqEFzy2clfDKL8wpDtRyvWIoDSgeAc2/w4aSxS0okA3r 2Zvw== X-Forwarded-Encrypted: i=1; AJvYcCW7AkHJG4mQS/Dp77jRLAcXXd1U5Uq6Rh8h7bGP6y15biX7T6e6vCmnIrVqK/FMzR52EC2RUraP5DJS9PzoAE9u6tbMcoDIoqkiQqA= X-Gm-Message-State: AOJu0YzkyjEcFSQsImNIQqT9PJSO7uLGenUvoDici4pDstiPBuJ0Inl6 zUWom7Vh/Op4V7q6Vf5HulQWg/TyEP/4q2fTkCbDA4fdCnLrP40rVB8QDNB7rw== X-Google-Smtp-Source: AGHT+IFSMLwcHePmJYpuKv8V2B4L07cpCeuaHyXPO3dO9KZYt9s0uHdtA5t5lc2zXRfrWt6NJanmiQ== X-Received: by 2002:a05:6214:2dc8:b0:6b0:7afb:5c85 with SMTP id 6a1803df08f44-6b07afb6026mr69292796d6.3.1718060995102; Mon, 10 Jun 2024 16:09:55 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b06519d521sm35256946d6.65.2024.06.10.16.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 16:09:54 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 10 Jun 2024 23:09:52 +0000 Subject: [PATCH v2 1/7] media: uvcvideo: Allow custom control mapping Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240610-billion-v2-1-38e861475f85@chromium.org> References: <20240610-billion-v2-0-38e861475f85@chromium.org> In-Reply-To: <20240610-billion-v2-0-38e861475f85@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab Cc: Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 Some advanced controls might not be completely implemented by vendors. If the controls are a enumeration, UVC does not gives a way to probe what is implemented and what is not. Let's create a new callback function where heuristics can be implemented to detect what is implemented and what not. Reviewed-by: Sergey Senozhatsky Signed-off-by: Ricardo Ribalda Reviewed-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_ctrl.c | 10 +++++++++- drivers/media/usb/uvc/uvcvideo.h | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index e59a463c2761..44ec185a8c8b 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -2360,7 +2360,7 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl, /* * Add a control mapping to a given control. */ -static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain, +static int __uvc_ctrl_add_mapping_to_list(struct uvc_video_chain *chain, struct uvc_control *ctrl, const struct uvc_control_mapping *mapping) { struct uvc_control_mapping *map; @@ -2434,6 +2434,14 @@ static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain, return -ENOMEM; } +static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain, + struct uvc_control *ctrl, const struct uvc_control_mapping *mapping) +{ + if (mapping && mapping->add_mapping) + return mapping->add_mapping(chain, ctrl, mapping); + return __uvc_ctrl_add_mapping_to_list(chain, ctrl, mapping); +} + int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, const struct uvc_control_mapping *mapping) { diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 6fb0a78b1b00..fa0396dd5b35 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -84,7 +84,9 @@ struct gpio_desc; struct sg_table; +struct uvc_control; struct uvc_device; +struct uvc_video_chain; /* * TODO: Put the most frequently accessed fields at the beginning of @@ -123,6 +125,9 @@ struct uvc_control_mapping { s32 master_manual; u32 slave_ids[2]; + int (*add_mapping)(struct uvc_video_chain *chain, + struct uvc_control *ctrl, + const struct uvc_control_mapping *mapping); s32 (*get)(struct uvc_control_mapping *mapping, u8 query, const u8 *data); void (*set)(struct uvc_control_mapping *mapping, s32 value, From patchwork Mon Jun 10 23:09:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13692557 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09154152176 for ; Mon, 10 Jun 2024 23:09:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718060998; cv=none; b=H0bXcZLP/B+9nRSNfQH5b4iYtAaP7E0iRs4SHgWoAdmVHFZit9X5Ydgq+GRyhBvPdyka0iA4ZM8UEZmXZpHOxcdOjjCdqtp4g8cN/x1z+2e07gC9peYEbPD7D3TOddHeynbFfrL0UpdXPD7sG5lW0O2iAMgtMiY+R90Ol6Kf61Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718060998; c=relaxed/simple; bh=5KtcvntcMUZkACMFk5rU2ybB+ZMYW6Y9YCbSQeSS2kI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EFX12nXgugvAPqMw3OZztAb1ii1KUjTWaRNtWU35ebtxrL78Cub7QbMJQcibBR6USA9lgn7wo8mHSCYF/bHekq/SATCBFFVkNq5bbvqZACYo0f37dFxVPMTKAznh3SntiMQzjAXM/bVPgUqe1l7SB4Abl0QjCLrCNNrKiK6hHtI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Mc7Npuc6; arc=none smtp.client-ip=209.85.222.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Mc7Npuc6" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-795dc9e0d15so78243885a.1 for ; Mon, 10 Jun 2024 16:09:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718060996; x=1718665796; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=AbM4kNTJNPzmGxmhqRn7T4MAUpw44gO0YyJKcWOn6hw=; b=Mc7Npuc6hM3Sm4YInJw6f/eWbK+ZllD/PKntLxkuLKT2k307yJQTF5fqSOLSVWr8hR BdiCpk5OevTGPDiXrKZfjPOytON3ZrCbC/J6xvBd58HbZhT3Cr0gbYJkvrzuy1ZIBhqZ tttuvZiuDttG2r8Sn8/SwPRPUXxarZ2V1u5y8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718060996; x=1718665796; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AbM4kNTJNPzmGxmhqRn7T4MAUpw44gO0YyJKcWOn6hw=; b=dHuJAe/qAXTW87cbN0LnHaMCf+CYzpjzrddiqJSRDqUj6baq7OnngcEIs+vXdpuKsl BjeQrmpww6N1Pd6VI9GieHZp7eR1U/xhi0gaxjIp4mQBev0ictQYgt+NBOPmD5ZdOdSY NYbekPxEJ/E3tM9rkqK9AjwssByQDWMQpDprpMmUUuIYzJ/uT1By6YICd4WWxy0oNLLN W4NVzuwiJTrWdQRJw5/1cGvbOeoRCtGZ64oXl8Tw5bxAHULQme2lBC3sIvzIFudi/gb7 TypwMdlzvkTiHNUnN+rUwzxTSwRo34Q9WWQPkkpX/jN0mqiWM8jMVqeg5QEa8Jiwe65w Y7nQ== X-Forwarded-Encrypted: i=1; AJvYcCXrPkEDx4ismiEvleuVDZbkGX6G4eG4ZsMZy6Hq4HbLLlQ9IWQJIJP5aZRnlEBbwzMEPXFtQolOeKvtHFT/AyuOASKMKO5ZSlVxTIg= X-Gm-Message-State: AOJu0YyOQhHT5VmBwv3qseY4wOUezw121yWNAkVMN3gXoZyLC6MPEp8s 2EPoCtmSGaszZYTaxouf9chlhw/KVdvc4Tg5tDysORTsb1Gdj+aYYZ82/gYa7Q== X-Google-Smtp-Source: AGHT+IH2h0TqAZAmA0RqqwWg+HjA1/ZYxta7QDd7AU9qer6HLjPF9Oj/kvRaWHlK8xVe5Q9cgLSkww== X-Received: by 2002:a05:6214:524a:b0:6b0:6b57:4c57 with SMTP id 6a1803df08f44-6b06b574fbbmr88218606d6.1.1718060995938; Mon, 10 Jun 2024 16:09:55 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b06519d521sm35256946d6.65.2024.06.10.16.09.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 16:09:55 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 10 Jun 2024 23:09:53 +0000 Subject: [PATCH v2 2/7] media: uvcvideo: Refactor Power Line Frequency limit selection Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240610-billion-v2-2-38e861475f85@chromium.org> References: <20240610-billion-v2-0-38e861475f85@chromium.org> In-Reply-To: <20240610-billion-v2-0-38e861475f85@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab Cc: Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 Move the PLF mapping logic to its own function. This patch does not introduce any new functionality to the logic, it is just a preparation patch. Reviewed-by: Sergey Senozhatsky Signed-off-by: Ricardo Ribalda Reviewed-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_ctrl.c | 93 ++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 38 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 44ec185a8c8b..d82cfc56dfd5 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -459,6 +459,56 @@ static void uvc_ctrl_set_rel_speed(struct uvc_control_mapping *mapping, data[first+1] = min_t(int, abs(value), 0xff); } +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 = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_60HZ, + V4L2_CID_POWER_LINE_FREQUENCY_50HZ), +}; + +const struct uvc_control_mapping uvc_ctrl_power_line_mapping_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_mask = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_60HZ, + V4L2_CID_POWER_LINE_FREQUENCY_DISABLED), +}; + +static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_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_mask = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_AUTO, + V4L2_CID_POWER_LINE_FREQUENCY_DISABLED), +}; + +static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain, + struct uvc_control *ctrl, const struct uvc_control_mapping *mapping); + +static int uvc_ctrl_add_plf_mapping(struct uvc_video_chain *chain, + struct uvc_control *ctrl, const struct uvc_control_mapping *mapping) +{ + if (chain->dev->uvc_version < 0x150) + return __uvc_ctrl_add_mapping(chain, ctrl, + &uvc_ctrl_power_line_mapping_uvc11); + + return __uvc_ctrl_add_mapping(chain, ctrl, + &uvc_ctrl_power_line_mapping_uvc15); +} + static const struct uvc_control_mapping uvc_ctrl_mappings[] = { { .id = V4L2_CID_BRIGHTNESS, @@ -748,51 +798,18 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, .data_type = UVC_CTRL_DATA_TYPE_BOOLEAN, }, -}; - -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 = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_60HZ, - V4L2_CID_POWER_LINE_FREQUENCY_50HZ), -}; - -const struct uvc_control_mapping uvc_ctrl_power_line_mapping_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_mask = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_60HZ, - V4L2_CID_POWER_LINE_FREQUENCY_DISABLED), + { + .entity = UVC_GUID_UVC_PROCESSING, + .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, + .add_mapping = uvc_ctrl_add_plf_mapping, + }, }; static const struct uvc_control_mapping *uvc_ctrl_mappings_uvc11[] = { - &uvc_ctrl_power_line_mapping_uvc11, NULL, /* Sentinel */ }; -static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_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_mask = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_AUTO, - V4L2_CID_POWER_LINE_FREQUENCY_DISABLED), -}; - static const struct uvc_control_mapping *uvc_ctrl_mappings_uvc15[] = { - &uvc_ctrl_power_line_mapping_uvc15, NULL, /* Sentinel */ }; From patchwork Mon Jun 10 23:09:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13692558 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5974F152515 for ; Mon, 10 Jun 2024 23:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718060999; cv=none; b=DMwQgFX25/ljad4ogfr2Oq7Y/YAz2j5zhtHl2l9YkihZa8ciXKpNepAw2ulQ15bc7F3hY8corEPAntDQqTktkWX3FXf/OuJVEPY4ooqMZq76Z3CGfidFqXwRQJkUcfb600EjrTe1by93lWGgTF9gBFOu1K9Qj+1Dg6S3KUhjgzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718060999; c=relaxed/simple; bh=j8MR+0Zdp3uWVc1WjRQyCRAas8P1RT3ZjAZLRfXEnB4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PInwHUX2SC+NpRXASMbxYB1YjPbr8bd1wnRbgEx6Z8S8TNoNw6GXgdPbUfSZAwED1ZHfV8dYKZDrboP19H2Hfx0CAMgZcOdovhozZbDdbR7Q+C1UGeD0xHDUH8HEg6XBTihNOg492UqqmPSOM7EqWn6/KWq8kkpqbWdko1p+0zI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Lm6+NkQk; arc=none smtp.client-ip=209.85.128.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Lm6+NkQk" Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-627ea4e0becso54291677b3.0 for ; Mon, 10 Jun 2024 16:09:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718060997; x=1718665797; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ggXYPXXJz9pqRmEYjjKEnuceXrydB78eIdBvang4V2c=; b=Lm6+NkQkQqOkqRcP/pR4gBk95xatY6QxI3pmTLlh3/4DviH4OU3zkEtOjcHyt01cos PtVCs1GQcMiiKNJFwbUw1MYGg0YVWi4+ImyQ095Et+fIpkEFeEUAGbbtDGOK9/3vsN+J f6bIZ0yEioVCLYKnblLSNCR/DTJ/w3MlHlRpE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718060997; x=1718665797; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ggXYPXXJz9pqRmEYjjKEnuceXrydB78eIdBvang4V2c=; b=UbqVGMKqKNaYQsa2h5tLvOuYmN8OTEvEs+aqy4iGrwX/fB1czgYT8FnqIJr7TF3cjZ AYkZiOUL2LCIC6RaBw/ZNMAOvKp5I8cQSMZ/F9M/WDCwyB93Zmpsa3RSQb0dkofi2gw0 srQ/UovCIhXPBy0tXQ4IZD1Kb9/cm0q0HgDRoRm9xnbeg0KCiNOupQbOdYu+xn21Db5x ENIGtvLDQ7x0Xq/fLdHmCT0udX639/GGbxqvNzOXVxZNVtV2Yy601zEJ6VsgAWYbh9WS 2zyHmNrb0WUb3kzaudXikpvdopu05eTbX/9oMthNxkJzD+tHpPNeYREXvgzXyq9VEr5J GudQ== X-Forwarded-Encrypted: i=1; AJvYcCUUBQTIBJcWVyc3StVx1/ek+66TnyooTb3UqJuY/uiJWDVJjQ5+pm++MtxE5mah0AFiY5MPVmIh1SWeRU0DdhJwrc+ofRFRQKyioWQ= X-Gm-Message-State: AOJu0YyG/dC47h5yRazMOdkTr5gnT9lGunWbsD9WzjyIesUicQt+hEui PjxnQXkWWCtZK1Dx/6KaJjHtBnmVabd3Whzp1ML4RM1CDlayrRh77hNch3v52w== X-Google-Smtp-Source: AGHT+IFkwiQpPmkIhbjE6EIVr7NDSN5urKP15cf7bAX2HFwkUmXks8NU9qkevmNJ0yGvGrwYb+4/Ww== X-Received: by 2002:a0d:d851:0:b0:618:95a3:70b9 with SMTP id 00721157ae682-62cd565129cmr109244957b3.36.1718060997387; Mon, 10 Jun 2024 16:09:57 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b06519d521sm35256946d6.65.2024.06.10.16.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 16:09:56 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 10 Jun 2024 23:09:54 +0000 Subject: [PATCH v2 3/7] media: uvcvideo: Probe the PLF characteristics Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240610-billion-v2-3-38e861475f85@chromium.org> References: <20240610-billion-v2-0-38e861475f85@chromium.org> In-Reply-To: <20240610-billion-v2-0-38e861475f85@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab Cc: Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 The UVC 1.5 standard defines 4 values for the PLF control: Off, 50Hz, 60Hz and Auto. But it does not clearly define if all the values must be implemented or not. Instead of just using the UVC version to determine what the PLF control can do, probe it. Reviewed-by: Sergey Senozhatsky Signed-off-by: Ricardo Ribalda Reviewed-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_ctrl.c | 52 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index d82cfc56dfd5..5b77ac308c84 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -495,18 +495,60 @@ static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc15 = { V4L2_CID_POWER_LINE_FREQUENCY_DISABLED), }; -static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain, +static int __uvc_ctrl_add_mapping_to_list(struct uvc_video_chain *chain, struct uvc_control *ctrl, const struct uvc_control_mapping *mapping); static int uvc_ctrl_add_plf_mapping(struct uvc_video_chain *chain, struct uvc_control *ctrl, const struct uvc_control_mapping *mapping) { + const struct uvc_control_mapping *out_mapping = + &uvc_ctrl_power_line_mapping_uvc11; + u8 *buf __free(kfree) = NULL; + u8 init_val; + int ret; + + buf = kmalloc(sizeof(*buf), GFP_KERNEL); + if (!buf) + return -ENOMEM; + + /* Save the default PLF value, so we can restore it. */ + ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, ctrl->entity->id, + chain->dev->intfnum, ctrl->info.selector, + buf, sizeof(*buf)); + /* If we cannot read the control skip it. */ + if (ret) + return ret; + init_val = *buf; + + /* If PLF value cannot be set to off, it is limited. */ + *buf = V4L2_CID_POWER_LINE_FREQUENCY_DISABLED; + ret = uvc_query_ctrl(chain->dev, UVC_SET_CUR, ctrl->entity->id, + chain->dev->intfnum, ctrl->info.selector, + buf, sizeof(*buf)); + if (ret) + return __uvc_ctrl_add_mapping_to_list(chain, ctrl, + &uvc_ctrl_power_line_mapping_limited); + + /* UVC 1.1 does not define auto, we can exit. */ if (chain->dev->uvc_version < 0x150) - return __uvc_ctrl_add_mapping(chain, ctrl, - &uvc_ctrl_power_line_mapping_uvc11); + goto end; + + /* Check if the device supports auto. */ + *buf = V4L2_CID_POWER_LINE_FREQUENCY_AUTO; + ret = uvc_query_ctrl(chain->dev, UVC_SET_CUR, ctrl->entity->id, + chain->dev->intfnum, ctrl->info.selector, + buf, sizeof(*buf)); + if (!ret) + out_mapping = &uvc_ctrl_power_line_mapping_uvc15; + +end: + /* Restore initial value and add mapping. */ + *buf = init_val; + uvc_query_ctrl(chain->dev, UVC_SET_CUR, ctrl->entity->id, + chain->dev->intfnum, ctrl->info.selector, + buf, sizeof(*buf)); - return __uvc_ctrl_add_mapping(chain, ctrl, - &uvc_ctrl_power_line_mapping_uvc15); + return __uvc_ctrl_add_mapping_to_list(chain, ctrl, out_mapping); } static const struct uvc_control_mapping uvc_ctrl_mappings[] = { From patchwork Mon Jun 10 23:09:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13692559 Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86C2D1527AC for ; Mon, 10 Jun 2024 23:09:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718061001; cv=none; b=VrJGGmSaNkcrQ5eLrExyqFveT4cgYeDdjuJ8kNL8c6W2ulAoV3I95BwxJ8ZPJXKvX+sqSpLzzr1J/Y1CtXFLl21HASyXLbJi2aM3e43o0atUesfWnpKDS296FN4+oC/Mule1XoEW6oa/7NS0gA967c9FT2CnW8EogFiQzz8bvtM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718061001; c=relaxed/simple; bh=iTfdC4btNMwXyVr7bat6V5XQY3nrpXEk8t37YJiWujI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Q+w4zSCpPDng4q8hvw5CvbLFQfRQZ69eQNh1fQ8HFbQakp7msQrG/LenA+uxa83YfrskrQAB2ehJC0B6+rIOv2RtJzxIqCDILu9n5KcJjF+bcfNLgCZO/EC2O/MCcWA0yeJw7JhNVgbv37A1jJRs+69ubcUHP808YnVTjn+wbGM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=gM2GEUK4; arc=none smtp.client-ip=209.85.161.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="gM2GEUK4" Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-5bafcb42d28so235391eaf.0 for ; Mon, 10 Jun 2024 16:09:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718060998; x=1718665798; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=KRxFROHQ2dCXosAMLsg5w59iJitkjf3IVXz7c5nb/d0=; b=gM2GEUK4FluZMl+dKKSxY+zCkEcHDP1Cyeibd3YDwfrl4rnMWMxd0U/Ul5bueVvXnx kcP2v4sHFM7Xy5sKmnzKJh69HPCOUz/RkS2iJ+I8h7CSCIMwsKIjDumUR7FhkRZvy+kj pS8vg+9nSpr92rsFJv616ruhuqSsYOgAKXyKA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718060998; x=1718665798; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KRxFROHQ2dCXosAMLsg5w59iJitkjf3IVXz7c5nb/d0=; b=KqjBNtmR0SFOkFFbr4yaq78QTs0SgOiLxkw0myG99vv9uxuzlBrksAB62kxpQjuoCO A91mNqfSR4716+tEV3ltU1qvhiAIaWeeEUTg5KVyS+VutdW+BxdXy9+DOIg+Q6q7UqaP l0VYSKpWkiw8v0rLtKcklgr9gARxsxdKGAc2jz+umkHHa/+8GrE2jwYab45OzBCjTDKF OqQIYJ5oSz433J1jJY4LQK9YdlS+p/b2xwpjUWTKrVkHTVRVLjiyCJgBCUXF0j8Ist2E zal3Rgdaox6gv8BPRoCJsP0Lr4JOvt2JW8zO8CA8ARi2XieeTcrJtssd+dp1+S6+jM27 L2Yw== X-Forwarded-Encrypted: i=1; AJvYcCVkayfHhiNDSFfxx3Ts5iBBsLpwX4XjZMyCnVAZT5ymdshfITJkdzhV9y/YdajoDauP3jcNhBPnhfd9EizD0jq7HHGjAfV7u+lCXAg= X-Gm-Message-State: AOJu0Yyn24Mvor5f1xkoiQ/tuOtsLoK43JsDI8RTeCp4xvO4yrop+vLj zpCrsnhend0ONVRobgVK5nROZMWL+SVxT/aOu6R+Mzej0CEZzzoJaW63fenv3Q== X-Google-Smtp-Source: AGHT+IFmlKoKWOJj2qo73Wl0NsPia9kSU0phIwncQtRQ3A99zhJAaMJL4Mw8zF7B8tzfmU8kOru5aA== X-Received: by 2002:a05:6358:5294:b0:19f:1ce8:dc0 with SMTP id e5c5f4694b2df-19f1fe13fa9mr1605477555d.12.1718060998529; Mon, 10 Jun 2024 16:09:58 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b06519d521sm35256946d6.65.2024.06.10.16.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 16:09:57 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 10 Jun 2024 23:09:55 +0000 Subject: [PATCH v2 4/7] media: uvcvideo: Cleanup version-specific mapping Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240610-billion-v2-4-38e861475f85@chromium.org> References: <20240610-billion-v2-0-38e861475f85@chromium.org> In-Reply-To: <20240610-billion-v2-0-38e861475f85@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab Cc: Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 We do not have more version specific mappings. Let's remove this code for now. It can be easily reverted later if needed. Reviewed-by: Laurent Pinchart Reviewed-by: Sergey Senozhatsky Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 5b77ac308c84..efc46f53ac81 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -847,14 +847,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, }; -static const struct uvc_control_mapping *uvc_ctrl_mappings_uvc11[] = { - NULL, /* Sentinel */ -}; - -static const struct uvc_control_mapping *uvc_ctrl_mappings_uvc15[] = { - NULL, /* Sentinel */ -}; - /* ------------------------------------------------------------------------ * Utility functions */ @@ -2656,7 +2648,6 @@ static void uvc_ctrl_prune_entity(struct uvc_device *dev, static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, struct uvc_control *ctrl) { - const struct uvc_control_mapping **mappings; unsigned int i; /* @@ -2721,18 +2712,6 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, ctrl->info.selector == mapping->selector) __uvc_ctrl_add_mapping(chain, ctrl, mapping); } - - /* Finally process version-specific mappings. */ - mappings = chain->dev->uvc_version < 0x0150 - ? uvc_ctrl_mappings_uvc11 : uvc_ctrl_mappings_uvc15; - - for (i = 0; mappings[i]; ++i) { - const struct uvc_control_mapping *mapping = mappings[i]; - - if (uvc_entity_match_guid(ctrl->entity, mapping->entity) && - ctrl->info.selector == mapping->selector) - __uvc_ctrl_add_mapping(chain, ctrl, mapping); - } } /* From patchwork Mon Jun 10 23:09:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13692560 Received: from mail-oo1-f43.google.com (mail-oo1-f43.google.com [209.85.161.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 208CA153581 for ; Mon, 10 Jun 2024 23:10:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718061002; cv=none; b=ROTrZjS+dpegjzNVIrgN3u6YSJmo9mQR8D7I9LTalX30jbxiMDOjvTBMPGxf9iYvjyM/gY0t3LUcdVbeQJUZJwY6IP/T7DGs56Td+yaQ2knOmlxP/ludNn/Q5fAfaZ+ouoKX+uyaSxS5T9cd3qjGzWM7ysWglcyGrx8mYMVjp1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718061002; c=relaxed/simple; bh=OUIAEYxW2pt7xlzXmaotUnfEstFIYjmqTiX5MYoVVRg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SrGp2RITtPphdg93t876CTP68nuDMzZ+5YU2sPos48Vf/QnnkoQhzL/ecsM3qzYZgUNnX7pejvLSJLHDfN9RqkTv8NeeRk9ebC/PM5jGThi3vVOqLyYuEZ+Oc7wqOKu9RNv5kaFK2HY8RnhTG58y0Fqqlcx/bUPyjWdqXHCTmvo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=lcxFhA/Q; arc=none smtp.client-ip=209.85.161.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="lcxFhA/Q" Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-5b9706c84e5so2837963eaf.1 for ; Mon, 10 Jun 2024 16:10:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718061000; x=1718665800; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=hm98dOi0/zRzUBfFNpcElUy3e9wDhIJ4KCCov/nGFTQ=; b=lcxFhA/QvMiB5odiKSNsODLs2xDUqc8EUHOGLPGoQyfuWTyCCBMuNMwdptmeaugV5j KX+yec+tggkrBjmbHtWZjMpu9xUItgo2VTgg2Nw3viO/Tsv4+fXfyNCxjclVdoIDD4xU X1jwxWszNmhW4eSIp6rn71OOf3gqpXfvna6x8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718061000; x=1718665800; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hm98dOi0/zRzUBfFNpcElUy3e9wDhIJ4KCCov/nGFTQ=; b=s9G/BNpfIc++foihwmi17ys85LHdAR7fV7J8gThtCWKxMoUsvzVDfEl6OgHnv+ZH4X 0jN/zrhQDbUZ1NAH3ubOzPHsdnGRH+v16IH0mIQyKbA0Stpemxn9dm7+7JQyHoNRrySN gT/2YMnIkie0l+HMCxCo1sEhbAxQb8Bk622+Jh82uzBhR2862yq3c3aCxvdtpWNH8RZ0 cYZC/0oXZw0jvtsLQawdg6kwANHMMN542amZ706d8/Pi4cTNQR7jQtvuJwdNYjfrXZUo cNsGi2KptmBs9zmA9ZYjDmgKc15Fw1xwcgEik7sacTB+k2IvoUwZqLsse0RJ2bhZl3Uo 0txw== X-Forwarded-Encrypted: i=1; AJvYcCU8f24XpDXBm+/TKdUH1164kM8tBefd8TBraPBuliv4kF7fpF5TCDqv3T7usSBAPY7tDlvygsKfm5Xgu3j+vFiW3z0njy+MZdN2z24= X-Gm-Message-State: AOJu0YymZBU2a4SXK6jLJNe/453TaCiN5OnVTArvESl3eYHK8SWI+cKa Io0wPMRsesUQSdbkuZ8X1dkPliYKNYjj+iLUWf7mQKULyK7v5wvkH3Fz2J16sA== X-Google-Smtp-Source: AGHT+IEceemHixBzieP2KZfovugvjCMFKfE0k8sKaMP22e3NHBGqtiLQaG5XPws0aTira0s0kS/A3g== X-Received: by 2002:a05:6358:840b:b0:19f:5b1f:91b1 with SMTP id e5c5f4694b2df-19f5b1f9254mr115528755d.14.1718061000049; Mon, 10 Jun 2024 16:10:00 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b06519d521sm35256946d6.65.2024.06.10.16.09.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 16:09:58 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 10 Jun 2024 23:09:56 +0000 Subject: [PATCH v2 5/7] media: uvcvideo: Remove PLF device quirking Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240610-billion-v2-5-38e861475f85@chromium.org> References: <20240610-billion-v2-0-38e861475f85@chromium.org> In-Reply-To: <20240610-billion-v2-0-38e861475f85@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab Cc: Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 We can use heuristics to figure out the proper range of the control instead of quirking every single device. Reviewed-by: Sergey Senozhatsky Signed-off-by: Ricardo Ribalda Reviewed-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_ctrl.c | 4 +- drivers/media/usb/uvc/uvc_driver.c | 122 ------------------------------------- drivers/media/usb/uvc/uvcvideo.h | 2 - 3 files changed, 2 insertions(+), 126 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index efc46f53ac81..d74019cb27fe 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -459,7 +459,7 @@ static void uvc_ctrl_set_rel_speed(struct uvc_control_mapping *mapping, data[first+1] = min_t(int, abs(value), 0xff); } -const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited = { +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, @@ -471,7 +471,7 @@ const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited = { V4L2_CID_POWER_LINE_FREQUENCY_50HZ), }; -const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11 = { +static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11 = { .id = V4L2_CID_POWER_LINE_FREQUENCY, .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index bbd90123a4e7..5f689fee60a9 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2383,20 +2383,6 @@ MODULE_PARM_DESC(timeout, "Streaming control requests timeout"); * Driver initialization and cleanup */ -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_ctrl_power_line_uvc11 = { - .mappings = (const struct uvc_control_mapping *[]) { - &uvc_ctrl_power_line_mapping_uvc11, - NULL, /* Sentinel */ - }, -}; - static const struct uvc_device_info uvc_quirk_probe_minmax = { .quirks = UVC_QUIRK_PROBE_MINMAX, }; @@ -2427,33 +2413,6 @@ 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 }, - /* 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 = 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 = 0x4034, - .bInterfaceClass = USB_CLASS_VIDEO, - .bInterfaceSubClass = 1, - .bInterfaceProtocol = UVC_PC_PROTOCOL_15, - .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, @@ -2583,42 +2542,6 @@ 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 = 0xb5eb, - .bInterfaceClass = USB_CLASS_VIDEO, - .bInterfaceSubClass = 1, - .bInterfaceProtocol = 0, - .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited }, - /* Chicony Electronics Co., Ltd Integrated Camera */ - { .match_flags = USB_DEVICE_ID_MATCH_DEVICE - | USB_DEVICE_ID_MATCH_INT_INFO, - .idVendor = 0x04f2, - .idProduct = 0xb67c, - .bInterfaceClass = USB_CLASS_VIDEO, - .bInterfaceSubClass = 1, - .bInterfaceProtocol = UVC_PC_PROTOCOL_15, - .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_uvc11 }, - /* 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, @@ -3003,51 +2926,6 @@ static const struct usb_device_id uvc_ids[] = { .bInterfaceSubClass = 1, .bInterfaceProtocol = 0, .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_FORCE_BPP) }, - /* SunplusIT Inc HD Camera */ - { .match_flags = USB_DEVICE_ID_MATCH_DEVICE - | USB_DEVICE_ID_MATCH_INT_INFO, - .idVendor = 0x2b7e, - .idProduct = 0xb752, - .bInterfaceClass = USB_CLASS_VIDEO, - .bInterfaceSubClass = 1, - .bInterfaceProtocol = UVC_PC_PROTOCOL_15, - .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_uvc11 }, - /* Lenovo Integrated Camera */ - { .match_flags = USB_DEVICE_ID_MATCH_DEVICE - | USB_DEVICE_ID_MATCH_INT_INFO, - .idVendor = 0x30c9, - .idProduct = 0x0093, - .bInterfaceClass = USB_CLASS_VIDEO, - .bInterfaceSubClass = 1, - .bInterfaceProtocol = UVC_PC_PROTOCOL_15, - .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_uvc11 }, - /* Sonix Technology USB 2.0 Camera */ - { .match_flags = USB_DEVICE_ID_MATCH_DEVICE - | USB_DEVICE_ID_MATCH_INT_INFO, - .idVendor = 0x3277, - .idProduct = 0x0072, - .bInterfaceClass = USB_CLASS_VIDEO, - .bInterfaceSubClass = 1, - .bInterfaceProtocol = 0, - .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited }, - /* 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 }, - /* Acer EasyCamera */ - { .match_flags = USB_DEVICE_ID_MATCH_DEVICE - | USB_DEVICE_ID_MATCH_INT_INFO, - .idVendor = 0x5986, - .idProduct = 0x1180, - .bInterfaceClass = USB_CLASS_VIDEO, - .bInterfaceSubClass = 1, - .bInterfaceProtocol = 0, - .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited }, /* Intel D410/ASR depth camera */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO, diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index fa0396dd5b35..4df02a40c74f 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -753,8 +753,6 @@ int uvc_status_start(struct uvc_device *dev, gfp_t flags); void uvc_status_stop(struct uvc_device *dev); /* Controls */ -extern const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited; -extern const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11; extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops; int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, From patchwork Mon Jun 10 23:09:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13692561 Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FD7915444B for ; Mon, 10 Jun 2024 23:10:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718061004; cv=none; b=YclaOCDxaICL81RIBAnSkRzDO6kwimw6roQtT26P8M8+M/MByMZ3hcgKxZtGyusGV7ndVPcKWTXZqEQzJh1UxwWOiaduyaH1mmmygB7D9Ygi7INzpdm9wyzXZUfN+tJKaySQ9+U72UqjQGjSbIfc4F5DnR3J7CrzgA8WNUoYK4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718061004; c=relaxed/simple; bh=+r2Q25v4QtfWRynLyRqPbgCpgtuh54ubGSY1KEdbNko=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bNwvloxp9pHUGRiR2piUb9XtI3+bgNaSSRf50PlONDMqDyA1E4qa+fMJVI+94L0a+rUxPsP0efh2c+MTyQIYgOtkuLe9PlZhpMu2YYMamvGxhS9RwTLKftec21lBwljvYDXfFIdVInbdOn5lulkuXKb/HWqZP3pqENNST6T+zkA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=U26le7M2; arc=none smtp.client-ip=209.85.219.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="U26le7M2" Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-6b08d661dbaso230316d6.0 for ; Mon, 10 Jun 2024 16:10:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718061001; x=1718665801; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Er/qUnS8MdBJtpjo7BWYHXnD96tca0yCRfZOovxm8nw=; b=U26le7M204F4uxJv1Q80Ygo74iSqbHJkvY7VbNyuULhMZCDOZDrAa5ljLd6G1qf1ZH jn7ZzWOKsZLChSBHgCwPoaEAEt5m2f5Dl1ND6Q75ESFdcbJl8u6SrR68kbHuPb63dO7F i16m/ODeXqLKL7SGtvKpJwrhNz7K/YBkiA+hM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718061001; x=1718665801; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Er/qUnS8MdBJtpjo7BWYHXnD96tca0yCRfZOovxm8nw=; b=Sv1z8er8iA7RYeLVArUIjim4A1ZJrIdeHa8P+UEeBlIJdI+6VCF5GycIfVLiimEhKF q/neQqR4/oWQRat3b0sJJPiNPsZRpy56Biwb7+3cPKyA0vgFe3zfxVejg5IJIndiH/cl MrAe5dCCrAUeMKeeDYT5V60wC+cXGF4R+8ZnfcVqEB6g09jKJb2zHJEGN/qo06cIJj3L gNRTgIi979pvBN7iq7iC+ZwqKe1Qst8rfsG6S7zPwDSgi6HxlgQ2fPzJ134r2V6ZnwiG hhzsxlqQgFh2mO/O6HjrJgfVyFLjp7rMLJiR3KfuslCaZe0SJeVsVMFdrgNXLiSWH+uG OYqA== X-Forwarded-Encrypted: i=1; AJvYcCUSK1KlKp8H6M3aUxlDU/azYa034C0hxGb+Hsr8Lu0xMSLs5EJCoGMJ2bGeDmrkYYvZi5p3S/xcJRruw0qv0EOfOq3otHd/x2MLOe0= X-Gm-Message-State: AOJu0YzKnArub2R9pNysnphkhEL1X0VTP7YqvEWcdqjHh6vQGyqENaFs 9vagE7pPIbWxLrDmcsgQ+frvkR2jHGYbDYMnRJykANkh8sJgaNxkhR9FYbOXtA== X-Google-Smtp-Source: AGHT+IGGVcUXF3Q+TzeoBW1dpWSX4RCelVgPbdr7LwKtNneYSQiKMiE+ovxL9rBTwMEOW02U5O75Aw== X-Received: by 2002:ad4:5747:0:b0:6ab:9214:ffd3 with SMTP id 6a1803df08f44-6b089f75071mr21382306d6.25.1718061001474; Mon, 10 Jun 2024 16:10:01 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b06519d521sm35256946d6.65.2024.06.10.16.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 16:10:00 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 10 Jun 2024 23:09:57 +0000 Subject: [PATCH v2 6/7] media: uvcvideo: Remove mappings form uvc_device_info Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240610-billion-v2-6-38e861475f85@chromium.org> References: <20240610-billion-v2-0-38e861475f85@chromium.org> In-Reply-To: <20240610-billion-v2-0-38e861475f85@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab Cc: Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 We do not have any quirk device making us of this. Remove from now. It can be easily reverted later if needed. Signed-off-by: Ricardo Ribalda Reviewed-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_ctrl.c | 27 +-------------------------- drivers/media/usb/uvc/uvcvideo.h | 1 - 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index d74019cb27fe..1c1710e3c486 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -2679,32 +2679,7 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, if (!ctrl->initialized) return; - /* - * 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; - - for (i = 0; chain->dev->info->mappings[i]; ++i) { - const struct uvc_control_mapping *mapping = - chain->dev->info->mappings[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. */ + /* Process common mappings. */ for (i = 0; i < ARRAY_SIZE(uvc_ctrl_mappings); ++i) { const struct uvc_control_mapping *mapping = &uvc_ctrl_mappings[i]; diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 4df02a40c74f..ff9545dcf716 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -527,7 +527,6 @@ struct uvc_device_info { u32 quirks; u32 meta_format; u16 uvc_version; - const struct uvc_control_mapping **mappings; }; struct uvc_status_streaming { From patchwork Mon Jun 10 23:09:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13692562 Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06F751552F8 for ; Mon, 10 Jun 2024 23:10:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718061005; cv=none; b=ATNDEOstKvBAL66J5tW9nTZVRbftE1k5PCRP+e0bsVXtWSf9p9qc0ylEXuN5saF3n/LR4k9LFwLU9sQXrubPBpZifwViykb7aUP8MgCpSzU2DA+ElKTkUyOjQVBf6mgfDnQIPrRxLDX4OFO19v+UJZDLLdle00sZ/AlLFZ48cvU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718061005; c=relaxed/simple; bh=3YQ1MREPZcXZY8Rzdf2ucSaUl0qgCLccvMpvwcUdRxw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=USlT3NjOg2QCN6neKDc9CUXTK62dDtrdI7sz9murW7byG0+sspuL+gr+ixVBVWMN2Uumww11kOel5owxB/YqOav1B9aBQGD70oK4q7uhKn4+yYILhj8LjP2dzAEqfejipk2pZphLp5l3h24FN5QbDAOnUpPhS4/7RzgRyggjpq0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=M7dQmIL4; arc=none smtp.client-ip=209.85.161.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="M7dQmIL4" Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-5b9f9e7176eso2333534eaf.2 for ; Mon, 10 Jun 2024 16:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718061003; x=1718665803; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=BOfU1pocYD2Scfhf5kButvETql9ENuAv9ka+WIo4LyM=; b=M7dQmIL40ddmTKpyo9O1PINEm/XLjvqsWwa6sqa437yr1uDbzKH0502VeC1sBoKrrC 45soHcL4ZS7jAi+ZYxxejaRiFsHMBAhCPVRTBOdqrlIBOFFpg2X2rsKckfmXNlcsmSHz sUq6qvMSu9DDYg2EIfg+MNmJb1qRV7ciX1Ce0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718061003; x=1718665803; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BOfU1pocYD2Scfhf5kButvETql9ENuAv9ka+WIo4LyM=; b=V2sKvsBcOgVIswpLghvNvEzmaTrwpxtYQ4Cwuz2Z1FFMihSeMVbRL2i8bynuhK4ENz LxpxQygph+GRFtqKdVRPro9mampqgZYfK5c5iTvJPeQWc3X0Sp5nFdILDhxtaw8khQk5 ookWxjELS0GKKvXJ+/dB2g0wBKwccYAqyNPKlWbtKHZaXeuPRhowGJX8v7YY/2Vx5J0I mwzFvZLJpPOGjDs4DodoeuFyjbf3KoXqQ2k4S/VLQmnpXu88yC2A0pJZxr0Di9ptOizh 7ww4WficqwgzEmVVstnHDZ1kBqhU3YWB/pQNU38q6EV0/LYmkWHtQ9jFXCmy2MrdHiMA AK0g== X-Forwarded-Encrypted: i=1; AJvYcCVP7NmQ/OZ+7Gzz/BbcfGtq8C3SV1g8nITUao2xxzHkpPi6xtGuPbvDlqzPLDQwpvukNqJ7Mculn2BW24MrPAzeZUyfH0UBL0n7eh4= X-Gm-Message-State: AOJu0Yzu0BevGTfcfdXbRvNTv4RWX5DNT9fDPFWmT6BadN4noiGbjr9+ buolMQ0SFHQambtdPqq5q3tN0YcHwm6pDL5uWq1wOvkf7xGQYL9VvxHVhfpmwA== X-Google-Smtp-Source: AGHT+IFGj2VK+72l/JFB5SBb2/B+u/t8MIDQowXQChyupB5qIsFTtEzAdZedl985d4NSC3brJeqMYQ== X-Received: by 2002:a05:6358:57a3:b0:19f:4553:5514 with SMTP id e5c5f4694b2df-19f45535aadmr801047355d.29.1718061002738; Mon, 10 Jun 2024 16:10:02 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b06519d521sm35256946d6.65.2024.06.10.16.10.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 16:10:01 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 10 Jun 2024 23:09:58 +0000 Subject: [PATCH v2 7/7] media: uvcvideo: Replace get_mapping with filter_mapping Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240610-billion-v2-7-38e861475f85@chromium.org> References: <20240610-billion-v2-0-38e861475f85@chromium.org> In-Reply-To: <20240610-billion-v2-0-38e861475f85@chromium.org> To: Laurent Pinchart , Mauro Carvalho Chehab Cc: Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 If the callback returns a mapping instead of adding it, the codeflow is more clean and we do not need a forward declaration of __uvc_ctrl_add_mapping_to_list(). Suggested-by: Laurent Pinchart Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 40 ++++++++++++++++++---------------------- drivers/media/usb/uvc/uvcvideo.h | 6 +++--- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 1c1710e3c486..4a13f2685d9e 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -495,11 +495,8 @@ static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc15 = { V4L2_CID_POWER_LINE_FREQUENCY_DISABLED), }; -static int __uvc_ctrl_add_mapping_to_list(struct uvc_video_chain *chain, - struct uvc_control *ctrl, const struct uvc_control_mapping *mapping); - -static int uvc_ctrl_add_plf_mapping(struct uvc_video_chain *chain, - struct uvc_control *ctrl, const struct uvc_control_mapping *mapping) +static const struct uvc_control_mapping *uvc_ctrl_filter_plf_mapping + (struct uvc_video_chain *chain, struct uvc_control *ctrl) { const struct uvc_control_mapping *out_mapping = &uvc_ctrl_power_line_mapping_uvc11; @@ -509,7 +506,7 @@ static int uvc_ctrl_add_plf_mapping(struct uvc_video_chain *chain, buf = kmalloc(sizeof(*buf), GFP_KERNEL); if (!buf) - return -ENOMEM; + return NULL; /* Save the default PLF value, so we can restore it. */ ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, ctrl->entity->id, @@ -517,7 +514,7 @@ static int uvc_ctrl_add_plf_mapping(struct uvc_video_chain *chain, buf, sizeof(*buf)); /* If we cannot read the control skip it. */ if (ret) - return ret; + return NULL; init_val = *buf; /* If PLF value cannot be set to off, it is limited. */ @@ -526,8 +523,7 @@ static int uvc_ctrl_add_plf_mapping(struct uvc_video_chain *chain, chain->dev->intfnum, ctrl->info.selector, buf, sizeof(*buf)); if (ret) - return __uvc_ctrl_add_mapping_to_list(chain, ctrl, - &uvc_ctrl_power_line_mapping_limited); + return &uvc_ctrl_power_line_mapping_limited; /* UVC 1.1 does not define auto, we can exit. */ if (chain->dev->uvc_version < 0x150) @@ -548,7 +544,7 @@ static int uvc_ctrl_add_plf_mapping(struct uvc_video_chain *chain, chain->dev->intfnum, ctrl->info.selector, buf, sizeof(*buf)); - return __uvc_ctrl_add_mapping_to_list(chain, ctrl, out_mapping); + return out_mapping; } static const struct uvc_control_mapping uvc_ctrl_mappings[] = { @@ -843,7 +839,7 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { { .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, - .add_mapping = uvc_ctrl_add_plf_mapping, + .filter_mapping = uvc_ctrl_filter_plf_mapping, }, }; @@ -2411,8 +2407,9 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl, /* * Add a control mapping to a given control. */ -static int __uvc_ctrl_add_mapping_to_list(struct uvc_video_chain *chain, - struct uvc_control *ctrl, const struct uvc_control_mapping *mapping) +static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain, + struct uvc_control *ctrl, + const struct uvc_control_mapping *mapping) { struct uvc_control_mapping *map; unsigned int size; @@ -2485,14 +2482,6 @@ static int __uvc_ctrl_add_mapping_to_list(struct uvc_video_chain *chain, return -ENOMEM; } -static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain, - struct uvc_control *ctrl, const struct uvc_control_mapping *mapping) -{ - if (mapping && mapping->add_mapping) - return mapping->add_mapping(chain, ctrl, mapping); - return __uvc_ctrl_add_mapping_to_list(chain, ctrl, mapping); -} - int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, const struct uvc_control_mapping *mapping) { @@ -2681,7 +2670,14 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, /* Process common mappings. */ for (i = 0; i < ARRAY_SIZE(uvc_ctrl_mappings); ++i) { - const struct uvc_control_mapping *mapping = &uvc_ctrl_mappings[i]; + const struct uvc_control_mapping *mapping = NULL; + + /* Try to get a custom mapping from the device. */ + if (uvc_ctrl_mappings[i].filter_mapping) + mapping = uvc_ctrl_mappings[i].filter_mapping(chain, + ctrl); + if (!mapping) + mapping = &uvc_ctrl_mappings[i]; if (uvc_entity_match_guid(ctrl->entity, mapping->entity) && ctrl->info.selector == mapping->selector) diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index ff9545dcf716..a9547795fe22 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -125,9 +125,9 @@ struct uvc_control_mapping { s32 master_manual; u32 slave_ids[2]; - int (*add_mapping)(struct uvc_video_chain *chain, - struct uvc_control *ctrl, - const struct uvc_control_mapping *mapping); + const struct uvc_control_mapping *(*filter_mapping) + (struct uvc_video_chain *chain, + struct uvc_control *ctrl); s32 (*get)(struct uvc_control_mapping *mapping, u8 query, const u8 *data); void (*set)(struct uvc_control_mapping *mapping, s32 value,