From patchwork Thu Mar 23 15:53:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 666406 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 A6695C6FD1C for ; Thu, 23 Mar 2023 15:54:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232239AbjCWPyT (ORCPT ); Thu, 23 Mar 2023 11:54:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232181AbjCWPyM (ORCPT ); Thu, 23 Mar 2023 11:54:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD80A21286 for ; Thu, 23 Mar 2023 08:54:02 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 3A185627D2 for ; Thu, 23 Mar 2023 15:53:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 172AEC4339C; Thu, 23 Mar 2023 15:53:57 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCHv2 13/19] media: common: saa7146: fall back to V4L2_PIX_FMT_BGR24 Date: Thu, 23 Mar 2023 16:53:37 +0100 Message-Id: <20230323155343.2399473-14-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230323155343.2399473-1-hverkuil-cisco@xs4all.nl> References: <20230323155343.2399473-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 e698b4470db3..d706aa3b5967 100644 --- a/drivers/media/common/saa7146/saa7146_video.c +++ b/drivers/media/common/saa7146/saa7146_video.c @@ -367,8 +367,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;