Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp617751imm; Wed, 23 May 2018 02:43:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqKtqFOocVN9wqj4FeUArnK2NHNmvVFUELnb48nLuhfAfB4I6FnOXLm54hQr7MoCY73qkmP X-Received: by 2002:a17:902:b489:: with SMTP id y9-v6mr2020740plr.385.1527068634465; Wed, 23 May 2018 02:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527068634; cv=none; d=google.com; s=arc-20160816; b=phYQbATtl1U2VZ0365oUqfsP9HMxd7dfnL4caalFRHgxVthGVqw7qVtRdiucPsAI7T 6AithDju6PHKNaluRLksaBZbcyM+Nt8hXteOmkJzHTyHCMJkpdmQf8xLf2rTG7l2O0UG ZcCnbvrI6FrdQBuJyQvVZqufY2pKUMvupuJFM/ykpBJGzC1itRAEe4s/ttq+PvyFw7eD meM4VvELrJ9Rlbr8w5coc8XcE8zGA3QjCXcsy/78fl2EpxiV2fGY26H3ekVFuWyd+msQ 1J7vhbWWPkoivzth/ofGU3nuxi6nma4aLY1z1aLTC9zsCGPSyfM8hupIqREcNPWBS4xY AotQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=vnun7Wf9fovuePjgI+hGPJpaUzMGUHcnZqVyzQtTES8=; b=UIzZNHJUeMs1CtzOUS7km4D9ZwUWywamVrquCmjaTx3dIulFiuqP/Kh+WNQgxyxQ9U 2b7HcbOUpCp/jwGskJmFAHaIz3+Ei8DLapMsxWV9i0nYmVc9bjViWc80BGV/arWCdhMt cGEyrkUXbuRZU8+T1VPKBqGTg5USAbgVhq+EsOmR1qU//+AlaKHA526GU1s9coaorle5 A9qI8N7J0BBOBbrCG8cyt2KC2YiRbxSIyK9vFPU5/+x4Va5/YM+TJ4nsPkWOcE1tbMI4 jcFeexzSTbW436aftjSjl4EowNvdPid9YfDoMKjKAV3e/gsyve3mQqZU2ncEkrHkq3el HJuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r7-v6si18799109ple.585.2018.05.23.02.43.39; Wed, 23 May 2018 02:43:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932360AbeEWJlv (ORCPT + 99 others); Wed, 23 May 2018 05:41:51 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:43342 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932178AbeEWJlq (ORCPT ); Wed, 23 May 2018 05:41:46 -0400 Received: from localhost (unknown [IPv6:2001:bc8:30d7:121:9eb6:d0ff:fe8a:8b39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: ana) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 756DC263991; Wed, 23 May 2018 10:41:44 +0100 (BST) Date: Wed, 23 May 2018 11:41:41 +0200 From: Ana Guerrero Lopez To: Laurent Pinchart Cc: ming_qian@realsil.com.cn, Mauro Carvalho Chehab , linux-media@vger.kernel.org, Linux Kernel Mailing List , Hans de Goede , Kai Heng Feng Subject: Re: [PATCH] media: uvcvideo: Support realtek's UVC 1.5 device Message-ID: <20180523094141.GA32594@delenn> References: <1525831988-32017-1-git-send-email-ming_qian@realsil.com.cn> <2510852.fx2XduE8hM@avalon> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > commit a9c002732695eab2096580a0d1a1687bc2f95928 > > Author: ming_qian > > Date: Wed May 9 10:13:08 2018 +0800 > > > > media: uvcvideo: Support UVC 1.5 video probe & commit controls > > > > The length of UVC 1.5 video control is 48, and it is 34 for UVC 1.1. > > Change it to 48 for UVC 1.5 device, and the UVC 1.5 device can be > > recognized. > > > > More changes to the driver are needed for full UVC 1.5 compatibility. > > However, at least the UVC 1.5 Realtek RTS5847/RTS5852 cameras have been > > reported to work well. > > > > Cc: stable@vger.kernel.org > > Signed-off-by: ming_qian > > [Factor out code to helper function, update size checks] > > Signed-off-by: Laurent Pinchart > > I tested this new patch and it works well. > > Tested-by: Kai-Heng Feng I tested it as well and it works well. Tested-by: Ana Guerrero Lopez > > > > diff --git a/drivers/media/usb/uvc/uvc_video.c > > b/drivers/media/usb/uvc/uvc_video.c > > index eb9e04a59427..285b0e813b9d 100644 > > --- a/drivers/media/usb/uvc/uvc_video.c > > +++ b/drivers/media/usb/uvc/uvc_video.c > > @@ -207,14 +207,27 @@ static void uvc_fixup_video_ctrl(struct > > uvc_streaming *stream, > > } > > } > > > > +static size_t uvc_video_ctrl_size(struct uvc_streaming *stream) > > +{ > > + /* > > + * Return the size of the video probe and commit controls, which depends > > + * on the protocol version. > > + */ > > + if (stream->dev->uvc_version < 0x0110) > > + return 26; > > + else if (stream->dev->uvc_version < 0x0150) > > + return 34; > > + else > > + return 48; > > +} > > + > > static int uvc_get_video_ctrl(struct uvc_streaming *stream, > > struct uvc_streaming_control *ctrl, int probe, u8 query) > > { > > + u16 size = uvc_video_ctrl_size(stream); > > u8 *data; > > - u16 size; > > int ret; > > > > - size = stream->dev->uvc_version >= 0x0110 ? 34 : 26; > > if ((stream->dev->quirks & UVC_QUIRK_PROBE_DEF) && > > query == UVC_GET_DEF) > > return -EIO; > > @@ -271,7 +284,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming > > *stream, > > ctrl->dwMaxVideoFrameSize = get_unaligned_le32(&data[18]); > > ctrl->dwMaxPayloadTransferSize = get_unaligned_le32(&data[22]); > > > > - if (size == 34) { > > + if (size >= 34) { > > ctrl->dwClockFrequency = get_unaligned_le32(&data[26]); > > ctrl->bmFramingInfo = data[30]; > > ctrl->bPreferedVersion = data[31]; > > @@ -300,11 +313,10 @@ static int uvc_get_video_ctrl(struct uvc_streaming > > *stream, > > static int uvc_set_video_ctrl(struct uvc_streaming *stream, > > struct uvc_streaming_control *ctrl, int probe) > > { > > + u16 size = uvc_video_ctrl_size(stream); > > u8 *data; > > - u16 size; > > int ret; > > > > - size = stream->dev->uvc_version >= 0x0110 ? 34 : 26; > > data = kzalloc(size, GFP_KERNEL); > > if (data == NULL) > > return -ENOMEM; > > @@ -321,7 +333,7 @@ static int uvc_set_video_ctrl(struct uvc_streaming > > *stream, > > put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]); > > put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]); > > > > - if (size == 34) { > > + if (size >= 34) { > > put_unaligned_le32(ctrl->dwClockFrequency, &data[26]); > > data[30] = ctrl->bmFramingInfo; > > data[31] = ctrl->bPreferedVersion; > > > > -- > > Regards, > > > > Laurent Pinchart