Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3337397imu; Sun, 11 Nov 2018 12:40:51 -0800 (PST) X-Google-Smtp-Source: AJdET5eTxxnea7I5K4PWkXCz5EXktUmiguoGhXFzBSO+Z2jSvnZbg8bVnS4N+iP1qONc08F1RwiK X-Received: by 2002:a63:2643:: with SMTP id m64mr14883559pgm.35.1541968851295; Sun, 11 Nov 2018 12:40:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541968851; cv=none; d=google.com; s=arc-20160816; b=vn/crq6i4BdCfa3yZqYTFMkm+2hT5S5ckcyM1oJLA9s6qqUjATqGz/W/eFNN/khFYx GTBNCuzIOFNQHGDUWK4JutkANu6KJjcf1rshKV1n5Fgz5ShbU4WigFiJ0MQAEy0CXOYJ e4gnepMkg7pGiT/oK2A+Zj4AGhybbIaxMQE9mrPoUdWvNDZfZ7lGzykzRNQmUUAnh1DA vtYvyxoyuqXBv+GWnyX9CG22dO6r/YbG9lLfTpExyjCuli3wzqpXfvAbBSariW8go0Zo T4YwAKkXQDaBBC6hYGAOPVyZEyQyJTxxOEd0u07jJ37qAMUiuQog02IPnVx8rMuq+NYX 7zTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=HXA1SCWoWQWOFQh6peh0Z/wzsdXn+NRfIP4s/K4/OM0=; b=vi1H1lK+qYQgCg89svfCBff25fQcqYH7JBwa5+RKQKOalDpaaHnrELMBbzPlkr9haf dxJmGocDA6+rxrinmcJmgH9TRDTCkK8sgzpVl0FjFcdHnH3WpGKL3Ek8HeXKoujNkO8p SYtDzJcgQFseWZamEE6VkJxIzCuBZsMjL5hwhwRP7sqTEEnRyhAH61dC2BKLkzuwjP1+ 3GI513zIuJp0s2rNoGyoXwfJ+do5V2RkPARlIX3IfuBF7HhlRFz/QPnf0GyhohKPLc3c mc2w1PhpSeqoVqt46pEoO3xRPS1sdQ1FzPT0Vt3Q4gFTn/5UjTF/F04Lqo+iny7zgXc5 HXVQ== 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 w11si5453997pgp.161.2018.11.11.12.40.35; Sun, 11 Nov 2018 12:40:51 -0800 (PST) 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 S1730158AbeKLG22 (ORCPT + 99 others); Mon, 12 Nov 2018 01:28:28 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:49592 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729999AbeKLFsI (ORCPT ); Mon, 12 Nov 2018 00:48:08 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsT-0000lK-BR; Sun, 11 Nov 2018 19:58:37 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsQ-0001UA-Fi; Sun, 11 Nov 2018 19:58:34 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "ming_qian" , "Mauro Carvalho Chehab" , "Laurent Pinchart" , "Ana Guerrero Lopez" , "Kai-Heng Feng" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 092/366] media: uvcvideo: Support realtek's UVC 1.5 device In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 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] 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 [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- 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 @@ -155,14 +155,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; @@ -217,7 +230,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]; @@ -246,11 +259,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; @@ -267,7 +279,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;