Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp432748imm; Tue, 22 May 2018 22:43:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrh9cjuT3rYiOllI4ZxeNORG7I4w1rDRsqk9/+6VgHCJRbzxlV3m3RWCzknIrW0eI4exQCf X-Received: by 2002:a65:5ac9:: with SMTP id d9-v6mr1203506pgt.342.1527054220991; Tue, 22 May 2018 22:43:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527054220; cv=none; d=google.com; s=arc-20160816; b=EECbr63aHju+WLTHYRtFGssBEu6PztBYN4Oqvq6P9NMwzwhl2uOcaqKLNrXF2QsJoJ LUJb+S2xl4TaKMGQFc+XrKAGcnpua+O89tsBfIfVO9OyY6C82DalC3G11UkG+Uy2VT/w VP3Rl9vhOTyy5gcAtoje/8ffRGjr34WsVOL6Mqru045qNHELN90D6MwFU8xfh/qJpDcH FjgqIHB0qjw11XGVVn77zo62GZKkem2GDZw3BCKIHUnDU8N2+PzI+cBth+lnqGd3OA0+ HvzlArijAbMGHCN/6Azt8CMarP6sfc02VrXNUqLbMqO1/4jYcnkysNlmMs470MylEIO6 LAxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:arc-authentication-results; bh=s3yOi99UNDUSMvO1qQdRH6mKduFL+KpyZupntgC35yc=; b=jWfn7ms+6mwekH6X3khr5oz7OXKVJ2fFXoVMpXHyLosZZmq02c7shf89l9aPPz/De7 58tGAHBt4ov87aI2M+aK6ZIRgAnwVuVTUGKINAp2EcfIgaUDXCeUCTZw1lIQoEH9HWux kk1yCSWY6MVoZo9R/Qtv2wSaK7rQkWbmRouNbSb3ahdd6u31rFdiG6DWC+biJ05YO1HT TEvyBWQQnglK5Dx+2o5lo+/yCPNDYTN2rbx8lbiFEFLHlnAJAVO7mYZ63kGWhxIbUwQu CjhWyn1RmkB2Wzo6bLZWXPtFeUXNHn8ZX5dqLtfqwNKGx7/87Tarr91c5+rcskjAJgCd jRHA== 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=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p17-v6si7264646pge.110.2018.05.22.22.43.26; Tue, 22 May 2018 22:43:40 -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=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754081AbeEWFmt (ORCPT + 99 others); Wed, 23 May 2018 01:42:49 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:49658 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754026AbeEWFmq (ORCPT ); Wed, 23 May 2018 01:42:46 -0400 Received: from mail-pl0-f71.google.com ([209.85.160.71]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fLMXt-0000AL-3u for linux-kernel@vger.kernel.org; Wed, 23 May 2018 05:42:45 +0000 Received: by mail-pl0-f71.google.com with SMTP id a6-v6so13464983pll.22 for ; Tue, 22 May 2018 22:42:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=s3yOi99UNDUSMvO1qQdRH6mKduFL+KpyZupntgC35yc=; b=N1azqJsa1+Nk3+j0gUIokUXqVwyl9rZKeo4GefoDFFZ0sEorjWKgRFfwGK/+icFsLl CEL+m2FOk8uEJkxyJFHwsdVhHlAFurs5qZTu0a2OpZAkSzCI3+juOVDUfCmn60fPBOSa YQBT+/1CjfMAG0RSBlNbLFZugndBwwOzzhBhhouhZFWv+fqWevHok+1vri7Gk0w68N5W 3IjVtNpqB+02/c3StRYgVpOvQUXBwl9gw2tyeBh8sGWU8wHtBZj2Ujt6l6k+zdeFtTkt kLLDnFmrUR09Ss86d+eH1ZsitwFe/V/cwajDEG57bl7PFVIPQZEZ66yPp79Ld+4H/v3F 90KA== X-Gm-Message-State: ALKqPwdjVzpSQHZ1kj1BXNfrwf9PfAlCsODmQcl/dRugbC8Ut+tdVSDy 6UvypmLJSRJJDRvj2CuenDD6/IursQkNVRPXbm1E3d0kDdma8dlTKWJIFWOFzPGeqz+gqq03k4j ybU92l3H87FOf44ZGqX1dLi42deA50ZZeXqw1rrI4eQ== X-Received: by 2002:a63:6186:: with SMTP id v128-v6mr1096865pgb.35.1527054163608; Tue, 22 May 2018 22:42:43 -0700 (PDT) X-Received: by 2002:a63:6186:: with SMTP id v128-v6mr1096839pgb.35.1527054163175; Tue, 22 May 2018 22:42:43 -0700 (PDT) Received: from [10.101.46.95] ([175.41.48.77]) by smtp.gmail.com with ESMTPSA id d23-v6sm29202352pfn.3.2018.05.22.22.42.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 22:42:42 -0700 (PDT) Content-Type: text/plain; charset=us-ascii; delsp=yes; format=flowed Mime-Version: 1.0 (Mac OS X Mail 11.4 \(3445.8.2\)) Subject: Re: [PATCH] media: uvcvideo: Support realtek's UVC 1.5 device From: Kai Heng Feng In-Reply-To: <2510852.fx2XduE8hM@avalon> Date: Wed, 23 May 2018 13:42:38 +0800 Cc: ming_qian@realsil.com.cn, Mauro Carvalho Chehab , linux-media@vger.kernel.org, Linux Kernel Mailing List , Hans de Goede , Ana Guerrero Lopez Content-Transfer-Encoding: 7bit Message-Id: References: <1525831988-32017-1-git-send-email-ming_qian@realsil.com.cn> <2510852.fx2XduE8hM@avalon> To: Laurent Pinchart X-Mailer: Apple Mail (2.3445.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On May 23, 2018, at 4:32 AM, Laurent Pinchart > wrote: > > Hello, > > Thank you for the patch. > > On Wednesday, 9 May 2018 05:13:08 EEST ming_qian@realsil.com.cn wrote: >> From: ming_qian >> >> The length of UVC 1.5 video control is 48, and it id 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. > > This patch is however not specific to Realtek devices, so I think we should > make the subject line more generic. It's fine mentioning in the commit > message > itself that the Realtek RTS5847/RTS5852 cameras have been successfully > tested. > >> Signed-off-by: ming_qian >> --- >> drivers/media/usb/uvc/uvc_video.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/drivers/media/usb/uvc/uvc_video.c >> b/drivers/media/usb/uvc/uvc_video.c index aa0082f..32dfb32 100644 >> --- a/drivers/media/usb/uvc/uvc_video.c >> +++ b/drivers/media/usb/uvc/uvc_video.c >> @@ -171,6 +171,8 @@ static int uvc_get_video_ctrl(struct uvc_streaming >> *stream, int ret; >> >> size = stream->dev->uvc_version >= 0x0110 ? 34 : 26; >> + if (stream->dev->uvc_version >= 0x0150) >> + size = 48; >> if ((stream->dev->quirks & UVC_QUIRK_PROBE_DEF) && >> query == UVC_GET_DEF) >> return -EIO; >> @@ -259,6 +261,8 @@ static int uvc_set_video_ctrl(struct uvc_streaming >> *stream, int ret; >> >> size = stream->dev->uvc_version >= 0x0110 ? 34 : 26; >> + if (stream->dev->uvc_version >= 0x0150) >> + size = 48; >> data = kzalloc(size, GFP_KERNEL); >> if (data == NULL) >> return -ENOMEM; > > Instead of duplicating the computation in both functions, I think we should > move the code to a helper function. > > Furthermore there are equality checks further down both functions that > compare > the size to 34, they should be updated to also support UVC 1.5. > > I propose the following updated patch. If you're fine with it there's no > need > to resubmit, I'll queue it for v4.19. > > I have dropped the Reviewed-by and Tested-by tags as the patch has changed. > > 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 > > 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