From patchwork Thu Mar 2 13:03:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1EB5C6FA8E for ; Thu, 2 Mar 2023 13:03:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbjCBNDw (ORCPT ); Thu, 2 Mar 2023 08:03:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229963AbjCBNDt (ORCPT ); Thu, 2 Mar 2023 08:03:49 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F7E118AB7 for ; Thu, 2 Mar 2023 05:03:46 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id C2BCACE1ED1 for ; Thu, 2 Mar 2023 13:03:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 880B1C433EF; Thu, 2 Mar 2023 13:03:42 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 10/17] media: common: saa7146: fall back to V4L2_PIX_FMT_BGR24 Date: Thu, 2 Mar 2023 14:03:23 +0100 Message-Id: <20230302130330.1125172-11-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org If the requested pixelformat is not supported, then fall back to V4L2_PIX_FMT_BGR24 for improved V4L2 compliance. Signed-off-by: Hans Verkuil --- drivers/media/common/saa7146/saa7146_video.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c index 6d8da22dd321..bf42de07625e 100644 --- a/drivers/media/common/saa7146/saa7146_video.c +++ b/drivers/media/common/saa7146/saa7146_video.c @@ -372,8 +372,10 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma DEB_EE("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n", dev, fh); fmt = saa7146_format_by_fourcc(dev, f->fmt.pix.pixelformat); - if (NULL == fmt) - return -EINVAL; + if (!fmt) { + f->fmt.pix.pixelformat = V4L2_PIX_FMT_BGR24; + fmt = saa7146_format_by_fourcc(dev, f->fmt.pix.pixelformat); + } field = f->fmt.pix.field; maxw = vv->standard->h_max_out;