Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2199167imm; Thu, 21 Jun 2018 08:39:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJX4XCs5V63L3S5zbeqGtLDEAh1DIlxD1811UmiUiMbrH/xZ8VHtulhg9eBc9owqMp6HS2A X-Received: by 2002:a17:902:b60c:: with SMTP id b12-v6mr29218994pls.44.1529595578158; Thu, 21 Jun 2018 08:39:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529595578; cv=none; d=google.com; s=arc-20160816; b=rDwSzXGHsrZRPm3XW4W9S9JhbHtJev0xlbknaTQtp1yyHqFLagqfpOZWjB6Iu1y9uV PVGLIkafzQFKYzNCjEcBx7wRmASm6+ExmLINS6YXw/3vOMz592D4jhdbZzwyyMrU7zca 7KOqxMtlJ78gazoneWvTWZMML2n9zWSDI0Ts02rbXysC2+GmieZwTLW4Bu7DkHOXlrhW fdW+kD2+FLmylPMSXYjUWnIwYsnDkwbKXjfx7kWbrik5K6aYleoz7D7J60qjXBkdgcL2 f/mXh+KYJnt14udi73EHGUgAMeBNES8kj8xmmaT8Urn+R8aj5dPwMZPQWHGHzDXLurcw 24ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:organization:references :in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=M30CVXdCRRNYY5DJEdiiW0Mj5olx+LUAOAH4BEG8+0Q=; b=oInwmgsu9XIQxNcwlipEuQtJbK6PQNBBQZtFFgoGGRlLD4yF4zTODStRyO1hwVgzOL qfd9b44w4t2bCDRr6DkANNs3dPWGbcrkU0ZbZUZp3dlcZBzJdgNCAj4XETedaOptZZmU AoirRjs/BrumHk/R+6DV+FUTs9dTtUza/sKgPwXN7fTIXB7yZ1hX99k3Rz5tIyzRcAz0 gs8FL28z+zYfUrxOF75xsX3zA77C/3kghWiTvbYXzxJmHpjlRNiZbqRccB/LQQEb1Qkj qAt4x1wTZj2WqcPCsreuLxmkgZxS4W4LFjhzrkRNLCYgU7n+7Net3OM7k8dNnTE60Pia Q8iQ== 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 m9-v6si4313534pgr.148.2018.06.21.08.39.23; Thu, 21 Jun 2018 08:39:38 -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 S933323AbeFUPi1 (ORCPT + 99 others); Thu, 21 Jun 2018 11:38:27 -0400 Received: from mail.bootlin.com ([62.4.15.54]:57201 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933188AbeFUPiZ (ORCPT ); Thu, 21 Jun 2018 11:38:25 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 7F3312073C; Thu, 21 Jun 2018 17:38:23 +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 aptenodytes (AAubervilliers-681-1-50-153.w90-88.abo.wanadoo.fr [90.88.168.153]) by mail.bootlin.com (Postfix) with ESMTPSA id 1108B206A0; Thu, 21 Jun 2018 17:38:23 +0200 (CEST) Message-ID: Subject: Re: [PATCH 8/9] media: cedrus: Add start and stop decoder operations From: Paul Kocialkowski To: Maxime Ripard , hans.verkuil@cisco.com, acourbot@chromium.org, sakari.ailus@linux.intel.com, Laurent Pinchart Cc: tfiga@chromium.org, posciak@chromium.org, 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 Date: Thu, 21 Jun 2018 17:38:23 +0200 In-Reply-To: <20180613140714.1686-9-maxime.ripard@bootlin.com> References: <20180613140714.1686-1-maxime.ripard@bootlin.com> <20180613140714.1686-9-maxime.ripard@bootlin.com> Organization: Bootlin Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-ni+hXRL3y8E4UMCwvjZ0" X-Mailer: Evolution 3.28.2 Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-ni+hXRL3y8E4UMCwvjZ0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Wed, 2018-06-13 at 16:07 +0200, Maxime Ripard wrote: > Some codec needs to perform some additional task when a decoding is start= ed > and stopped, and not only at every frame. >=20 > For example, the H264 decoding support needs to allocate buffers that wil= l > be used in the decoding process, but do not need to change over time, or = at > each frame. >=20 > 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. >=20 > 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(-) >=20 > 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); > }; > =20 > diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.c b/d= rivers/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 in= t count) > { > struct sunxi_cedrus_ctx *ctx =3D vb2_get_drv_priv(q); > + struct sunxi_cedrus_dev *dev =3D ctx->dev; > + int ret =3D 0; > =20 > 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; > } > =20 > - return 0; > + if (V4L2_TYPE_IS_OUTPUT(q->type) && I suppose this check was put in place to ensure that ->start is only called once, but what if start_streaming is called multiple times on output? Am I totally unsure about whether the API guarantees that we only get one start_streaming call per buffer queue, regardless of how many userspace issues. If we don't have such a guarantee, we probably need an internal mechanism to avoid having ->start called more than once. > + dev->dec_ops[ctx->current_codec]->start) > + ret =3D dev->dec_ops[ctx->current_codec]->start(ctx); > + > + return ret; > } > =20 > static void sunxi_cedrus_stop_streaming(struct vb2_queue *q) > { > struct sunxi_cedrus_ctx *ctx =3D vb2_get_drv_priv(q); > + struct sunxi_cedrus_dev *dev =3D ctx->dev; > struct vb2_v4l2_buffer *vbuf; > unsigned long flags; > =20 > flush_scheduled_work(); > + > + if (V4L2_TYPE_IS_OUTPUT(q->type) && Ditto. Cheers, Paul > + dev->dec_ops[ctx->current_codec]->stop) > + dev->dec_ops[ctx->current_codec]->stop(ctx); > + > for (;;) { > spin_lock_irqsave(&ctx->dev->irq_lock, flags); > =20 --=20 Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com --=-ni+hXRL3y8E4UMCwvjZ0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEJZpWjZeIetVBefti3cLmz3+fv9EFAlsrxm8ACgkQ3cLmz3+f v9G/PAf/TkeDe68tjgtNF820SRelVCY6scJMhqkEY8dsvauKOhKNE9y4yRrRoWFS INc3FukkeeIPcwLG6Q+H3T37p93+ml8EXeEjpJIMvvPP+hWRiWJywSoLw4CeQW/I ChxY5q/h/XVHydQoUhWHK+905iJCA5d6Vub9vwjNaY5NdtGOM6YFcyAr+pcY/afK HTRYtpnkCgX75jGvlbMcrT6Ncjda5DXXsNMctbroH3YGZdiBry+JAIR2RRVQePl+ 4oAf1eU1MlKuxGkoKzeHFL9MjiA2UQxirKtRV8doLzlxUyBtuy7HQ3IC7vL9JONg VIS48xrU5XGgkbsj3sw1ddW96t+FCw== =Uu7e -----END PGP SIGNATURE----- --=-ni+hXRL3y8E4UMCwvjZ0--