Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1107796pxb; Fri, 6 Nov 2020 00:47:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNAk43QzDdSe8Be9WZVliKtLe24ld17mogTAWpIB9/11rG17+JLMCQBoSwpQiugOpLqaEs X-Received: by 2002:a17:906:6d13:: with SMTP id m19mr993020ejr.345.1604652473249; Fri, 06 Nov 2020 00:47:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604652473; cv=none; d=google.com; s=arc-20160816; b=DsA9J5XKqU+YuxuNOqkL4bmKu8ZR5ArCdKFbKIbKI0iKz3wu5QY5fYMCSfZC6heOnU 19xXT6I5/UNd790uz8dgaXsZumwxoaJaiI3P54J3PK9XhSVyJ9iz1dniXsZ1Mnuotv/P myiPLgJXeIAh45L9POiUrxFNDtNz/vb5Ym9tDt4bv2xf1gsOe64efo+lXFESt8rKcXLY rLdxI7karXdhe5d9WiNCTz2k1wm2IqFAC5hIKOhd6fd+97FylzPa2ec78HGmFEkpCl1c lhEyre2Ttvvb7oAAhi+VxbgalhG4d0D0Kb2A9vFZ01c446hAd4+7RcKu5LkjMQEHYMuS DPtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=0/92cdpzO11FzbQCzueBuQSjWB1HRcbFekCHNB7QwcU=; b=oJG0NJOlPjFUlodFW06EXvyZBBeDzLMbVb19DVfxT1gOLbZz8DHUXIZxE+caOrA1pw YYU0PWHf8s1o7Xh1BHsWkf3gnQPREtIIRfW5UMNGaD24ohZaeDwDtJXWQEGNGK2H/aLw MOAAftho9WWTt2Z1pPX+gqjomHbNqjVSHmVH6zV0foNId2vi8o5b8MiaGYqoudvXlSCr LYP6lHR8WmMiTO7J5xCE169qSa97r1vJDdPxh6VKyzeuu3nxVP0bU3s/Juu+zrODfg+O Il1Wzg5wtEmbAhU1gwbLnKjl/uKS+gyxfGOB+vYItWiC7NvGrg6NLKLkGfFZ71REtb1I NZew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WM5OUzi6; 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 pg11si399575ejb.92.2020.11.06.00.47.29; Fri, 06 Nov 2020 00:47:53 -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=WM5OUzi6; 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 S1726629AbgKFIpl (ORCPT + 99 others); Fri, 6 Nov 2020 03:45:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725830AbgKFIpk (ORCPT ); Fri, 6 Nov 2020 03:45:40 -0500 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D28CEC0613CF for ; Fri, 6 Nov 2020 00:45:40 -0800 (PST) Received: by mail-oi1-x22f.google.com with SMTP id m17so621891oie.4 for ; Fri, 06 Nov 2020 00:45:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0/92cdpzO11FzbQCzueBuQSjWB1HRcbFekCHNB7QwcU=; b=WM5OUzi6OJSrwtnoagEHDtH1MNZJfaqznzdeqhLLjSaXFRo/7HhDcyly0g9sLf5x61 GFx2DK4dEfOCn1Su22egEM1OXHB4EPOCknH3F/yPBRxAki/tGyYa/pzYCVw77BKa2mOm Q823G/ZK6sxtg40iJbIT0uFqvook8AX3pXp1k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0/92cdpzO11FzbQCzueBuQSjWB1HRcbFekCHNB7QwcU=; b=JX1EIj8Y1b+ZMLfghGZ9Le91X2lPXJfh4FIbPUAoZ7z9+n3ErzbBZ8GfEMZPasNiIA YVCU1gPv4ioXdRrblizSEpzFNwR8///TrkPMK7Ylv6KDeCs4yfblqZRoZlgrraxF6aSJ PF+tc5BoL5FHAOA+WfGglir/g5f7TJ5dBRWgdT2D2RlU5ZocYIqPmjGKvhAyWfza/tpm YEH2j5TlIVhX39nh4w/4ji+NPnJ1iyvTbVOYgJJ8MqFMrgMYJucsDTznLR7xHzPSXa0g QFIy6l8UgcdBAGiyZh2NJaymbzZuwjMHpF6EJp2CwEa+gQXCOvh8SW7myRc1muCAwl5g 9DKA== X-Gm-Message-State: AOAM533mwOW9yMrcFX+ECWd4+GRbcetqGL8AMjckjV+OrlmiauWL9p3O /CKN8Y7h8Icgt2XbX1VJ5ekl4C/dgmKD1w== X-Received: by 2002:aca:5f46:: with SMTP id t67mr486804oib.156.1604652339842; Fri, 06 Nov 2020 00:45:39 -0800 (PST) Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com. [209.85.167.170]) by smtp.gmail.com with ESMTPSA id v17sm172313ote.40.2020.11.06.00.45.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Nov 2020 00:45:39 -0800 (PST) Received: by mail-oi1-f170.google.com with SMTP id q206so590139oif.13 for ; Fri, 06 Nov 2020 00:45:38 -0800 (PST) X-Received: by 2002:a05:6808:602:: with SMTP id y2mr516793oih.11.1604652338400; Fri, 06 Nov 2020 00:45:38 -0800 (PST) MIME-Version: 1.0 References: <20201104180734.286789-1-ribalda@chromium.org> <20201104180734.286789-3-ribalda@chromium.org> <20201106060602.GA6926@pendragon.ideasonboard.com> In-Reply-To: <20201106060602.GA6926@pendragon.ideasonboard.com> From: Ricardo Ribalda Date: Fri, 6 Nov 2020 09:45:27 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/7] media: uvcvideo: Move guid to entity To: Laurent Pinchart Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Laurent Thanks for the review On Fri, Nov 6, 2020 at 7:06 AM Laurent Pinchart wrote: > > Hi Ricardo, > > Thank you for the patch. > > On Wed, Nov 04, 2020 at 07:07:29PM +0100, Ricardo Ribalda wrote: > > Instead of having multiple copies of the entity guid on the code, move > > it to the entity structure. > > > > Signed-off-by: Ricardo Ribalda > > --- > > drivers/media/usb/uvc/uvc_ctrl.c | 30 ++++-------------------------- > > drivers/media/usb/uvc/uvc_driver.c | 21 +++++++++++++++++++-- > > drivers/media/usb/uvc/uvcvideo.h | 2 +- > > 3 files changed, 24 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 9fc0b600eab1..77fea26faa9a 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,18 @@ static struct uvc_entity *uvc_alloc_entity(u16 type, u8 id, > > entity->id = id; > > entity->type = type; > > > > + 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; > > + } > > Given that the GUID is set in uvc_parse_vendor_control() and > uvc_parse_standard_control() for extension units, I'm wondering if it > would make sense to move it there for the other entity types too. Up to > you. Otherwise, I'd add the following comment above the switch: > > /* > * Set the GUID for standard entity types. For extension units, the GUID > * is initialized by the caller. > */ I added the comment. So far I am working on https://github.com/ribalda/linux/tree/uvctest-v3 Please let me know when you are ready with v2, to send v3 to the mailing list. Thanks! > Reviewed-by: Laurent Pinchart > > > + > > entity->num_links = 0; > > entity->num_pads = num_pads; > > entity->pads = ((void *)(entity + 1)) + extra_size; > > @@ -1109,7 +1126,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 +1385,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; > > -- > Regards, > > Laurent Pinchart -- Ricardo Ribalda