From patchwork Thu Nov 2 20:22:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10039279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 59D3E6032D for ; Thu, 2 Nov 2017 20:22:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C54528AB0 for ; Thu, 2 Nov 2017 20:22:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40FFA293C6; Thu, 2 Nov 2017 20:22:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCF5328AB0 for ; Thu, 2 Nov 2017 20:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964832AbdKBUWi (ORCPT ); Thu, 2 Nov 2017 16:22:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47112 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964801AbdKBUWh (ORCPT ); Thu, 2 Nov 2017 16:22:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 637D625C3C; Thu, 2 Nov 2017 20:22:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 637D625C3C Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=hdegoede@redhat.com Received: from shalem.localdomain.com (ovpn-117-36.ams2.redhat.com [10.36.117.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5441460240; Thu, 2 Nov 2017 20:22:36 +0000 (UTC) From: Hans de Goede To: Gregor Jasny Cc: Linux Media Mailing List , Hans de Goede Subject: [PATCH] libv4lconvert: We support more then 32 bit src fmts now, so use 64 bit bitmasks Date: Thu, 2 Nov 2017 21:22:34 +0100 Message-Id: <20171102202234.9140-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 02 Nov 2017 20:22:37 +0000 (UTC) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We support more then 32 bit src fmts now, so we can no longer re-use struct v4l2_frmsizeenum.pixel_format to store a bitmask of all the supported src-formats for a given frame-size. This fixes a subtile bug where we would try to use SE401 as src fmt instead of YUYV under certain circumstances. BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1508706 Signed-off-by: Hans de Goede --- lib/libv4lconvert/libv4lconvert-priv.h | 2 ++ lib/libv4lconvert/libv4lconvert.c | 9 ++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/libv4lconvert/libv4lconvert-priv.h b/lib/libv4lconvert/libv4lconvert-priv.h index e2389347..9a467e10 100644 --- a/lib/libv4lconvert/libv4lconvert-priv.h +++ b/lib/libv4lconvert/libv4lconvert-priv.h @@ -66,6 +66,8 @@ struct v4lconvert_data { int cinfo_initialized; #endif // HAVE_JPEG struct v4l2_frmsizeenum framesizes[V4LCONVERT_MAX_FRAMESIZES]; + /* Bitmask of all supported src_formats which can do for a size */ + int64_t framesize_supported_src_formats[V4LCONVERT_MAX_FRAMESIZES]; unsigned int no_framesizes; int bandwidth; int fps; diff --git a/lib/libv4lconvert/libv4lconvert.c b/lib/libv4lconvert/libv4lconvert.c index 1a5ccec2..d666bd97 100644 --- a/lib/libv4lconvert/libv4lconvert.c +++ b/lib/libv4lconvert/libv4lconvert.c @@ -434,7 +434,8 @@ static int v4lconvert_do_try_format_uvc(struct v4lconvert_data *data, for (i = 0; i < ARRAY_SIZE(supported_src_pixfmts); i++) { /* is this format supported? */ - if (!(data->framesizes[best_framesize].pixel_format & (1 << i))) + if (!(data->framesize_supported_src_formats[best_framesize] & + (1ULL << i))) continue; /* Note the hardcoded use of discrete is based on this function @@ -1647,9 +1648,7 @@ static void v4lconvert_get_framesizes(struct v4lconvert_data *data, return; } data->framesizes[data->no_framesizes].type = frmsize.type; - /* We use the pixel_format member to store a bitmask of all - supported src_formats which can do this size */ - data->framesizes[data->no_framesizes].pixel_format = 1 << index; + data->framesize_supported_src_formats[data->no_framesizes] = 1ULL << index; switch (frmsize.type) { case V4L2_FRMSIZE_TYPE_DISCRETE: @@ -1662,7 +1661,7 @@ static void v4lconvert_get_framesizes(struct v4lconvert_data *data, } data->no_framesizes++; } else { - data->framesizes[j].pixel_format |= 1 << index; + data->framesize_supported_src_formats[j] |= 1ULL << index; } } }