From patchwork Mon Mar 19 09:32:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 10292015 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 DB08560349 for ; Mon, 19 Mar 2018 09:32:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBD5C28587 for ; Mon, 19 Mar 2018 09:32:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C054C286CD; Mon, 19 Mar 2018 09:32:38 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 3960528587 for ; Mon, 19 Mar 2018 09:32:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755406AbeCSJcg (ORCPT ); Mon, 19 Mar 2018 05:32:36 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:39773 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755397AbeCSJcf (ORCPT ); Mon, 19 Mar 2018 05:32:35 -0400 Received: by mail-pf0-f196.google.com with SMTP id u5so6799128pfh.6 for ; Mon, 19 Mar 2018 02:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=Ijy5Jsoh+MXxo+EZNYBV63r+6qhGhqxxlzdJP04/pYE=; b=D509rImuwkjwonlC85q0GtSs0gP/+T7+4C6X4VFUNIZ4mv4+B2H583Fqf+4kfavi2W u/plfpepI4uSkAUAZSJzHcwYuVsuF1u0S3+XsoVVucctnI34PQummDR+ZwCgWY0zSI07 mgbyM/90JeAkGJP9TBzcXsHntk7Frm1UIEULY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Ijy5Jsoh+MXxo+EZNYBV63r+6qhGhqxxlzdJP04/pYE=; b=VzqmYpQOLoy99P4l3ziAL6EpqfO5rxkCyiM4pF4n+CeDp/qfrQ4/1e3FchmFCQbrbJ OUDUGckjpX6JzpsdvYrKXeVj645kcSylPkDvJoviUj9/wh8SzGfNaF1FHlx9aJxJOdJT 2PZfXArBRikyxhMrc0yeYWvvxVRc7W3d2pl25oqVwqpZfvzSSv0w46e/OBktuBnHCiB4 45FVxGLR4j9CvjN6aGBqZ7dXQP4+C7TZGgu+qX0ifT0XzpLW7DSt7vsuf8LSnfFoDzXq fxtgJEsB45c+r1PTAA6FSJG4sFYmXESiXT9hRMlCqnqG9WuZJ1G2fivxdD40Q0FBrU3C r3VA== X-Gm-Message-State: AElRT7HntIkZlgzZuo0kVPiKroWfj+AC5GcDf+KnIJTRMRXykNEW1ufJ pLaJzGP0sMy63PcRL47aWEZW4A== X-Google-Smtp-Source: AG47ELs8povAKv1aw2hrG4ebjPveFBORtFCFTb7NCQpb03qu9pceIK5Fuk2P9U6Eq8WwLi4/LyWQZQ== X-Received: by 10.99.110.137 with SMTP id j131mr8620575pgc.85.1521451955141; Mon, 19 Mar 2018 02:32:35 -0700 (PDT) Received: from acourbot.tok.corp.google.com ([2401:fa00:4:4:9712:8cf1:d0f:7d33]) by smtp.gmail.com with ESMTPSA id d12sm26155520pfn.42.2018.03.19.02.32.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Mar 2018 02:32:34 -0700 (PDT) From: Alexandre Courbot To: Stanimir Varbanov Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Alexandre Courbot Subject: [PATCH v2] venus: vdec: fix format enumeration Date: Mon, 19 Mar 2018 18:32:29 +0900 Message-Id: <20180319093229.76253-1-acourbot@chromium.org> X-Mailer: git-send-email 2.16.2.804.g6dcf76e118-goog Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP find_format_by_index() stops enumerating formats as soon as the index matches, and returns NULL if venus_helper_check_codec() finds out that the format is not supported. This prevents formats to be properly enumerated if a non-supported format is present, as the enumeration will end with it. Fix this by moving the call to venus_helper_check_codec() into the loop, and keep enumerating when it fails. Fixes: 29f0133ec6 media: venus: use helper function to check supported codecs Signed-off-by: Alexandre Courbot Acked-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/vdec.c | 13 +++++++------ drivers/media/platform/qcom/venus/venc.c | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index c9e9576bb08a..49bbd1861d3a 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -135,20 +135,21 @@ find_format_by_index(struct venus_inst *inst, unsigned int index, u32 type) return NULL; for (i = 0; i < size; i++) { + bool valid; + if (fmt[i].type != type) continue; - if (k == index) + valid = type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE || + venus_helper_check_codec(inst, fmt[i].pixfmt); + if (k == index && valid) break; - k++; + if (valid) + k++; } if (i == size) return NULL; - if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE && - !venus_helper_check_codec(inst, fmt[i].pixfmt)) - return NULL; - return &fmt[i]; } diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index e3a10a852cad..6b2ce479584e 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -120,20 +120,21 @@ find_format_by_index(struct venus_inst *inst, unsigned int index, u32 type) return NULL; for (i = 0; i < size; i++) { + bool valid; + if (fmt[i].type != type) continue; - if (k == index) + valid = type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE || + venus_helper_check_codec(inst, fmt[i].pixfmt); + if (k == index && valid) break; - k++; + if (valid) + k++; } if (i == size) return NULL; - if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && - !venus_helper_check_codec(inst, fmt[i].pixfmt)) - return NULL; - return &fmt[i]; }