Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1027420iob; Fri, 13 May 2022 20:10:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJhnsMwlRzUqCDYmDfsNt8jqOFRpPbf7W0BllXaT/a0Fw6dPVGt2VRdS+yIVB2RFeVW2Vn X-Received: by 2002:a7b:c76e:0:b0:394:8be3:a83c with SMTP id x14-20020a7bc76e000000b003948be3a83cmr17934931wmk.41.1652497852236; Fri, 13 May 2022 20:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652497852; cv=none; d=google.com; s=arc-20160816; b=GpoQMT9ORgDUpaG8BBFVbC9fId2HmCvvso9Vr39IVNuS2syz6uhBLDwVFpRzuoLoTC DQtSg2jH/h6F8JjdLh39Foa/z+BG5d8qqx8eCqAqI2cjQwQQfJpv8WIeodd5mXhLJIiK qVMgzBWc2MI/5br1P6ryR/5ouJFHbsdukgJGLtZYgnw4Gzdem7jUwqhAcln5q8fP5wQg lcqcSJd1lGwiGznDXCC1AlyDmv/YVDSesp0sAfF9n8sXvl5vIeoXwuo8CL3dUzhod81d uqAMtRKOsg19oRxbcPIkTZW3xJ4Z+DiO3p8kcQnr2+qAJamvWWh6bJscrjW4OhRvsljQ pFqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1ZFhqmrDqdVEYh8EABc8LPovMwxkSLdRJ4AqNYx8lQo=; b=XTQPxIRNTu/Si7dXVefe5Mu9CPisxuPzLKlIMtqKzHdya1vilHk4v5rSJzRmFxKRng AziDsK9r36CLw6oZFqX/HHnjaRGpjFSAXgMKCJefiCcqyS/Zwyl3pWDsgAaz4wLpRAiM aXFvWa5f92FRYUHuhj7tshA+rM/YQH5OyrgciOJFQCXc7Oz3ItzrpuOpWWiVVxMAp7ax 4dRujeLl6ZAnjwwBJUn/KDU/EkoaGnyEdUlraVkc5h1icOVtmHQUX+bBtD2IT7Hz1NtY kAFg0KcnWD+hSmpaZx52QuNDW5kq/0r/nolkTLIk4UTX8t+GlB1/cHsQlY48ULBuNoo1 5EgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=iZUI2QrU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id p17-20020adf9d91000000b0020cdff2f70asi3437724wre.847.2022.05.13.20.10.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:10:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=iZUI2QrU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 22B433CB2DF; Fri, 13 May 2022 16:51:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384512AbiEMUcl (ORCPT + 99 others); Fri, 13 May 2022 16:32:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384476AbiEMUas (ORCPT ); Fri, 13 May 2022 16:30:48 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D4AF78924; Fri, 13 May 2022 13:30:01 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: nicolas) with ESMTPSA id 098C41F46484 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1652473792; bh=/HUm+2tIimTRRFVj71OaFyqc2Gk4HBundroiAuGI1EY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iZUI2QrUdNrjgYRKH8Evuj3VNdhydoESdxJ0hiTMRmlNUijZoRZfLwt6Bb++CbrZC GNNaE3CEmKeSdOajaCYNS6ECqplCV/2Jms6LFKRgXtoCW6TktozZiDkZqXkbnKlsUp CY5boNhczvZfmK2jkzLEuvp7+NutQRnY17z6jTj9Gy9zrhxrxxk1nDopkA/RxJFA5d P3CFHHQQj8/Lrn5zYVTk/aLO7zj9QGBgM2WZLrVAxY9O5WAphypJrPjHMx0Ik4ZjHT uLGxlWw+GiCWDF+DjkMR6FU5sfWbQdtxvLpObdewkrX3T/v0I4P9vNl1YFS8+a0zOj o6AYUdJCO739g== From: Nicolas Dufresne To: Ezequiel Garcia , Mauro Carvalho Chehab , Greg Kroah-Hartman Cc: nicolas@ndufresne.ca, linux-media@vger.kernel.org, Hans Verkuil , linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v5 11/20] media: rkvdec: Move H264 SPS validation in rkvdec-h264 Date: Fri, 13 May 2022 16:29:13 -0400 Message-Id: <20220513202922.13846-12-nicolas.dufresne@collabora.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220513202922.13846-1-nicolas.dufresne@collabora.com> References: <20220513202922.13846-1-nicolas.dufresne@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org No functional change, this moves H264 specific validation into the H264 specific code. This is in preparation of improving this validation and reusing it when VIDIOC_STREAMON is called. Signed-off-by: Nicolas Dufresne Reviewed-by: Ezequiel Garcia Signed-off-by: Hans Verkuil --- drivers/staging/media/rkvdec/rkvdec-h264.c | 23 ++++++++++++++++++++++ drivers/staging/media/rkvdec/rkvdec.c | 23 ++++++---------------- drivers/staging/media/rkvdec/rkvdec.h | 1 + 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/drivers/staging/media/rkvdec/rkvdec-h264.c b/drivers/staging/media/rkvdec/rkvdec-h264.c index 8d44a884a52e..0dcbcb1bac80 100644 --- a/drivers/staging/media/rkvdec/rkvdec-h264.c +++ b/drivers/staging/media/rkvdec/rkvdec-h264.c @@ -1137,9 +1137,32 @@ static int rkvdec_h264_run(struct rkvdec_ctx *ctx) return 0; } +static int rkvdec_h264_try_ctrl(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl) +{ + if (ctrl->id == V4L2_CID_STATELESS_H264_SPS) { + const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps; + /* + * TODO: The hardware supports 10-bit and 4:2:2 profiles, + * but it's currently broken in the driver. + * Reject them for now, until it's fixed. + */ + if (sps->chroma_format_idc > 1) + /* Only 4:0:0 and 4:2:0 are supported */ + return -EINVAL; + if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8) + /* Luma and chroma bit depth mismatch */ + return -EINVAL; + if (sps->bit_depth_luma_minus8 != 0) + /* Only 8-bit is supported */ + return -EINVAL; + } + return 0; +} + const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops = { .adjust_fmt = rkvdec_h264_adjust_fmt, .start = rkvdec_h264_start, .stop = rkvdec_h264_stop, .run = rkvdec_h264_run, + .try_ctrl = rkvdec_h264_try_ctrl, }; diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c index 2df8cf4883e2..e3d44d5b35f3 100644 --- a/drivers/staging/media/rkvdec/rkvdec.c +++ b/drivers/staging/media/rkvdec/rkvdec.c @@ -29,23 +29,12 @@ static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl) { - if (ctrl->id == V4L2_CID_STATELESS_H264_SPS) { - const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps; - /* - * TODO: The hardware supports 10-bit and 4:2:2 profiles, - * but it's currently broken in the driver. - * Reject them for now, until it's fixed. - */ - if (sps->chroma_format_idc > 1) - /* Only 4:0:0 and 4:2:0 are supported */ - return -EINVAL; - if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8) - /* Luma and chroma bit depth mismatch */ - return -EINVAL; - if (sps->bit_depth_luma_minus8 != 0) - /* Only 8-bit is supported */ - return -EINVAL; - } + struct rkvdec_ctx *ctx = container_of(ctrl->handler, struct rkvdec_ctx, ctrl_hdl); + const struct rkvdec_coded_fmt_desc *desc = ctx->coded_fmt_desc; + + if (desc->ops->try_ctrl) + return desc->ops->try_ctrl(ctx, ctrl); + return 0; } diff --git a/drivers/staging/media/rkvdec/rkvdec.h b/drivers/staging/media/rkvdec/rkvdec.h index 2f4ea1786b93..9df0fba799a4 100644 --- a/drivers/staging/media/rkvdec/rkvdec.h +++ b/drivers/staging/media/rkvdec/rkvdec.h @@ -72,6 +72,7 @@ struct rkvdec_coded_fmt_ops { void (*done)(struct rkvdec_ctx *ctx, struct vb2_v4l2_buffer *src_buf, struct vb2_v4l2_buffer *dst_buf, enum vb2_buffer_state result); + int (*try_ctrl)(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl); }; struct rkvdec_coded_fmt_desc { -- 2.34.3