Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp708853imm; Wed, 13 Jun 2018 07:09:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIyOBCDqiHuQAo9Hig01FKR8OeftciSvzA0/U3Goe53fP4eWRujEt/73Rb2F/fmVfNPDqge X-Received: by 2002:a17:902:8e87:: with SMTP id bg7-v6mr5357209plb.129.1528898950587; Wed, 13 Jun 2018 07:09:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528898950; cv=none; d=google.com; s=arc-20160816; b=d1tuZCXbExhZsyRqK7qtEQb8913EvgCEJGRYxXnIZdIei5BgOyEzeEgSYd+ZWClCuJ kpsOxzVRpU72qE+75oK11kuBBziN+RgNfsGk4Za+FfvE2mvKxuDbcXW1+f4of9P+rzOL Xe4jjB0j7g2wd7t5nX8o6YjlaaAdz5CAmU+fyPQGi4hXv8sj4S6ZTjcnbVX6m2u6ibMK IVXSEaRWS8QIJFwYG7VWuxSia/LRGiQcZ75+xZKDXJ/zf2fDMods5Xx+P1L58Cia9jPR wQr0X0WVHSpIPHHMh7aEDdG1x/0lx8kMNmyLmk4XGaR609JKjda8ia7jqhumJ+VvDqc4 tQqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=BfmcqQD22rZ5YZtpvpMvXQBrgEbJhhp79r25Q21I2tI=; b=P388EYt5zgQCbdpRKQCKbJUo7boblvLEqRrohl/cjyUpvVNGBF/XfK/dnoa98p/A1L Mk0s4je0happBWZXVP9fuydGnHULhjECJxMIvfkNHcmcRzRYVi9DuIw3FchVjj7yADPa wDrOqJ9VFG8a1MwDqiWJQjR0GoU+Z1TZgyFFK3XfLR+awmgRPgeszEmHRJAI5CuTGt/H dQJg6Eab2tPvIHc+gKwwPeb2t1BGOqquAJ0Dp3ak/9go9Vq5+VjXEhC2JE7E9yehRBhW pxKyymVpw5pfhm64Knj4WNl8iWQ+P/UbJisABSYs+Rx8YUQTnqfdN5VBI1UnAzAZSYML Losw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s9-v6si2799278pfm.85.2018.06.13.07.08.56; Wed, 13 Jun 2018 07:09:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964783AbeFMOHf (ORCPT + 99 others); Wed, 13 Jun 2018 10:07:35 -0400 Received: from mail.bootlin.com ([62.4.15.54]:52480 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935750AbeFMOHc (ORCPT ); Wed, 13 Jun 2018 10:07:32 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id E338A20A46; Wed, 13 Jun 2018 16:07:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (AAubervilliers-681-1-37-30.w90-88.abo.wanadoo.fr [90.88.156.30]) by mail.bootlin.com (Postfix) with ESMTPSA id DD31D20A58; Wed, 13 Jun 2018 16:07:19 +0200 (CEST) From: Maxime Ripard To: hans.verkuil@cisco.com, acourbot@chromium.org, sakari.ailus@linux.intel.com, Laurent Pinchart Cc: tfiga@chromium.org, posciak@chromium.org, Paul Kocialkowski , Chen-Yu Tsai , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, nicolas.dufresne@collabora.com, jenskuske@gmail.com, linux-sunxi@googlegroups.com, Thomas Petazzoni , Maxime Ripard Subject: [PATCH 8/9] media: cedrus: Add start and stop decoder operations Date: Wed, 13 Jun 2018 16:07:13 +0200 Message-Id: <20180613140714.1686-9-maxime.ripard@bootlin.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180613140714.1686-1-maxime.ripard@bootlin.com> References: <20180613140714.1686-1-maxime.ripard@bootlin.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some codec needs to perform some additional task when a decoding is started and stopped, and not only at every frame. For example, the H264 decoding support needs to allocate buffers that will be used in the decoding process, but do not need to change over time, or at each frame. In order to allow that for codecs, introduce a start and stop hook that will be called if present at start_streaming and stop_streaming time. Signed-off-by: Maxime Ripard --- .../platform/sunxi/cedrus/sunxi_cedrus_common.h | 2 ++ .../platform/sunxi/cedrus/sunxi_cedrus_video.c | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_common.h b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_common.h index a2a507eb9fc9..20c78ec1f037 100644 --- a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_common.h +++ b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_common.h @@ -120,6 +120,8 @@ struct sunxi_cedrus_dec_ops { enum sunxi_cedrus_irq_status (*irq_status)(struct sunxi_cedrus_ctx *ctx); void (*setup)(struct sunxi_cedrus_ctx *ctx, struct sunxi_cedrus_run *run); + int (*start)(struct sunxi_cedrus_ctx *ctx); + void (*stop)(struct sunxi_cedrus_ctx *ctx); void (*trigger)(struct sunxi_cedrus_ctx *ctx); }; diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.c b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.c index fb7b081a5bb7..d93461178857 100644 --- a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.c +++ b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.c @@ -416,6 +416,8 @@ static int sunxi_cedrus_buf_prepare(struct vb2_buffer *vb) static int sunxi_cedrus_start_streaming(struct vb2_queue *q, unsigned int count) { struct sunxi_cedrus_ctx *ctx = vb2_get_drv_priv(q); + struct sunxi_cedrus_dev *dev = ctx->dev; + int ret = 0; switch (ctx->vpu_src_fmt->fourcc) { case V4L2_PIX_FMT_MPEG2_FRAME: @@ -425,16 +427,26 @@ static int sunxi_cedrus_start_streaming(struct vb2_queue *q, unsigned int count) return -EINVAL; } - return 0; + if (V4L2_TYPE_IS_OUTPUT(q->type) && + dev->dec_ops[ctx->current_codec]->start) + ret = dev->dec_ops[ctx->current_codec]->start(ctx); + + return ret; } static void sunxi_cedrus_stop_streaming(struct vb2_queue *q) { struct sunxi_cedrus_ctx *ctx = vb2_get_drv_priv(q); + struct sunxi_cedrus_dev *dev = ctx->dev; struct vb2_v4l2_buffer *vbuf; unsigned long flags; flush_scheduled_work(); + + if (V4L2_TYPE_IS_OUTPUT(q->type) && + dev->dec_ops[ctx->current_codec]->stop) + dev->dec_ops[ctx->current_codec]->stop(ctx); + for (;;) { spin_lock_irqsave(&ctx->dev->irq_lock, flags); -- 2.17.0