From patchwork Wed Apr 12 11:08:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 674394 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 0B046C77B6E for ; Wed, 12 Apr 2023 11:08:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229508AbjDLLIi (ORCPT ); Wed, 12 Apr 2023 07:08:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjDLLIh (ORCPT ); Wed, 12 Apr 2023 07:08:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CA635241 for ; Wed, 12 Apr 2023 04:08:35 -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 EA40E62C1C for ; Wed, 12 Apr 2023 11:08:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAB2CC4339E; Wed, 12 Apr 2023 11:08:33 +0000 (UTC) Message-ID: Date: Wed, 12 Apr 2023 13:08:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: en-US To: Linux Media Mailing List Cc: Mauro Carvalho Chehab From: Hans Verkuil Subject: [PATCH] tvtime: support drivers that always select a pixfmt in S_FMT Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Drivers can either reject an unsupported pixelformat in VIDIOC_S_FMT, or replace it with a supported one. Either option is allowed. tvtime assumes that it is rejected, but instead it should check if it chose something else, and then retry with UYVY. Signed-off-by: Hans Verkuil diff --git a/src/videoinput.c b/src/videoinput.c index 5c147c8..12763dd 100644 --- a/src/videoinput.c +++ b/src/videoinput.c @@ -516,13 +516,19 @@ retry: memset( &(imgformat.fmt.pix), 0, sizeof( struct v4l2_pix_format ) ); imgformat.fmt.pix.width = capwidth; imgformat.fmt.pix.height = vidin->height; - imgformat.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; imgformat.fmt.pix.field = V4L2_FIELD_INTERLACED; + imgformat.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; - if( ioctl( vidin->grab_fd, VIDIOC_S_FMT, &imgformat ) < 0 ) { + if( ioctl( vidin->grab_fd, VIDIOC_S_FMT, &imgformat ) < 0 || + imgformat.fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV ) { /* Try for UYVY instead. */ + memset( &(imgformat.fmt.pix), 0, sizeof( struct v4l2_pix_format ) ); + imgformat.fmt.pix.width = capwidth; + imgformat.fmt.pix.height = vidin->height; + imgformat.fmt.pix.field = V4L2_FIELD_INTERLACED; imgformat.fmt.pix.pixelformat = V4L2_PIX_FMT_UYVY; - if( ioctl( vidin->grab_fd, VIDIOC_S_FMT, &imgformat ) < 0 ) { + if( ioctl( vidin->grab_fd, VIDIOC_S_FMT, &imgformat ) < 0 || + imgformat.fmt.pix.pixelformat != V4L2_PIX_FMT_UYVY ) { fprintf( stderr, "\n" " Your capture card driver: %s\n"