Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1334222imm; Tue, 2 Oct 2018 06:41:46 -0700 (PDT) X-Google-Smtp-Source: ACcGV61NaDP31LvYi1dFCvrP5LmO3h6OVkOaNZeRPsdONHlYl9cy/hmV7sV0EjIObxB3tJINOzlm X-Received: by 2002:a63:af5b:: with SMTP id s27-v6mr14460256pgo.448.1538487706291; Tue, 02 Oct 2018 06:41:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538487706; cv=none; d=google.com; s=arc-20160816; b=lYKGLKCDQBn2kXLem5Uhy/8w6dv6x7N8cJgXUOEE0vA2qquEBiNOaxfHciB9ukhHe0 CaUe77XAQv9MjfJy6f4ym7j6Y9x6oY+aYLy+06xXU8mgub1i97vtEtOjPucqJ5LqzdVF N8ydjOtXmbbQT/ca51OasMCB5FxxoTyPZ7nvCOJQ5wPphhNEkSq3K+jhhMw/uoVmi58T XWY6HcK1nUA6/TAWPVT26SFipxzvAPnRGlmLY1cKy2K3c6Fym0dKG/ohy2CAJq4onHz8 ATtaCyimy4SsHxt2kkxZ3/tfK9VoDHAh9ZP06h4v4wHWJDP6zgB9+jLjkpaMe9NRow0o 1voQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=5SXInx4LzsqzRm8mHrUOcirJ9S1MLT4JWdJyKMuGBt4=; b=R6ltuB6WjW/kQ5l/De6JGOFa3MK5QKNcl3UT+VfEtfqv/HOY4emRSGPRSMSPvriTvQ yHMVcJpC5qzStEtMKuNp3WcOE5woEYRw0+i0mxJVeLiAZslvYjkQ9Fz4XEbjA4GhQyr0 6zJO8WNm0OOle9Z0iW7W2KY4KXmun+ANchtwfc856z6xy/xdaBh5ORDfZXU/mARbqyR+ 0stnvxqe3f1iJ0mp9RFI79LxWSi3YhRXe4XCqB4p/DGLR6ZUqVY24Y+4BIUoA+KqP5Pz cBZALDL0JaVogFLPtiMHm5+fQhdhnnmatLm+vxTrHtK5S1yRe6G9ss+6gacio8nS6F2b +Iyg== 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 t20-v6si16624835plj.261.2018.10.02.06.41.31; Tue, 02 Oct 2018 06:41:46 -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 S1733281AbeJBUUE (ORCPT + 99 others); Tue, 2 Oct 2018 16:20:04 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36374 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733264AbeJBUUD (ORCPT ); Tue, 2 Oct 2018 16:20:03 -0400 Received: from localhost (24-104-73-23-ip-static.hfc.comcastbusiness.net [24.104.73.23]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7F070B4B; Tue, 2 Oct 2018 13:36:38 +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.9 67/94] media: uvcvideo: Support realteks UVC 1.5 device Date: Tue, 2 Oct 2018 06:25:21 -0700 Message-Id: <20181002132505.145041018@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002132500.494838053@linuxfoundation.org> References: <20181002132500.494838053@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-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;