Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2996977imm; Sun, 1 Jul 2018 09:59:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfmVLJHUoxFBh3o0bX7JFTcTjy6hi4AI8NnEiek5tO5nymVxfT+1JqExfmiFF+SUD37gWiO X-Received: by 2002:a62:9dcc:: with SMTP id a73-v6mr11398553pfk.249.1530464396187; Sun, 01 Jul 2018 09:59:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530464396; cv=none; d=google.com; s=arc-20160816; b=TYj1aLkjD2EKuo6Z+3Bz6F8xCx5sML1Jc07+eVeb2m8Yy2lTj5YtpAaNMACXd204U5 1XuG3BHR/10/hvP5sO3GxfvqkfWCvzS+cjP8qTKQLX1SPSC8QWcd714mKO6HBaoN/6ih eA8gpGS6UiJayVANMxBuJgORWsJ1MA69MUtfWsuBzDhENgKDzVwU168cuS38fEtTO+Ax XOG7UN7Rht932UL1fYVfCVOzbNY1mlpCP1EOGw4e9ZuUnF8CYi+NL/NEK7CY9youCYEE 4hHEjeJpap9fNSM1XLMC+tLb4IVzOk3grz5E1lMGRQY00m6/Mmoe5ixUmRNMeFRLcubY qMUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=PVf83u4HeTbTNEsEKk3kcmKJuRbZEofYmiLl1qIe27w=; b=bCUtQ8l5ROTldQn5j4qzoVsq9wKswiuiKG+Md/+GEGgLq+JOHEPKoncI+3cpLgJDK7 f78JIVJDBmMYyNO1KsC1KTs6Z+ofNmQdyRXDwtt7Wxk5VcRZiYF+nWmTm54Nz9GYXSRy QqN6BWkXpG82hMsyW88sNGfpnWH+xamT77A4DvEmswIjKqL8TM5p1ho/O5mZaePiZqO3 1Q1LTnyfDFMljTnrMD2YKf4SdrgRPExpuokAS32HW2Bw34kfnxrKN6aFXPu2kTGOydL+ t+q/sk+ck4kbScYfAn5oChl+4iUhOPWWd4cTKtT9mu4h/8BSP4/816iqAuAjh7V1UG0Y lThg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1-v6si14591479pld.40.2018.07.01.09.59.41; Sun, 01 Jul 2018 09:59:56 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934030AbeGAQ5X (ORCPT + 99 others); Sun, 1 Jul 2018 12:57:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38058 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032485AbeGAQod (ORCPT ); Sun, 1 Jul 2018 12:44:33 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 735CCA73; Sun, 1 Jul 2018 16:44:32 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, ming_qian , Laurent Pinchart , Kai-Heng Feng , Ana Guerrero Lopez , Mauro Carvalho Chehab Subject: [PATCH 4.17 174/220] media: uvcvideo: Support realteks UVC 1.5 device Date: Sun, 1 Jul 2018 18:23:18 +0200 Message-Id: <20180701160915.509719277@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: ming_qian commit f620d1d7afc7db57ab59f35000752840c91f67e7 upstream. 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. [laurent.pinchart@ideasonboard.com: Factor out code to helper function, update size checks] Cc: stable@vger.kernel.org Signed-off-by: ming_qian Signed-off-by: Laurent Pinchart Tested-by: Kai-Heng Feng Tested-by: Ana Guerrero Lopez Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/uvc/uvc_video.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -163,14 +163,27 @@ static void uvc_fixup_video_ctrl(struct } } +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; @@ -225,7 +238,7 @@ static int uvc_get_video_ctrl(struct uvc 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]; @@ -254,11 +267,10 @@ out: 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; @@ -275,7 +287,7 @@ static int uvc_set_video_ctrl(struct uvc 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;