Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp916130pxb; Wed, 3 Mar 2021 20:57:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzI6eiSmER7neUp8HSFNKgD5yYScuyBY+C5U41FsAFZRoHTQYG+YVBcZdKaE+QPSvIyi+bg X-Received: by 2002:a17:907:9709:: with SMTP id jg9mr2236678ejc.276.1614833828240; Wed, 03 Mar 2021 20:57:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614833828; cv=none; d=google.com; s=arc-20160816; b=APOMU5g5XkdRu9aRkTkzKkSrGdwbRaGoTFl1PD4Txuim72vnVDKN9bsCStlD+8bzPX ln4rYLA44+sPbBBkb1YKbhDxSXv+Cir1h03XCiZ8/5m5Br8aEWzlZBA71ob4Y1AIexDH R4NROS/FXMqfGaDT65rZf+YNnhdaeZDJnSAdzGiXQx6mXQVkVZFlbrTohCp1B9AqvPrI Axn9hHzXTYPLlTUq/kX9rz8LWkHPN30ndHhwBawUk0cXo8IftSMCs2RaxRdiR+s82W+y Y0kvfXejnS2LEWtENCfnCJtG1cv0B4uacePLvzPf9MBQ/jubyGfjJEZoWr33oLFAlLDH vDsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=G6Y45kx5GNJSvtTs2oCGbBFA1B5cP/0e1X2oxsGoeEc=; b=ESHkWFQbvkzh3sWlP6zipaBMWXqRzxPo2Ty7Ih1T8BUryrMAhni6JWrNA3wMBybbxU P6aTtybxhJ0y9GY8hu2nbfRAMZ2z4rt3W4OkSpiveOmG6u/nF8+NsbKswIqke8CsQplU 9FeFNxaKPu69wqVPki3nbeuhqeSukspJNlKb23EedbwD03sOgzzNdrDTA/fOIRTSVrBB vf/unpAy667ZzcLYpwZwwrHi8aHLit6yu/eWbOZV+sKEVL8jknLHJ4k3f9MAANxbnXDw ol2JYAjFPysEWINUfM9yRORL/94L+kfyhu9HqQxBp+UXgsSYeyf8N61tAalczo8bBMw4 VrUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=spocLWiD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j17si17025937edw.10.2021.03.03.20.56.45; Wed, 03 Mar 2021 20:57:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=spocLWiD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443151AbhCBCTE (ORCPT + 99 others); Mon, 1 Mar 2021 21:19:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:55182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240429AbhCATpM (ORCPT ); Mon, 1 Mar 2021 14:45:12 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 836F664EDE; Mon, 1 Mar 2021 17:12:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614618776; bh=54KiUnhgH/gu9nF7H3ne4ivMcs82IRwTkSTLS8uXcek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=spocLWiDk7NeeQTP+feI42tpSl7P+xYNL7wEbt9s6XFwmafiz5oKtSsd+D4kJHQ6M MuuLXlC0yJSXRrMjlKNEnEeG3rfag2fsJO1hpd/DRf0skYiFLXnAMy6/Ng0S6Ne4eO z8P+lN+TM2DVXs9VWJZJST1YwAVXYrv+1VSrtbS8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Till=20D=C3=B6rges?= , Laurent Pinchart , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.10 195/663] media: uvcvideo: Accept invalid bFormatIndex and bFrameIndex values Date: Mon, 1 Mar 2021 17:07:23 +0100 Message-Id: <20210301161151.427837099@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Laurent Pinchart [ Upstream commit dc9455ffae02d7b7fb51ba1e007fffcb9dc5d890 ] The Renkforce RF AC4K 300 Action Cam 4K reports invalid bFormatIndex and bFrameIndex values when negotiating the video probe and commit controls. The UVC descriptors report a single supported format and frame size, with bFormatIndex and bFrameIndex both equal to 2, but the video probe and commit controls report bFormatIndex and bFrameIndex set to 1. The device otherwise operates correctly, but the driver rejects the values and fails the format try operation. Fix it by ignoring the invalid indices, and assuming that the format and frame requested by the driver are accepted by the device. Link: https://bugzilla.kernel.org/show_bug.cgi?id=210767 Fixes: 8a652a17e3c0 ("media: uvcvideo: Ensure all probed info is returned to v4l2") Reported-by: Till Dörges Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/usb/uvc/uvc_v4l2.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index fa06bfa174ad3..c7172b8952a96 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -248,7 +248,9 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, goto done; /* After the probe, update fmt with the values returned from - * negotiation with the device. + * negotiation with the device. Some devices return invalid bFormatIndex + * and bFrameIndex values, in which case we can only assume they have + * accepted the requested format as-is. */ for (i = 0; i < stream->nformats; ++i) { if (probe->bFormatIndex == stream->format[i].index) { @@ -257,11 +259,10 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, } } - if (i == stream->nformats) { - uvc_trace(UVC_TRACE_FORMAT, "Unknown bFormatIndex %u\n", + if (i == stream->nformats) + uvc_trace(UVC_TRACE_FORMAT, + "Unknown bFormatIndex %u, using default\n", probe->bFormatIndex); - return -EINVAL; - } for (i = 0; i < format->nframes; ++i) { if (probe->bFrameIndex == format->frame[i].bFrameIndex) { @@ -270,11 +271,10 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, } } - if (i == format->nframes) { - uvc_trace(UVC_TRACE_FORMAT, "Unknown bFrameIndex %u\n", + if (i == format->nframes) + uvc_trace(UVC_TRACE_FORMAT, + "Unknown bFrameIndex %u, using default\n", probe->bFrameIndex); - return -EINVAL; - } fmt->fmt.pix.width = frame->wWidth; fmt->fmt.pix.height = frame->wHeight; -- 2.27.0