From patchwork Mon Mar 18 23:55:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13596040 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (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 21DA95F870 for ; Mon, 18 Mar 2024 23:55:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710806134; cv=none; b=W3zdkMV9rEDILp5QhB4KKUJr9Y0oCqEK/XWg5Iml0PoAYniCsVE5FYDxdrE3QF0rR/8fsKl0ufXyBybwyqcoEKvFxOdkyl0XEph7D0Jum0+200hDx4acu5JoDJN2lzut2e6+4XOaeP3HqN9xscFmrPU+j5ajx06cyYRgmH4SISs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710806134; c=relaxed/simple; bh=rowtwgwTzTc2/qlsuivkpFe9gApODrL9SLk4LA5CMVA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g5Er5MD8uCVIj6djEfZB+xuQ4mvLupqxxrK0c+7dduzpMHS15A0ZJ/MgNC70uhAQPve0j2WRgCvaTa9LyxSdE372IhmQZcbAyjqg1hFKMGlWWERe2JdKy7fRySkCaQJrmt5fJFh2xAFUa0As726Y4Ebg5SXpLDJN6HtVJejN/04= 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=eqgB+gtF; arc=none smtp.client-ip=209.85.222.169 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="eqgB+gtF" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-78a13117a3dso3871985a.1 for ; Mon, 18 Mar 2024 16:55:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1710806132; x=1711410932; 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=jncCK9aTJnH9oQYheR4m1KC9owq0XH6MuF35O7AIQjE=; b=eqgB+gtFFx2gq3JHR2O9FZIj0vY7Mc3Km8Ef8slS7Z9afMVY5v2n10DtT5DqPiNTXn tm6oKKrA1QeDouE4ashrSGohrZXik2bnEcQi5HNDtxjV+HWTMhzsCTXyyU09uWh5Kdts 2u/JqHQ5ueWDw22hi9lWtWGJXub/fp767zq7w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710806132; x=1711410932; 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=jncCK9aTJnH9oQYheR4m1KC9owq0XH6MuF35O7AIQjE=; b=n+qfLBRPcEEfaa6CzDxkzAOwhIJAofaYzKhllnzEsdOHXFKZJWo3yZi3sTnFbtcD6C d/L2UKoFU1Ns3hxB5GcRWitu6U7qTV0QZtxjBQCScCfDY7flI1ku85JkwGHgmtqx1aTw 1cU70ZkRvBYZz6UuCT70rOm6O3ebINcQL2F42blgtKz/MXoeyU48lkfQ9uY8GgUykQp5 e+GKo1TGFkVQ6YZmcYFeAdoLydurSwvKiISjAW+1F9RvT58Gept+x2LBbSKzcVdX7Uid BdMRo/UFaiBXiZpuutVsE14NKEA6xb0IU7T/E1FBN9KIvweNegChf4nOCHgufHMY36mc g60Q== X-Forwarded-Encrypted: i=1; AJvYcCV69SI0sRCRjbvdF1KbXe+ZKrN+Dxz/W/ohdoiBgKHCKpMw2kDh1IGQF1pq6hrje0i1MkfcRzsTIy9CpQoRouXWWnaEULTM0I+d01A= X-Gm-Message-State: AOJu0Yy2UlTWO9sGGps3nYMIGKg0xMGGoiaEsl2Mwvp6joFK+Sxigdyu pTKZyoP5DrA7I3Z9S9FMEYhWx6HL9OavGIaVRQpSqF9T0OzQaI3unVl45a74hw== X-Google-Smtp-Source: AGHT+IHeJjk+X8VL/kQzFnMLRimmoKUCR3xzZLlpLovHDemxVv6glcUkJy2psvzsXL54QGoJkWlqRg== X-Received: by 2002:a05:620a:2714:b0:787:4148:f6e3 with SMTP id b20-20020a05620a271400b007874148f6e3mr1868765qkp.37.1710806132048; Mon, 18 Mar 2024 16:55:32 -0700 (PDT) Received: from denia.c.googlers.com (188.173.86.34.bc.googleusercontent.com. [34.86.173.188]) by smtp.gmail.com with ESMTPSA id h15-20020ae9ec0f000000b00787930320b6sm4991690qkg.70.2024.03.18.16.55.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 16:55:31 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 18 Mar 2024 23:55:23 +0000 Subject: [PATCH 1/5] 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: <20240318-billion-v1-1-2f7bc0ee2030@chromium.org> References: <20240318-billion-v1-0-2f7bc0ee2030@chromium.org> In-Reply-To: <20240318-billion-v1-0-2f7bc0ee2030@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. Lets create a new callback function where heuristics can be implemented to detect what is implemented and what not. Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 15 ++++++++-- drivers/media/usb/uvc/uvcvideo.h | 59 +++++++++++++++++++++------------------- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index e59a463c27618..3e939b4fbaaaf 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -2434,6 +2434,14 @@ static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain, return -ENOMEM; } +static int __uvc_ctrl_add_custom_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(chain, ctrl, mapping); +} + int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, const struct uvc_control_mapping *mapping) { @@ -2637,7 +2645,8 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, if (uvc_entity_match_guid(ctrl->entity, mapping->entity) && ctrl->info.selector == mapping->selector) { - __uvc_ctrl_add_mapping(chain, ctrl, mapping); + __uvc_ctrl_add_custom_mapping(chain, ctrl, + mapping); custom = true; } } @@ -2652,7 +2661,7 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, if (uvc_entity_match_guid(ctrl->entity, mapping->entity) && ctrl->info.selector == mapping->selector) - __uvc_ctrl_add_mapping(chain, ctrl, mapping); + __uvc_ctrl_add_custom_mapping(chain, ctrl, mapping); } /* Finally process version-specific mappings. */ @@ -2664,7 +2673,7 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, if (uvc_entity_match_guid(ctrl->entity, mapping->entity) && ctrl->info.selector == mapping->selector) - __uvc_ctrl_add_mapping(chain, ctrl, mapping); + __uvc_ctrl_add_custom_mapping(chain, ctrl, mapping); } } diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 6fb0a78b1b009..611350a82c37f 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -101,34 +101,6 @@ struct uvc_control_info { u32 flags; }; -struct uvc_control_mapping { - struct list_head list; - struct list_head ev_subs; - - u32 id; - char *name; - u8 entity[16]; - u8 selector; - - u8 size; - u8 offset; - enum v4l2_ctrl_type v4l2_type; - u32 data_type; - - const u32 *menu_mapping; - const char (*menu_names)[UVC_MENU_NAME_LEN]; - unsigned long menu_mask; - - u32 master_id; - s32 master_manual; - u32 slave_ids[2]; - - s32 (*get)(struct uvc_control_mapping *mapping, u8 query, - const u8 *data); - void (*set)(struct uvc_control_mapping *mapping, s32 value, - u8 *data); -}; - struct uvc_control { struct uvc_entity *entity; struct uvc_control_info info; @@ -336,6 +308,37 @@ struct uvc_video_chain { u8 ctrl_class_bitmap; /* Bitmap of valid classes */ }; +struct uvc_control_mapping { + struct list_head list; + struct list_head ev_subs; + + u32 id; + char *name; + u8 entity[16]; + u8 selector; + + u8 size; + u8 offset; + enum v4l2_ctrl_type v4l2_type; + u32 data_type; + + const u32 *menu_mapping; + const char (*menu_names)[UVC_MENU_NAME_LEN]; + unsigned long menu_mask; + + u32 master_id; + 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, + u8 *data); +}; + struct uvc_stats_frame { unsigned int size; /* Number of bytes captured */ unsigned int first_data; /* Index of the first non-empty packet */ From patchwork Mon Mar 18 23:55:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13596041 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (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 49B945F87D for ; Mon, 18 Mar 2024 23:55:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710806135; cv=none; b=UChW0B6/KeO/XXzyHWW/s/FPxfvaZ5rm0eY5yWfTVsWulVOnqPancvhWs0MFmNv4m+EkhhfFBLTfFrX6dBQHCYeeDcTHa+NlIbnZxzRm73VyEhqvQVLDI5YLvIRjnIbci4WP74EqVMYc7WZKEhx2kSfSeJgxHKP+MV011FbxqGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710806135; c=relaxed/simple; bh=zBECVF9sz72SkafC2kf8Npmyir5v2S+2KXe7owaPEq4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ifvmWosBsg+XGhnefmd3UqNzz4XceHktiGMIKR30AeM9xsTYC1lpsmZ5NOLFjbfFMzfxGrbM2O2Ra4GQs7YMVUdJ7DD1zYwkPmeuFZ3fiqpw8a5QAqH7/Sy39nmI+fvzwZALd8eNlyzMBwUUAGo3Og+Oi55lyEPvRkBXVVBHaUs= 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=dRUlpozA; arc=none smtp.client-ip=209.85.222.181 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="dRUlpozA" Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-789e83637e0so198891485a.2 for ; Mon, 18 Mar 2024 16:55:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1710806133; x=1711410933; 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=H7pU/Vvhg3ZPRZ+PwIWA3KmscAs2Y8vnY/vfNGY6VG8=; b=dRUlpozAU9t4TdVJVAgq5f0VYUP23f2G4umZCzBUQ7N9bGHA4ftYaYud1ssD7U2BoJ EZCGLcMfau5yBXzk2o9njOpZt5nnbjI6eK/Tf8enD1U+S6I15Z4Jzy4FPQUS2hlm5oot H0BCFJrJnHVFCF884Vn5yNWXImN7oizO8xuaQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710806133; x=1711410933; 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=H7pU/Vvhg3ZPRZ+PwIWA3KmscAs2Y8vnY/vfNGY6VG8=; b=G4aYP1+2mL09fRcygwqzL1NNgbN9en0obUw2ypMvdZ4iYyE9LHI+PxQf25IENRcoIE xZv8S+GszpIE6JxZLfOJk9jx+my0kg7SDMtIlTqL0Zx8cdl5a7xOAbMaBxcTLDMBImwr jxt2V9JfVU+Tnz9O8qtHCgoNVXQ0/Zr8GH46j7baSVUtzFqjQmLpZBNYMNPW7UI9VdFk dxuqsXiG6n0qTeXhokpe6EpKVSxzY4fJ71W1S7oerp0QEDkwWmzXcTeliJEc/AjUbYz0 q7DX63xzwpj4I5mxRNOM2zgZe9K5paxi6Vi7jQKL3oq4EKZ+ovs9KXQ3P2S8wlOJxPLV EeOg== X-Forwarded-Encrypted: i=1; AJvYcCXoIXXmPp/0BbaCgLJYeizuXdc2RaUppXZdaEg9POSsd+p7nedm7ExtDqaLjDdD/yHyv1o/Xlei9+tS3NZ622hDkS/zx7NFzcbzkXo= X-Gm-Message-State: AOJu0Yzc2CLxbEYRxiONGKosVBXLOaH/9dqb4D1V9iUPlPiD5X/JYY5k Upr+0WI6BijdhToeqG+x9yRuaxrgxfjv8EqqYnigJEcbGhbpHXJib6k28VmQ0g== X-Google-Smtp-Source: AGHT+IFjPCdhiePVVPLNrBIQ/vTLljDrOjwCXunGHDBXceN2AmMeQKPx2eOYrD0GrMNGPL7a3KIZ5g== X-Received: by 2002:a05:620a:47aa:b0:788:264a:73c2 with SMTP id dt42-20020a05620a47aa00b00788264a73c2mr16845115qkb.39.1710806133219; Mon, 18 Mar 2024 16:55:33 -0700 (PDT) Received: from denia.c.googlers.com (188.173.86.34.bc.googleusercontent.com. [34.86.173.188]) by smtp.gmail.com with ESMTPSA id h15-20020ae9ec0f000000b00787930320b6sm4991690qkg.70.2024.03.18.16.55.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 16:55:32 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 18 Mar 2024 23:55:24 +0000 Subject: [PATCH 2/5] 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: <20240318-billion-v1-2-2f7bc0ee2030@chromium.org> References: <20240318-billion-v1-0-2f7bc0ee2030@chromium.org> In-Reply-To: <20240318-billion-v1-0-2f7bc0ee2030@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. Signed-off-by: Ricardo Ribalda --- 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 3e939b4fbaaaf..67522143c6c85 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 Mar 18 23:55:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13596042 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 2EFEA5FB8F for ; Mon, 18 Mar 2024 23:55:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710806136; cv=none; b=RL6SX0qxn2YJtJXtSXRXYIG5rqixgxHuRCY73Uq5gv5bn3DNynzan7zbCgR7g12qAeOsLGMfDuYu7l2F+r/Rz+NeHlf7ynzOyAOk+l+SJnRwxx4/tRCwbZtcbVepLZY0v8CCAT6bu32MDSMnwHDXulQ5/Mh+COSwzHbkGeWkSIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710806136; c=relaxed/simple; bh=JgStlDiQfZLuPMGKv3DaZ3yiTPKdweveDZLgce6gw7s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SaQpMA4qSbGA8n8oqRh1D7UmQ6/AFGH2MZrKHwt7TrX6cNKLuet7zEaaYmITfSjlpt8DyF5/EY0qSJ8gxERf1vMXSpyAHLs9qZH4LFdUs9sATfPGhcdDzBbL7kv6bH3a2SIUNSZ3e6bTWdRHNk4IXrKVr9IDWipNQnRLbc82/oM= 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=ev+nXVVz; arc=none smtp.client-ip=209.85.210.50 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="ev+nXVVz" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6e67451b084so2763114a34.2 for ; Mon, 18 Mar 2024 16:55:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1710806134; x=1711410934; 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=DDfVk65v2Kryzs73ZS+XanGLJ5n6XE9OWpKXOA8TdPw=; b=ev+nXVVzTPd/3nEetP3ZhvnCUHQAhlGmv+3MAhk9YytQjQ6+7uXzT6frrUZvjiGPak 9405pCEeFiyxOnFL05vsE1MayZUKqGw8vpUIbTtyO24LKaZLxi1nDo/xbSq/nRKH0gvo tdEgN+3WgnVGo6lpwR2dWWVtPne/bCPS2UOz4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710806134; x=1711410934; 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=DDfVk65v2Kryzs73ZS+XanGLJ5n6XE9OWpKXOA8TdPw=; b=R7qH1xo1lpzg3oOx5SVUaw58NOdX7FYUj9CfjElCU2F1VnFQvpRKecMwQsNVsVHUrz ut80j/pXrf2wLVEcFSbTomKkbXKL/AyIu12uw4yYUc0NVjA+kd9iqz2bSrYEeHCIiIoY QBsFTdK+vc9OZ+dCYkbhrSZpGouE5+Wtrhcoikx2muIX4Zox1203kTZcnfJNAdsaOE49 BQFhq+tgEco2rUqNIVVAhHf3twBo0AlfKK0irqk3AHQExrfgNI3r6a3wsg8YJmquY3qd 6NpL/jDAVZKzeVjzNTLcX7ZOk8ADkw8BFNSBD9Jvd6SR0+4dcRkPZspG2dnoqL0lR+jy QwAQ== X-Forwarded-Encrypted: i=1; AJvYcCXYWiBeAhpYAsD/UqjbnxBmA0vbzaiBku+sW7w/mqW6i6IojrkRFe5dJCDoo4zJnJ1Vu+ySSm7T+eg3qvxuOdLw3ZfgkC6uBjBtRpc= X-Gm-Message-State: AOJu0YyEQ9cgGVsenLgrkIjbGIO3915CKPQxa4+/Cv8/ATLeUgTvBAp5 r5UjHrobY2jW5ZjYgPDwweRk7ZEsfubdm+1pv6Q23JU9lvSe8sZuAjR6rmAVFZo0nXcvbWAZUo1 CQA== X-Google-Smtp-Source: AGHT+IEqw3Om+E+WiBkhsreCuDRwhJ/oxsIj60O1ACXBKx8LGEyOak5+XpYIUJJs1nAgbFDiD6agAw== X-Received: by 2002:a9d:65d2:0:b0:6e6:7dde:d048 with SMTP id z18-20020a9d65d2000000b006e67dded048mr11309934oth.15.1710806134300; Mon, 18 Mar 2024 16:55:34 -0700 (PDT) Received: from denia.c.googlers.com (188.173.86.34.bc.googleusercontent.com. [34.86.173.188]) by smtp.gmail.com with ESMTPSA id h15-20020ae9ec0f000000b00787930320b6sm4991690qkg.70.2024.03.18.16.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 16:55:33 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 18 Mar 2024 23:55:25 +0000 Subject: [PATCH 3/5] 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: <20240318-billion-v1-3-2f7bc0ee2030@chromium.org> References: <20240318-billion-v1-0-2f7bc0ee2030@chromium.org> In-Reply-To: <20240318-billion-v1-0-2f7bc0ee2030@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. Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 54 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 67522143c6c85..9a0b81aca30d1 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -501,12 +501,58 @@ static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain, 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 init_val; + u8 *buf; + 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) { + kfree(buf); + 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) { + out_mapping = &uvc_ctrl_power_line_mapping_limited; + goto end; + } + + /* 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); + kfree(buf); + return __uvc_ctrl_add_mapping(chain, ctrl, out_mapping); } static const struct uvc_control_mapping uvc_ctrl_mappings[] = { From patchwork Mon Mar 18 23:55:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13596043 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.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 D961D5FB9E for ; Mon, 18 Mar 2024 23:55:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710806137; cv=none; b=chKMUH60pNt6uVBZzeUYEreajQR/mjjzhT5/NkIsrrRCIx3dLCgeJytTQ/aQM57HoJD5xUu0X2GUn7vU+ETtsCgamEgAbtqDu6io26jgmayVkp0POoEoS9ARZbriayvw98RNJTF5wLg7zvREQjBPntbl+ubr4MyH2rpobJyuDMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710806137; c=relaxed/simple; bh=RsdInsKRFjFPeria6YprFZPQUFBlBulfguGTv/hRZ1g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NdumJ4QXLiY4g1sP/wrTI+65rrV8eoDu2PFjVK5u73311SGWpMJ+MssNrksrprBBTAZexOKTcLzxJUWUhvofy3JO20QqrdvGrd7LrxHTfa9jWI6SotuwPRlx1dgZiaq4tQmSU5I2KNZD8dIUxMUPyj280wTBTTQy6tWupEL5rmU= 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=EVd9vVLB; arc=none smtp.client-ip=209.85.210.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="EVd9vVLB" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-6e67cf739d0so2131527a34.1 for ; Mon, 18 Mar 2024 16:55:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1710806135; x=1711410935; 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=zp7PBpqLGtiHuxscR4MF6KkBApKCYsHGzqcNSer1N74=; b=EVd9vVLB2cENY3Pesh2lL4O+CK66/vBx6go/d5Zr+120DXmGAxj4lfBqbntQlZo7QE hh31GXxK99TCPMk5H9nAL9ZP2wETMSlsHbjlFcxu+tK+sLPSSDIm6t7dLweaJ6V2i9i9 2tjDbb1JroiyuAOu+afR0h8ZwTf7ujH3YU+7Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710806135; x=1711410935; 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=zp7PBpqLGtiHuxscR4MF6KkBApKCYsHGzqcNSer1N74=; b=rk37nDHFfa5YhJbPw+KADqdVrrnZMrAxXH3wxz9I1qkAOka3btzJSsc4uguw7/nKHl HCfoBifvhRHfE9ZyLFyz0OFCYlnzkx4PVN+3w9iNUUQ5D9LYVTZszNAqCHz0c1MQz7wj iJ3R8tng5IbF/JOOFxox2sFR7djjhjPR5Un0jQAEEAENTC2j97J0S7NDuBdBXyL6jOHn 4gWvQuGapqE469Bkmh9HSARKl09vXR+rQ/msUQCgkLxDNb5Oe5doo9BUI4Vc7TIUA/+o RTUFge5hvRb9NXYuuldTh6cLOxUBDHYDL11M5cF+5RJFOIGCfklJMZwgZfqGT8RA0jNw ZMAg== X-Forwarded-Encrypted: i=1; AJvYcCUEVWAMJS1Fw+2V5YVwXS5lPmPbnbxIH+/FYM9Me/rwApwieEwMheRChqRcWhKqSFoSucd5nxPV/Yk3rGI/+LXsKBd22n57c7fWkV8= X-Gm-Message-State: AOJu0YxgpabZ+owBuwMl22f1YUTSR2lW4XUJ08574DUNzCi+T50mFjGG MT1rmBqIRJQTPJiExUpBTHJhsGmukvGojByPkmRMoPLGZJV5FCuum2QRkQGGI7zV9PvbDBSbiip W7g== X-Google-Smtp-Source: AGHT+IGrUiFb9DP1hUk66/tEb1lXZjM4msiRZHH9Q61RHuQ1IhIkA3/IUKJ/6Fgiej0iK+12KRDq3w== X-Received: by 2002:a9d:68c7:0:b0:6e6:7b62:3028 with SMTP id i7-20020a9d68c7000000b006e67b623028mr10352580oto.36.1710806135001; Mon, 18 Mar 2024 16:55:35 -0700 (PDT) Received: from denia.c.googlers.com (188.173.86.34.bc.googleusercontent.com. [34.86.173.188]) by smtp.gmail.com with ESMTPSA id h15-20020ae9ec0f000000b00787930320b6sm4991690qkg.70.2024.03.18.16.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 16:55:34 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 18 Mar 2024 23:55:26 +0000 Subject: [PATCH 4/5] 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: <20240318-billion-v1-4-2f7bc0ee2030@chromium.org> References: <20240318-billion-v1-0-2f7bc0ee2030@chromium.org> In-Reply-To: <20240318-billion-v1-0-2f7bc0ee2030@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. Signed-off-by: Ricardo Ribalda Reviewed-by: Laurent Pinchart --- 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 9a0b81aca30d1..41578ded1174e 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -851,14 +851,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 */ @@ -2660,7 +2652,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; /* @@ -2726,18 +2717,6 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, ctrl->info.selector == mapping->selector) __uvc_ctrl_add_custom_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_custom_mapping(chain, ctrl, mapping); - } } /* From patchwork Mon Mar 18 23:55:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13596044 Received: from mail-vs1-f45.google.com (mail-vs1-f45.google.com [209.85.217.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 14EF05FDA7 for ; Mon, 18 Mar 2024 23:55:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710806138; cv=none; b=PiM23vlutbU2iPLDHfLCY8MFydrOwnHVUG2BK6icCMRhIgdbJuUxiM3dN8LmRlFk+5ht7UH/IWMJeduJiGvLm9Xi0xpLbESUg6wcAdBhv7W0mo2o7hXjU5Ozm7Ho225Q/TcL9/SI1G6E0a2CMjw21Y2IFLaVnL2YIxqqjEFyIKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710806138; c=relaxed/simple; bh=GiL+LY/p8pfW4zfMJcj2rtwh2jcG/Fnaf75jG+Q9ISo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FDOxnneEi/KLaN3NWcKo8YCib1DYHYjpeI5+4SIUL4gQYRrquoumN6Dhva8B/Mzh76gZlLjO4eW8jUdW3GDkNy/IxVZp4jSIlcXnD+UArJ/UxJ5BxN0GqohQ96odqOvwKfamZt6EpJIPlmBU8a9jiWt5P1lrFe1sFu84MHXVPPI= 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=JC9Dt8oD; arc=none smtp.client-ip=209.85.217.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="JC9Dt8oD" Received: by mail-vs1-f45.google.com with SMTP id ada2fe7eead31-4767bf3e2a2so1004821137.2 for ; Mon, 18 Mar 2024 16:55:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1710806136; x=1711410936; 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=Z6pBQRCTkt0thzPciZm+J+ubbehmNUxiTZuEht3ecr8=; b=JC9Dt8oDuQ5DGfl9SBDV4syZLlNwld2gHA7HGlhJS1cCPCPWOSmv9MOE4cY5iBbWS9 5j0/lfeiK7ZhtcvsBXfX65upehxIQ68524wyLxzzOD+PwsfXb9nVTS80pwVjqAoVjoGa hY58oiVUy5BrjqSK0WB9w9nFR1+FOnl3fM0fk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710806136; x=1711410936; 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=Z6pBQRCTkt0thzPciZm+J+ubbehmNUxiTZuEht3ecr8=; b=eiuM7AX9eJT1W5ubBZQLT7sA4LtoxYHmfeEk2BiVbJpd9fPIiQaH2yzYIqq4DFK3wL QabQSmiKv0tPHvOFQG8hOFmzWrdehzvKuyr20GSuKzdMlTBDsBExiWeaQsDVs3XpLhgs rur3bEyBwm7Kis1WKZDMXFWG14b0BO1p5gUz/UVu/AivCnmAu78K4n2IuRcRIf0biVTG nEaK4+3205lNNGgFf6NwDViCRXWOYbJ0YNYwVp691v4eu3+m4XuwP+N+H96XEjws+1+1 +bqRTh5mZzPn9kHyMVylkYG19M0JqiLZ0l9h3bg0yBmyqjIgQNbKUgySaCIlq1h1QK1H kudQ== X-Forwarded-Encrypted: i=1; AJvYcCVwkLRopmmzQS/uHikWyolQcYqy3hiQQzCteHY8Hx4B+kBh2WLSaY97tpAUrmQKWAsdkcZr+/EFmqL12/uGZd8Fq4zD8oHyGC29K90= X-Gm-Message-State: AOJu0YxKrzRyVr00Pq4J9W8roq1IJGSilXCiAouR4nMA4O4LqlPiBv6U 3ALeH9Ne5S1PqcxlAJ5LbLMIdz0eHm1N8BIOB3o0jkY4JOdWMnHUGkoZ/QEFsA== X-Google-Smtp-Source: AGHT+IFBabBj+6xRu60riOc9EQF1MmElf0xBgwYMRJnZti1Q2kw6Mf8MiniTK/5OOo99/XzpC649HQ== X-Received: by 2002:a05:6102:34ef:b0:474:cb60:cf3d with SMTP id bi15-20020a05610234ef00b00474cb60cf3dmr844617vsb.9.1710806136048; Mon, 18 Mar 2024 16:55:36 -0700 (PDT) Received: from denia.c.googlers.com (188.173.86.34.bc.googleusercontent.com. [34.86.173.188]) by smtp.gmail.com with ESMTPSA id h15-20020ae9ec0f000000b00787930320b6sm4991690qkg.70.2024.03.18.16.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 16:55:35 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 18 Mar 2024 23:55:27 +0000 Subject: [PATCH 5/5] 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: <20240318-billion-v1-5-2f7bc0ee2030@chromium.org> References: <20240318-billion-v1-0-2f7bc0ee2030@chromium.org> In-Reply-To: <20240318-billion-v1-0-2f7bc0ee2030@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. Signed-off-by: Ricardo Ribalda --- 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 41578ded1174e..11ba1e8ee25b8 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 bbd90123a4e76..5f689fee60a9e 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 611350a82c37f..896bb7362fa27 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -751,8 +751,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,