Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp787602pxb; Thu, 19 Nov 2020 13:54:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhMKL9mUizVS+FTS2Qv26H0IW2jL+CwHKz34tj7N5HoxrHmuw/4B2FupBuIbkmRmlDmxkc X-Received: by 2002:a17:906:e0d2:: with SMTP id gl18mr8979356ejb.412.1605822879536; Thu, 19 Nov 2020 13:54:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605822879; cv=none; d=google.com; s=arc-20160816; b=QxDqI90eDnOu4Wfv0Hr17JbxvtJ1zn12qfA8HModwYaDwo4L/FZJg69Jaa0T52lgDl FXMJLNhAhAteelfsiploq/tLRJQpzyJVXSQh01ES1t4GVxZmh+13M2D7QdvCfVt3QNXk X41fUZgYfYTNEtvlJxpdhxq08m/TEbcqI6buqpdFMFutBzbuePvUhlxLWsreaWlHTnAm SOvR1fb1ZfDVsbh5o7/P52MNN6t3g9K5ECM8RIA9oiRM8DvWdlqUfTdVEl6rd/48Y+di G4lSFSC3RW5/ep3xvBNG0CH1AUVh2/5Xs01LS5OlUTTIQCdu7AVFEycWHsodAGZsbI23 0r/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/t8bxWyHXMnbgZ9C+vxVwJ4A+FiurME4MGqZmJ5b3EQ=; b=zJOnD0IJ8ha1QtxDdrmEzZlobfSeqBFrhC+Ts0YMpns74z6jAhdAQ+GMsvjr3wTnrp G6nmsxilZvDLJSXUxWUH0zBo7wPAB/K/OvQxokd+n30bgPnZAbEW40LctjB2cGlS+g1c vz8qpkHTlru7KcVn5slZB3bHyUtuGDQsiQN1NIS0YAb0GsH9z0/74YICbU/d6Hz6ZSPY VscIqxpZrVutMKurdUx8auvCnMLLysWnb+IdBYwzBh4DmA8dQvla1bGJ8ha6M3WGhg58 qVoBQnnD3fJkRKAlFIX4w5VHszLjptnQyeh3UXQYoqGYeNVJ/NtSGwdapuvXE/CqWkYw l7Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=c2e+V++n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f9si584501ejr.733.2020.11.19.13.54.16; Thu, 19 Nov 2020 13:54:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=c2e+V++n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726500AbgKSVu3 (ORCPT + 99 others); Thu, 19 Nov 2020 16:50:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725887AbgKSVu2 (ORCPT ); Thu, 19 Nov 2020 16:50:28 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F8FEC0613CF for ; Thu, 19 Nov 2020 13:50:28 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id d12so7922308wrr.13 for ; Thu, 19 Nov 2020 13:50:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/t8bxWyHXMnbgZ9C+vxVwJ4A+FiurME4MGqZmJ5b3EQ=; b=c2e+V++nAy6pJ5KMZ05U2X69q6wngXqdhJ4JXCKTHKfQ41YbTzflI0g8LjJ1BK9SFA SNpASrBt+1xNUrfPU0K++TNeWkkQOnV4Pr3c++Bh4pKZhZZ6nYU0MI4A715JghqzGzhr r7wQ9cj4uZg3WbPgGWxdr5LtaiZodG2mPNKb4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/t8bxWyHXMnbgZ9C+vxVwJ4A+FiurME4MGqZmJ5b3EQ=; b=p4Pr40gd6RBAhTbvp5R+62TavC4CwpDEzleBsBpTq4XNui1jnzk+B5iAmK6zTN6zIB aUXlf5G2sXHQ8nKCGp/hbdxU1qD41tH1z6tI3oNq9MkKE4z+b149Fzn+vNt1hdtm9N+U 0TtVK9GGSAX3jWIKQwd2HSwsFR1GAM5MWHzw/9wql0YxFFYq5fkt5DXNCgzO+BRPIgG9 1otSQ+gG61IXbDm6eOQE/ZsD6O+pXxG8ALUXwuM4qcEmAl8xb/t/XYWUJ298EWVb3lAa 46Pw0vdRWiMR7lsCNSs1za7m0FQaHk9W1x/4tfmQazt+3CbSnvV/P3FWrxXqXn8lqy4z hgYQ== X-Gm-Message-State: AOAM531TZ59C/0J7UiEEtTAHd1FelHh66OsJgxy/W8XUSvcTtMoQP2kw F4hq3qpW9fyTsYJDySKhf9DbQw== X-Received: by 2002:adf:9b95:: with SMTP id d21mr11957346wrc.335.1605822627161; Thu, 19 Nov 2020 13:50:27 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id t136sm1818859wmt.18.2020.11.19.13.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 13:50:26 -0800 (PST) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Subject: [PATCH v3 1/8] media: uvcvideo: Move guid to entity Date: Thu, 19 Nov 2020 22:50:13 +0100 Message-Id: <20201119215020.508487-2-ribalda@chromium.org> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog In-Reply-To: <20201119215020.508487-1-ribalda@chromium.org> References: <20201119215020.508487-1-ribalda@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of having multiple copies of the entity guid on the code, move it to the entity structure. Reviewed-by: Laurent Pinchart Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 30 ++++-------------------------- drivers/media/usb/uvc/uvc_driver.c | 26 ++++++++++++++++++++++++-- drivers/media/usb/uvc/uvcvideo.h | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index f479d8971dfb..0e480b75e724 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -826,31 +826,10 @@ static void uvc_set_le_value(struct uvc_control_mapping *mapping, * Terminal and unit management */ -static const u8 uvc_processing_guid[16] = UVC_GUID_UVC_PROCESSING; -static const u8 uvc_camera_guid[16] = UVC_GUID_UVC_CAMERA; -static const u8 uvc_media_transport_input_guid[16] = - UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT; - static int uvc_entity_match_guid(const struct uvc_entity *entity, - const u8 guid[16]) + const u8 guid[16]) { - switch (UVC_ENTITY_TYPE(entity)) { - case UVC_ITT_CAMERA: - return memcmp(uvc_camera_guid, guid, 16) == 0; - - case UVC_ITT_MEDIA_TRANSPORT_INPUT: - return memcmp(uvc_media_transport_input_guid, guid, 16) == 0; - - case UVC_VC_PROCESSING_UNIT: - return memcmp(uvc_processing_guid, guid, 16) == 0; - - case UVC_VC_EXTENSION_UNIT: - return memcmp(entity->extension.guidExtensionCode, - guid, 16) == 0; - - default: - return 0; - } + return memcmp(entity->guid, guid, sizeof(entity->guid)) == 0; } /* ------------------------------------------------------------------------ @@ -1776,8 +1755,7 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev, if (data == NULL) return -ENOMEM; - memcpy(info->entity, ctrl->entity->extension.guidExtensionCode, - sizeof(info->entity)); + memcpy(info->entity, ctrl->entity->guid, sizeof(info->entity)); info->index = ctrl->index; info->selector = ctrl->index + 1; @@ -1883,7 +1861,7 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain, if (!found) { uvc_trace(UVC_TRACE_CONTROL, "Control %pUl/%u not found.\n", - entity->extension.guidExtensionCode, xqry->selector); + entity->guid, xqry->selector); return -ENOENT; } diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index ddb9eaa11be7..4cdd65d252d9 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1019,6 +1019,11 @@ static int uvc_parse_streaming(struct uvc_device *dev, return ret; } +static const u8 uvc_camera_guid[16] = UVC_GUID_UVC_CAMERA; +static const u8 uvc_media_transport_input_guid[16] = + UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT; +static const u8 uvc_processing_guid[16] = UVC_GUID_UVC_PROCESSING; + static struct uvc_entity *uvc_alloc_entity(u16 type, u8 id, unsigned int num_pads, unsigned int extra_size) { @@ -1038,6 +1043,23 @@ static struct uvc_entity *uvc_alloc_entity(u16 type, u8 id, entity->id = id; entity->type = type; + + /* + * Set the GUID for standard entity types. For extension units, the GUID + * is initialized by the caller. + */ + switch (type) { + case UVC_ITT_CAMERA: + memcpy(entity->guid, uvc_camera_guid, 16); + break; + case UVC_ITT_MEDIA_TRANSPORT_INPUT: + memcpy(entity->guid, uvc_media_transport_input_guid, 16); + break; + case UVC_VC_PROCESSING_UNIT: + memcpy(entity->guid, uvc_processing_guid, 16); + break; + } + entity->num_links = 0; entity->num_pads = num_pads; entity->pads = ((void *)(entity + 1)) + extra_size; @@ -1109,7 +1131,7 @@ static int uvc_parse_vendor_control(struct uvc_device *dev, if (unit == NULL) return -ENOMEM; - memcpy(unit->extension.guidExtensionCode, &buffer[4], 16); + memcpy(unit->guid, &buffer[4], 16); unit->extension.bNumControls = buffer[20]; memcpy(unit->baSourceID, &buffer[22], p); unit->extension.bControlSize = buffer[22+p]; @@ -1368,7 +1390,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev, if (unit == NULL) return -ENOMEM; - memcpy(unit->extension.guidExtensionCode, &buffer[4], 16); + memcpy(unit->guid, &buffer[4], 16); unit->extension.bNumControls = buffer[20]; memcpy(unit->baSourceID, &buffer[22], p); unit->extension.bControlSize = buffer[22+p]; diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index a3dfacf069c4..df7bf2d104a3 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -304,6 +304,7 @@ struct uvc_entity { u8 id; u16 type; char name[64]; + u8 guid[16]; /* Media controller-related fields. */ struct video_device *vdev; @@ -342,7 +343,6 @@ struct uvc_entity { } selector; struct { - u8 guidExtensionCode[16]; u8 bNumControls; u8 bControlSize; u8 *bmControls; -- 2.29.2.299.gdc1121823c-goog