From patchwork Wed Apr 3 22:14:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E6FFB922 for ; Wed, 3 Apr 2019 22:18:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA097285D9 for ; Wed, 3 Apr 2019 22:18:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8DEA28985; Wed, 3 Apr 2019 22:18:11 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 56A6F285D9 for ; Wed, 3 Apr 2019 22:18:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726471AbfDCWSK (ORCPT ); Wed, 3 Apr 2019 18:18:10 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:34558 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726458AbfDCWSK (ORCPT ); Wed, 3 Apr 2019 18:18:10 -0400 Received: by mail-wm1-f68.google.com with SMTP id r186so5819418wmf.1 for ; Wed, 03 Apr 2019 15:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SQGF3TuNF5KQ0AO+rkzzO1v78UFk3o3QLb/PiuS736c=; b=OR7/2a2Bg+GdNhtJ5Xww2FfSGIiMFFmv95n3XYZitoT7iQc4/S406G9CJGvmYb2hLI VxB2l1RLQjcRN3Vyyz6YOhb6YuAaz/Hm/oepOFtE7OoYgcbv3iJP9XEZoMwYNOSBPiZL tlE2gsFyCj7o51j392++sJBqs9kxluo+tapJ9KI6Z3MbaH1N7rsqNovl9dt8v/1hkHGL tjrwVX60u9EDOcAGtn47Zz9kKJLl+oXKcDfgMjfkc/nPJBuF2WZF2PiYJE3f8cACSi9J NewI8w689b495oOYAMnFyQMJ7aSqA+fGvdbqAMCMXvMw9ngoTdzavqKO3+E3vl7JB5ZE g/+w== 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:in-reply-to :references; bh=SQGF3TuNF5KQ0AO+rkzzO1v78UFk3o3QLb/PiuS736c=; b=Wls/X7Od6gOt+5M6Y6aY7keD2DZ8wAEZUynJ+i77TL9Od70Phcxj2Cr95xEd9NG8SB 5JLkfA8MQ+eXrQtI0kJWKfgtGx/wXoAmoUt17ksGkkQO1kuJReb3HAlVgQVBl+9GcaAj cGWGxo84+Lx6Sb/BO6aN99oVKeDdlblWqsuDn8EjWdBg5EO4G+uANgSTrMnXX2DPnKcq UWAUTFML6XFSnoqHZ2ot5lgxpBwOm/FwBLVae0rRD7LHB6dRhlhV/0Z3/tuyck4F+N+S llrgmVDOHBHTOybj6QZ9CQdEwdiXp+uuRrOLJXaQOIiDpCqEcfzkMEKwxFyz5EL7eCXB 0d8Q== X-Gm-Message-State: APjAAAWRIqqmmmk9TjvZ4dvqSiWWNAKeuMQpREQSke7owOI3TnHfdEbP VyUUfQSVl/Q9tfFih5s2+iU= X-Google-Smtp-Source: APXvYqxIOBa8FHBEABikwi1OVgv/83p6eKeiAM6qx3ow84u8ZhxHZABt+/peayl/dJBIjFMOySsGfw== X-Received: by 2002:a1c:804c:: with SMTP id b73mr1536949wmd.116.1554329889070; Wed, 03 Apr 2019 15:18:09 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:08 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH v2 01/16] videobuf2-v4l2: set last_buffer_dequeued in dqbuf Date: Wed, 3 Apr 2019 15:14:46 -0700 Message-Id: <20190403221501.32814-2-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 From: Hans Verkuil last_buffer_dequeued was set to true in __fill_v4l2_buffer, but this is called for qbuf as well. Move it to vb2_dqbuf. Signed-off-by: Hans Verkuil --- drivers/media/common/videobuf2/videobuf2-v4l2.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index b11a779e97b0..379738372651 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -562,11 +562,6 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, void *pb) b->flags |= V4L2_BUF_FLAG_REQUEST_FD; b->request_fd = vbuf->request_fd; } - - if (!q->is_output && - b->flags & V4L2_BUF_FLAG_DONE && - b->flags & V4L2_BUF_FLAG_LAST) - q->last_buffer_dequeued = true; } /* @@ -785,6 +780,11 @@ int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking) ret = vb2_core_dqbuf(q, NULL, b, nonblocking); + if (!q->is_output && + b->flags & V4L2_BUF_FLAG_DONE && + b->flags & V4L2_BUF_FLAG_LAST) + q->last_buffer_dequeued = true; + /* * After calling the VIDIOC_DQBUF V4L2_BUF_FLAG_DONE must be * cleared. From patchwork Wed Apr 3 22:14:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE5391575 for ; Wed, 3 Apr 2019 22:18:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D71212897F for ; Wed, 3 Apr 2019 22:18:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBAF728985; Wed, 3 Apr 2019 22:18:13 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 7C8D62897F for ; Wed, 3 Apr 2019 22:18:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726425AbfDCWSM (ORCPT ); Wed, 3 Apr 2019 18:18:12 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:40376 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726199AbfDCWSM (ORCPT ); Wed, 3 Apr 2019 18:18:12 -0400 Received: by mail-wm1-f67.google.com with SMTP id z24so664208wmi.5 for ; Wed, 03 Apr 2019 15:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/mdSvbwVZIpZIZzlf5bj5jBFsCqVjD3mBJ1uu40zFq0=; b=cIYFKvnOf1XhWwc/iSILDJOb6JW0i748qGDvuMbdXwQnwXDZCNsB699ShbvNUy1Xzo qyg5GNZWhLm0OqMLdpTfN7DT0hdAtCwSh7lxx0wWnYgnK/06EyJMDpn78Ip7gzrOkMwG 2FRj3p14F5E7EdHshK4qEXeesWtlpBvABIKNXZ7m5PQAU3QB0E2SmGwhKyCXUVgbgZ9N KHSyNfQzhCUHLX2LNl4F9NUt+n5kHjwa2qIhW8KIZ7i71gN4z/KtaAxyUMRiF4fC1WDC 3X8U4vUy+XNQtI4ma9L/QgYac1E7IYTD5BwdAjzaFkxecEH+9oYzCytTjGCtEdmpTIG8 lPzQ== 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:in-reply-to :references; bh=/mdSvbwVZIpZIZzlf5bj5jBFsCqVjD3mBJ1uu40zFq0=; b=QpFAeht9St3xzE/h9XA9XosCf3XLaIcDZx7i+pxBaar96gRZdxtGT5XKrWPBruK3vI yrAomoTOv4dupHFDEjJqrLqPCb3l9J2UCtU6/rFv/tj4VFv8V2K7M/uJhZ+a/smp9bn1 gRSifFJgC1xOb5Xwp75O448pSSVGgHDquvWjwzb/WqoabRZrHQtK353lN1m94MGdkkdy ax/yMhe6JVenLfawdfxpWHu2deMjxj97sDVWBFDOfP7Rs0Vua/aJIslxBCQtAQyMf2Sv ix7Rc4/enjZBn4SzOteDjalPnwbAJnyV7MUl1BIrRJ8Vy2mPkRjRd8M90MSm4DEll3Fw xtvA== X-Gm-Message-State: APjAAAVT24rvB9rqyvR5YEOp+6n+g1zZjyDRMQLefVjbbSAJDEWetYsz +GmBKpM8eGhqg0NZu8TgxNY= X-Google-Smtp-Source: APXvYqwomsLMXoOnpLmC5lPXUGi52B7mLyYDSl3UntpZXrZeH5lXvKQLHwh6onMj38fLtu9Zdmaoxg== X-Received: by 2002:a1c:f10f:: with SMTP id p15mr1598400wmh.27.1554329890278; Wed, 03 Apr 2019 15:18:10 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:09 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH v2 02/16] vicodec: move v4l2_ctrl_request_complete after spin_unlock Date: Wed, 3 Apr 2019 15:14:47 -0700 Message-Id: <20190403221501.32814-3-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 From: Hans Verkuil v4l2_ctrl_request_complete can sleep, so can't be called while a spinlock is held. Signed-off-by: Hans Verkuil --- drivers/media/platform/vicodec/vicodec-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index bd01a9206aa6..92647f02fc49 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -442,14 +442,14 @@ static void device_run(void *priv) ctx->comp_has_next_frame = false; } v4l2_m2m_buf_done(dst_buf, state); - if (ctx->is_stateless && src_req) - v4l2_ctrl_request_complete(src_req, &ctx->hdl); ctx->comp_size = 0; ctx->header_size = 0; ctx->comp_magic_cnt = 0; ctx->comp_has_frame = false; spin_unlock(ctx->lock); + if (ctx->is_stateless && src_req) + v4l2_ctrl_request_complete(src_req, &ctx->hdl); if (ctx->is_enc) v4l2_m2m_job_finish(dev->stateful_enc.m2m_dev, ctx->fh.m2m_ctx); From patchwork Wed Apr 3 22:14:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884577 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27047922 for ; Wed, 3 Apr 2019 22:18:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EEE12897F for ; Wed, 3 Apr 2019 22:18:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 033C128985; Wed, 3 Apr 2019 22:18:15 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 976DB2897F for ; Wed, 3 Apr 2019 22:18:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726494AbfDCWSO (ORCPT ); Wed, 3 Apr 2019 18:18:14 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:40986 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726387AbfDCWSN (ORCPT ); Wed, 3 Apr 2019 18:18:13 -0400 Received: by mail-wr1-f67.google.com with SMTP id r4so870410wrq.8 for ; Wed, 03 Apr 2019 15:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Fy2qFD74zdUbAe78wnfHfXfNlPMXRBU6r8h3CmVtLrU=; b=pqz5WkD8g5g2FdE2jB5RERZkQu26xUyXOqEnvRxWNFNh93CPao2vhBykn6LQNAbzFo LU+MHz3KuZmrVIwcKDsJLduaDwGWo1+bt7cmjpMqOuUTrXydf8Ny1nJOwEkq5shSZZQ6 NwkvBNC9LjBHIcL4m0+cerjgLpv44/2xIZqe6j1/FoGW85m6fqE+JD/IzzQabRsAUC67 85Wj5mmyx6eazuKPGSQOQ6Fgkhqfgu/dLXNn6W8r8/xu7vwigbBG98uCjTjDl5LFqkwO raUvCxaRL5oj9MGlEGHiDb3Iylh+NIf+NjY+GfS1gqcA8nC6xF1AqDwWklCB13Dbqz8J jUUg== 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:in-reply-to :references; bh=Fy2qFD74zdUbAe78wnfHfXfNlPMXRBU6r8h3CmVtLrU=; b=Y+cGiOqFR1ThW3rrleYQ3TGRcVaTwWdQQuRakvX4H+99//3jYUDcKieL9oWCmeCekn DYMjTcYJU3zSdiCMhmIqbeqZcR4Y++XmOfMrDIIMAZB4K+zl3KS5jQt/QCDWcUYwSn8O 0que6H6M9aQQ+6h6+kCxUKoTAif9BZ+TwnsCHAFI/dDeYvZK1TUT43yNxkUS7VK32pS/ KrZ/f6kJlDbUsqKGrQbhSqRNxVRw/XSEf/pG37SBHP0pggxXX2Qp8Bzh5txRrMiy1LkB V6dZ8mhG7+41srk2Ekc+24hAA/P2QeoNcK3+BbzoucR3eqP1AtxfMMtbxp8j2Dx1vaHv dtcw== X-Gm-Message-State: APjAAAWKMYugllWfSEimfppauMNJqbh1+C0grW3Q22XpHHO2w2l11Ohm OtYDXB1stMij9vro60rYKRY= X-Google-Smtp-Source: APXvYqzVZjSRK5PDXpaiN0MmF76uXXpIrZD0AUxuutDYzm0Q//lni8jLjcFTXN+A4SxZO3fjJ5vCqQ== X-Received: by 2002:a5d:68cf:: with SMTP id p15mr1281609wrw.301.1554329891578; Wed, 03 Apr 2019 15:18:11 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:10 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH v2 03/16] vicodec: always return a valid format. Date: Wed, 3 Apr 2019 15:14:48 -0700 Message-Id: <20190403221501.32814-4-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 From: Hans Verkuil Rather than returning width/height values of 0, just default to a format. Formats in V4L2 are always supposed to be valid, there is no concept of an invalid format. Signed-off-by: Hans Verkuil --- drivers/media/platform/vicodec/vicodec-core.c | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 92647f02fc49..aa3af796929b 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -1771,11 +1771,13 @@ static const struct v4l2_ctrl_config vicodec_ctrl_stateless_state = { */ static int vicodec_open(struct file *file) { + const struct v4l2_fwht_pixfmt_info *info = v4l2_fwht_get_pixfmt(0); struct video_device *vfd = video_devdata(file); struct vicodec_dev *dev = video_drvdata(file); struct vicodec_ctx *ctx = NULL; struct v4l2_ctrl_handler *hdl; - unsigned int size; + unsigned int raw_size; + unsigned int comp_size; int rc = 0; if (mutex_lock_interruptible(vfd->lock)) @@ -1814,7 +1816,7 @@ static int vicodec_open(struct file *file) v4l2_ctrl_handler_setup(hdl); if (ctx->is_enc) - ctx->q_data[V4L2_M2M_SRC].info = v4l2_fwht_get_pixfmt(0); + ctx->q_data[V4L2_M2M_SRC].info = info; else if (ctx->is_stateless) ctx->q_data[V4L2_M2M_SRC].info = &pixfmt_stateless_fwht; else @@ -1823,22 +1825,22 @@ static int vicodec_open(struct file *file) ctx->q_data[V4L2_M2M_SRC].coded_height = 720; ctx->q_data[V4L2_M2M_SRC].visible_width = 1280; ctx->q_data[V4L2_M2M_SRC].visible_height = 720; - size = 1280 * 720 * ctx->q_data[V4L2_M2M_SRC].info->sizeimage_mult / - ctx->q_data[V4L2_M2M_SRC].info->sizeimage_div; + raw_size = 1280 * 720 * info->sizeimage_mult / info->sizeimage_div; + comp_size = 1280 * 720 * pixfmt_fwht.sizeimage_mult / + pixfmt_fwht.sizeimage_div; if (ctx->is_enc || ctx->is_stateless) - ctx->q_data[V4L2_M2M_SRC].sizeimage = size; + ctx->q_data[V4L2_M2M_SRC].sizeimage = raw_size; else ctx->q_data[V4L2_M2M_SRC].sizeimage = - size + sizeof(struct fwht_cframe_hdr); + comp_size + sizeof(struct fwht_cframe_hdr); + ctx->q_data[V4L2_M2M_DST] = ctx->q_data[V4L2_M2M_SRC]; if (ctx->is_enc) { - ctx->q_data[V4L2_M2M_DST] = ctx->q_data[V4L2_M2M_SRC]; ctx->q_data[V4L2_M2M_DST].info = &pixfmt_fwht; - ctx->q_data[V4L2_M2M_DST].sizeimage = 1280 * 720 * - ctx->q_data[V4L2_M2M_DST].info->sizeimage_mult / - ctx->q_data[V4L2_M2M_DST].info->sizeimage_div + - sizeof(struct fwht_cframe_hdr); + ctx->q_data[V4L2_M2M_DST].sizeimage = + comp_size + sizeof(struct fwht_cframe_hdr); } else { - ctx->q_data[V4L2_M2M_DST].info = NULL; + ctx->q_data[V4L2_M2M_DST].info = info; + ctx->q_data[V4L2_M2M_DST].sizeimage = raw_size; } ctx->state.colorspace = V4L2_COLORSPACE_REC709; From patchwork Wed Apr 3 22:14:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB667922 for ; Wed, 3 Apr 2019 22:18:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93B932897F for ; Wed, 3 Apr 2019 22:18:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 884F328986; Wed, 3 Apr 2019 22:18:16 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 1C8C62897F for ; Wed, 3 Apr 2019 22:18:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726528AbfDCWSP (ORCPT ); Wed, 3 Apr 2019 18:18:15 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:54655 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726199AbfDCWSO (ORCPT ); Wed, 3 Apr 2019 18:18:14 -0400 Received: by mail-wm1-f65.google.com with SMTP id c1so563730wml.4 for ; Wed, 03 Apr 2019 15:18:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WM4V9PQvsPngXYIkdD5A0deEFdEL42tCk3s3+5JpINs=; b=EjimXlkg+ZnY+/d3tDY8BhOZEaejNSkFbIAkAQ+kR7z1Bc+TTO7QERXQpZ/xofY+Q+ PYWA9cG5Qr/GNCYmDNKzJQfs5S92ia0jKLcEF6eiCy/taQpSMJ7nxxnAyseRigiDfbQB neCSH8BjTjTo+tXoCGY3Fcj4mEkWI3IeeXvuyUzVNw0ejitn0nc8CLSLrVIdgzhn1F83 BOofxNBzRyk0t0qcpW6EfQRIgeragFPtcru+qAlZe31H/LmE2o8pGLhgVSHPZDuF9unP ABhUzuxuP1cUpb05RoA8hcGkS7iqSoDHqybJ0WSqkT6RODIdb45C2o2Mj+6g5iqI1oEW QfGg== 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:in-reply-to :references; bh=WM4V9PQvsPngXYIkdD5A0deEFdEL42tCk3s3+5JpINs=; b=XgeFm37OEY0EbTajdVLd2jd89UiEhSNybxDIR0XAzHkAG0wiRRjaNz6lkChE5prQgd M3BEskX/DDhLnNvpKmsYskCXRpzzpCnaB9HXRKgz0g4EpXuqsNHEZDlFERtpu1zhWNl/ y3gG3DNW6KuR+q8PqTUjcLo/3z/RYUqYPvrQD5WBgJ61Q00YMVUM5bafGW9hEs0hGp1i jmrBiTaQOIz3dfUa/w3H7edO8gJBDsuHrdGzqIDkUyB/at43++MhumE+xTjPaB1FhjHC E6OQ2+YoU5sxzkbkrWOliTWzb1fikh2XfHbng6SH95PLTeqgDzW/CP021Cr4cZBb/pwB 6GXg== X-Gm-Message-State: APjAAAVkhk4LBiyDjl1S74uqwXzESf+lVx97sWOvnh4El/ihR333Dv2C T9T7kxWdAT+va0h9nb0ppIE= X-Google-Smtp-Source: APXvYqxF7j4Nq1gRMtpfGut7s51lfZgGYhX3OXZfp6sjrQUGXyCqVZ1NdyAEQ4Q5hUTSNZxPkE54yw== X-Received: by 2002:a05:600c:2199:: with SMTP id e25mr1498843wme.36.1554329892980; Wed, 03 Apr 2019 15:18:12 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:12 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH v2 04/16] vicodec: pass on enc output format to capture side Date: Wed, 3 Apr 2019 15:14:49 -0700 Message-Id: <20190403221501.32814-5-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 From: Hans Verkuil Setting the encoder output format to e.g. 1920x1080 will set the crop rectangle to 1920x1080, the coded resolution to 1920x1088 and the capture coded resolution and sizeimage to 1920x1088 as well. Signed-off-by: Hans Verkuil --- drivers/media/platform/vicodec/vicodec-core.c | 64 ++++++++++++++++--- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index aa3af796929b..75b6bc5a6f3b 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -1032,16 +1032,10 @@ static int vidioc_s_fmt(struct vicodec_ctx *ctx, struct v4l2_format *f) default: return -EINVAL; } - if (q_data->visible_width > q_data->coded_width) - q_data->visible_width = q_data->coded_width; - if (q_data->visible_height > q_data->coded_height) - q_data->visible_height = q_data->coded_height; - dprintk(ctx->dev, - "Setting format for type %d, coded wxh: %dx%d, visible wxh: %dx%d, fourcc: %08x\n", + "Setting format for type %d, coded wxh: %dx%d, fourcc: 0x%08x\n", f->type, q_data->coded_width, q_data->coded_height, - q_data->visible_width, q_data->visible_height, q_data->info->id); return 0; @@ -1063,18 +1057,69 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *priv, struct v4l2_format *f) { struct vicodec_ctx *ctx = file2ctx(file); - struct v4l2_pix_format_mplane *pix_mp; + struct vicodec_q_data *q_data; + struct vicodec_q_data *q_data_cap; struct v4l2_pix_format *pix; + struct v4l2_pix_format_mplane *pix_mp; + u32 coded_w = 0, coded_h = 0; + unsigned int size = 0; + u32 w, h; int ret; + if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { + w = f->fmt.pix.width; + h = f->fmt.pix.height; + } else { + w = f->fmt.pix_mp.width; + h = f->fmt.pix_mp.height; + } + q_data = get_q_data(ctx, f->type); + q_data_cap = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); + ret = vidioc_try_fmt_vid_out(file, priv, f); if (ret) return ret; + if (ctx->is_enc) { + struct vb2_queue *vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); + struct vb2_queue *vq_cap = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, + V4L2_BUF_TYPE_VIDEO_CAPTURE); + const struct v4l2_fwht_pixfmt_info *info = ctx->is_stateless ? + &pixfmt_stateless_fwht : &pixfmt_fwht; + + if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { + coded_w = f->fmt.pix.width; + coded_h = f->fmt.pix.height; + } else { + coded_w = f->fmt.pix_mp.width; + coded_h = f->fmt.pix_mp.height; + } + if (vb2_is_busy(vq) && (coded_w != q_data->coded_width || + coded_h != q_data->coded_height)) + return -EBUSY; + size = coded_w * coded_h * + info->sizeimage_mult / info->sizeimage_div; + if (!ctx->is_stateless) + size += sizeof(struct fwht_cframe_hdr); + + if (vb2_is_busy(vq_cap) && size > q_data_cap->sizeimage) + return -EBUSY; + } + ret = vidioc_s_fmt(file2ctx(file), f); if (!ret) { + if (ctx->is_enc) { + q_data->visible_width = w; + q_data->visible_height = h; + q_data_cap->coded_width = coded_w; + q_data_cap->coded_height = coded_h; + if (q_data_cap->sizeimage < size) + q_data_cap->sizeimage = size; + dprintk(ctx->dev, + "Setting output crop to %dx%d\n", w, h); + } + switch (f->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_OUTPUT: pix = &f->fmt.pix; ctx->state.colorspace = pix->colorspace; @@ -1082,7 +1127,6 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *priv, ctx->state.ycbcr_enc = pix->ycbcr_enc; ctx->state.quantization = pix->quantization; break; - case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: pix_mp = &f->fmt.pix_mp; ctx->state.colorspace = pix_mp->colorspace; From patchwork Wed Apr 3 22:14:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76DCB1800 for ; Wed, 3 Apr 2019 22:18:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EF7D285D9 for ; Wed, 3 Apr 2019 22:18:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5351D28989; Wed, 3 Apr 2019 22:18:17 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 08040285D9 for ; Wed, 3 Apr 2019 22:18:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726548AbfDCWSQ (ORCPT ); Wed, 3 Apr 2019 18:18:16 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:37486 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726387AbfDCWSP (ORCPT ); Wed, 3 Apr 2019 18:18:15 -0400 Received: by mail-wm1-f65.google.com with SMTP id v14so678703wmf.2 for ; Wed, 03 Apr 2019 15:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2sPcabTL5atb+mRA0+z8Gv8NLDdZCGeHUnldZdaoJyM=; b=e9uStrygdb6QlSMxVjWvLEeTxMzrOp+fUv7pFYZZ/9jAnWoUhIBnyJhrJI5S2/Odm3 oKqqUpLMsKoBtjdEMR5fBPkMoss9ujPl9LVcvrktTgaGfSLLsXUMSVb5UXxhSUfNMqG1 hgUyJAhOxUrKIQmv3KHeizyw09tUMHjTRf4UGluv057WHzS9AdabnjaYu/Y5HM/C/yx3 cM+jRSgipuNiugxtU0LdEg1eljWOdGE+wd5vt0FcAWC8/oANmV96uaHNqnhQ4u2eFTqI Nue3nfLKmsbufoEy25CEkv6s9ugPSqFiEtiE6UwXrht0cV6BnRY/fJ4FzIixf4OxYK7L lYIQ== 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:in-reply-to :references; bh=2sPcabTL5atb+mRA0+z8Gv8NLDdZCGeHUnldZdaoJyM=; b=Xc/yRbETHOJMGIg5n6EefRj0FxWhVyhM6Fbduj2Yc5/aHcmGy7l37iB7M5xzD+DMOL MKXGgEfyf0Upv/W/f3iT6ah3VS+rq5l+1lhH++k9N6N0GB5DbXavPuUJ3ieii6AeNBp8 uwb8x3qylhrmy8OcscggWdeW1YZyu3qNijKJUi3OHph/nl7PsktVGmlc2Lwo6FzUYyBm i41J2n0nyfGsy3y25YneYj0InNP2TQbc1mRvmlHuoUMtEi+OpGiBEYo2zdJlyM6dJlb7 qFWD7RAcDE6GN34jzHr97A4oh11YIvirxPphG5p3qSt13CkRrD8cc063y05uXrhck3YL 6JdA== X-Gm-Message-State: APjAAAXHUAKoyPimUqOmA4t4TPbtAFQ4dKQBQ4ls/AeSsQwdWJdx/kuF GChnOMhwhXAb67U25T8ArKs= X-Google-Smtp-Source: APXvYqwVhYtP8JtI7g76maUeZg+y3oVW4+OzJtSJUTyV1Db+emPOf6yKXMnhkaEArhn6hZhurhL/qw== X-Received: by 2002:a7b:cd93:: with SMTP id y19mr1566500wmj.113.1554329894191; Wed, 03 Apr 2019 15:18:14 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:13 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH v2 05/16] vicodec: add V4L2_CID_MIN_BUFFERS_FOR_OUTPUT Date: Wed, 3 Apr 2019 15:14:50 -0700 Message-Id: <20190403221501.32814-6-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 From: Hans Verkuil The stateful encoder requires the presence of this control. Since a single buffer is sufficient for vicodec, we just set this control to 1. Signed-off-by: Hans Verkuil --- drivers/media/platform/vicodec/vicodec-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 75b6bc5a6f3b..b3bf5c4d73cd 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -1841,13 +1841,16 @@ static int vicodec_open(struct file *file) file->private_data = &ctx->fh; ctx->dev = dev; hdl = &ctx->hdl; - v4l2_ctrl_handler_init(hdl, 4); + v4l2_ctrl_handler_init(hdl, 5); v4l2_ctrl_new_std(hdl, &vicodec_ctrl_ops, V4L2_CID_MPEG_VIDEO_GOP_SIZE, 1, 16, 1, 10); v4l2_ctrl_new_std(hdl, &vicodec_ctrl_ops, V4L2_CID_FWHT_I_FRAME_QP, 1, 31, 1, 20); v4l2_ctrl_new_std(hdl, &vicodec_ctrl_ops, V4L2_CID_FWHT_P_FRAME_QP, 1, 31, 1, 20); + if (ctx->is_enc) + v4l2_ctrl_new_std(hdl, &vicodec_ctrl_ops, + V4L2_CID_MIN_BUFFERS_FOR_OUTPUT, 1, 1, 1, 1); if (ctx->is_stateless) v4l2_ctrl_new_custom(hdl, &vicodec_ctrl_stateless_state, NULL); if (hdl->error) { From patchwork Wed Apr 3 22:14:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884585 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E97C8922 for ; Wed, 3 Apr 2019 22:18:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D08AD285D9 for ; Wed, 3 Apr 2019 22:18:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4F4F28985; Wed, 3 Apr 2019 22:18:20 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 2FFA4285D9 for ; Wed, 3 Apr 2019 22:18:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726591AbfDCWST (ORCPT ); Wed, 3 Apr 2019 18:18:19 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40822 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726545AbfDCWSS (ORCPT ); Wed, 3 Apr 2019 18:18:18 -0400 Received: by mail-wr1-f68.google.com with SMTP id h4so878781wre.7 for ; Wed, 03 Apr 2019 15:18:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RWUptrEyuF9yugjjCgeYTKgevmbCFUs8gDEKccF/CRM=; b=aztEk3ZzKpttVqwJFVLQ+GNzENVTwbgk1gYdFlocZ7xe1hP+PUx7DJP2/sGFmA3DHU CG/Ui/2aH9+K/hTAtVIMC+0cINlfrKxSHmV/ySa5zW4QLExC+NFQW1kBGcG0ce9hte3/ HlB/LozPY1pzFZz7ex3quCIyajTfwwacHUEXBPxp1a2W4FJFTH6UR1Jostj4/abq6W0Q OjbNytoukgRVz1ejC0R+WS0+xzSrD/qCFVqk+/FkePcHlYF0SGmpGMCYT9QiXkGu2DPU 8jshl1bpoa/22KUg+rJTele1nIblvpRXIyQJQi/tmyuA0NRQndSTTCVhjovi+0GdyP43 Uetw== 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:in-reply-to :references; bh=RWUptrEyuF9yugjjCgeYTKgevmbCFUs8gDEKccF/CRM=; b=Miu8qxIzV45gZ3+1DhTaWjuHbASgmRFlHu5lsgENg9HXEU9vZyOwZY8MxsmmuoRVGL madf0HfTrqrGuCF7eEsCHV6LqYLebzlCgHTWiSf/30zUDe5mrYLW+7zkq8LchtnIkFdp F5biTojzmiAuuGW1H8UpLBRJYMvIyvMAfA90LgZuTYNvSz5NWYIpEi4cR4N/qu7CC2+i ILpsNhUt2W+x84m2xDax5SYIUHl7G4LryNZXHe26L+o9eXUasVb30jTQV8bI9a5rUnRx sqh/oR0VJGNjWDwkY/26q59Ms4/nJi3Hl1DBmphZwkWFXVJh0ReptQ6jdujJyoXqZFjQ PBBg== X-Gm-Message-State: APjAAAU6PAXYHIoBTr+TixRqadq3Fx8f+/JjJ2FgVK8ROhu3NgrcnoaX v/zz5DYRnl/DTAHNY+3RAci3SICEF5o= X-Google-Smtp-Source: APXvYqz6GrAYCSEPOMWEgWQBaYQRWmUKgYo1Oeu74OIu3YoGgrQp3BqsMuoA+S7AbenqMd8j4n+sqA== X-Received: by 2002:a5d:68cd:: with SMTP id p13mr1328366wrw.22.1554329895551; Wed, 03 Apr 2019 15:18:15 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:14 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH v2 06/16] vicodec: improve handling of ENC_CMD_STOP/START Date: Wed, 3 Apr 2019 15:14:51 -0700 Message-Id: <20190403221501.32814-7-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 From: Hans Verkuil Correctly handle stopping and restarting the encoder, keeping track of the stop and drain states. Signed-off-by: Hans Verkuil --- drivers/media/platform/vicodec/vicodec-core.c | 121 +++++++++++++++--- 1 file changed, 100 insertions(+), 21 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index b3bf5c4d73cd..a9a0f6a1b69e 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -116,12 +116,14 @@ struct vicodec_ctx { struct vicodec_dev *dev; bool is_enc; bool is_stateless; + bool is_draining; + bool next_is_last; + bool has_stopped; spinlock_t *lock; struct v4l2_ctrl_handler hdl; struct vb2_v4l2_buffer *last_src_buf; - struct vb2_v4l2_buffer *last_dst_buf; /* Source and destination queue data */ struct vicodec_q_data q_data[2]; @@ -138,6 +140,10 @@ struct vicodec_ctx { bool source_changed; }; +static const struct v4l2_event vicodec_eos_event = { + .type = V4L2_EVENT_EOS +}; + static inline struct vicodec_ctx *file2ctx(struct file *file) { return container_of(file->private_data, struct vicodec_ctx, fh); @@ -397,9 +403,6 @@ static enum vb2_buffer_state get_next_header(struct vicodec_ctx *ctx, /* device_run() - prepares and starts the device */ static void device_run(void *priv) { - static const struct v4l2_event eos_event = { - .type = V4L2_EVENT_EOS - }; struct vicodec_ctx *ctx = priv; struct vicodec_dev *dev = ctx->dev; struct vb2_v4l2_buffer *src_buf, *dst_buf; @@ -423,12 +426,12 @@ static void device_run(void *priv) dst_buf->flags &= ~V4L2_BUF_FLAG_LAST; v4l2_m2m_buf_copy_metadata(src_buf, dst_buf, !ctx->is_enc); - ctx->last_dst_buf = dst_buf; - spin_lock(ctx->lock); if (!ctx->comp_has_next_frame && src_buf == ctx->last_src_buf) { dst_buf->flags |= V4L2_BUF_FLAG_LAST; - v4l2_event_queue_fh(&ctx->fh, &eos_event); + v4l2_event_queue_fh(&ctx->fh, &vicodec_eos_event); + ctx->is_draining = false; + ctx->has_stopped = true; } if (ctx->is_enc || ctx->is_stateless) { src_buf->sequence = q_src->sequence++; @@ -579,6 +582,8 @@ static int job_ready(void *priv) unsigned int max_to_copy; unsigned int comp_frame_size; + if (ctx->has_stopped) + return 0; if (ctx->source_changed) return 0; if (ctx->is_stateless || ctx->is_enc || ctx->comp_has_frame) @@ -1217,25 +1222,45 @@ static int vidioc_s_selection(struct file *file, void *priv, return 0; } -static void vicodec_mark_last_buf(struct vicodec_ctx *ctx) +static int vicodec_mark_last_buf(struct vicodec_ctx *ctx) { - static const struct v4l2_event eos_event = { - .type = V4L2_EVENT_EOS - }; + struct vb2_v4l2_buffer *next_dst_buf; + int ret = 0; spin_lock(ctx->lock); + if (ctx->is_draining) { + ret = -EBUSY; + goto unlock; + } + if (ctx->has_stopped) + goto unlock; + ctx->last_src_buf = v4l2_m2m_last_src_buf(ctx->fh.m2m_ctx); - if (!ctx->last_src_buf && ctx->last_dst_buf) { - ctx->last_dst_buf->flags |= V4L2_BUF_FLAG_LAST; - v4l2_event_queue_fh(&ctx->fh, &eos_event); + ctx->is_draining = true; + if (ctx->last_src_buf) + goto unlock; + + next_dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); + if (!next_dst_buf) { + ctx->next_is_last = true; + goto unlock; } + + next_dst_buf->flags |= V4L2_BUF_FLAG_LAST; + vb2_buffer_done(&next_dst_buf->vb2_buf, VB2_BUF_STATE_DONE); + ctx->is_draining = false; + ctx->has_stopped = true; + v4l2_event_queue_fh(&ctx->fh, &vicodec_eos_event); + +unlock: spin_unlock(ctx->lock); + return ret; } static int vicodec_try_encoder_cmd(struct file *file, void *fh, struct v4l2_encoder_cmd *ec) { - if (ec->cmd != V4L2_ENC_CMD_STOP) + if (ec->cmd != V4L2_ENC_CMD_STOP && ec->cmd != V4L2_ENC_CMD_START) return -EINVAL; if (ec->flags & V4L2_ENC_CMD_STOP_AT_GOP_END) @@ -1254,8 +1279,22 @@ static int vicodec_encoder_cmd(struct file *file, void *fh, if (ret < 0) return ret; - vicodec_mark_last_buf(ctx); - return 0; + if (!vb2_is_streaming(&ctx->fh.m2m_ctx->cap_q_ctx.q) || + !vb2_is_streaming(&ctx->fh.m2m_ctx->out_q_ctx.q)) + return 0; + + if (ec->cmd == V4L2_ENC_CMD_STOP) + return vicodec_mark_last_buf(ctx); + ret = 0; + spin_lock(ctx->lock); + if (ctx->is_draining) { + ret = -EBUSY; + } else if (ctx->has_stopped) { + ctx->has_stopped = false; + vb2_clear_last_buffer_dequeued(&ctx->fh.m2m_ctx->cap_q_ctx.q); + } + spin_unlock(ctx->lock); + return ret; } static int vicodec_try_decoder_cmd(struct file *file, void *fh, @@ -1283,8 +1322,7 @@ static int vicodec_decoder_cmd(struct file *file, void *fh, if (ret < 0) return ret; - vicodec_mark_last_buf(ctx); - return 0; + return vicodec_mark_last_buf(ctx); } static int vicodec_enum_framesizes(struct file *file, void *fh, @@ -1462,6 +1500,23 @@ static void vicodec_buf_queue(struct vb2_buffer *vb) return; } + if (vb2_is_streaming(vq_cap)) { + if (!V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type) && + ctx->next_is_last) { + unsigned int i; + + for (i = 0; i < vb->num_planes; i++) + vb->planes[i].bytesused = 0; + vbuf->flags |= V4L2_BUF_FLAG_LAST; + vb2_buffer_done(vb, VB2_BUF_STATE_DONE); + ctx->is_draining = false; + ctx->has_stopped = true; + ctx->next_is_last = false; + v4l2_event_queue_fh(&ctx->fh, &vicodec_eos_event); + return; + } + } + /* * if both queues are streaming, the source change event is * handled in job_ready @@ -1571,8 +1626,6 @@ static int vicodec_start_streaming(struct vb2_queue *q, if (V4L2_TYPE_IS_OUTPUT(q->type)) ctx->last_src_buf = NULL; - else - ctx->last_dst_buf = NULL; state->gop_cnt = 0; @@ -1648,6 +1701,32 @@ static void vicodec_stop_streaming(struct vb2_queue *q) vicodec_return_bufs(q, VB2_BUF_STATE_ERROR); + if (ctx->is_enc) { + if (V4L2_TYPE_IS_OUTPUT(q->type)) { + if (ctx->is_draining) { + struct vb2_v4l2_buffer *next_dst_buf; + + spin_lock(ctx->lock); + ctx->last_src_buf = NULL; + next_dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); + if (!next_dst_buf) { + ctx->next_is_last = true; + } else { + next_dst_buf->flags |= V4L2_BUF_FLAG_LAST; + vb2_buffer_done(&next_dst_buf->vb2_buf, VB2_BUF_STATE_DONE); + ctx->is_draining = false; + ctx->has_stopped = true; + v4l2_event_queue_fh(&ctx->fh, &vicodec_eos_event); + } + spin_unlock(ctx->lock); + } + } else { + ctx->is_draining = false; + ctx->has_stopped = false; + ctx->next_is_last = false; + } + } + if ((!V4L2_TYPE_IS_OUTPUT(q->type) && !ctx->is_enc) || (V4L2_TYPE_IS_OUTPUT(q->type) && ctx->is_enc)) { if (!ctx->is_stateless) From patchwork Wed Apr 3 22:14:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CAE411575 for ; Wed, 3 Apr 2019 22:18:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B20BA285D9 for ; Wed, 3 Apr 2019 22:18:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A46E828985; Wed, 3 Apr 2019 22:18:19 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 42BD3285D9 for ; Wed, 3 Apr 2019 22:18:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726561AbfDCWSS (ORCPT ); Wed, 3 Apr 2019 18:18:18 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:43163 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726387AbfDCWSS (ORCPT ); Wed, 3 Apr 2019 18:18:18 -0400 Received: by mail-wr1-f68.google.com with SMTP id k17so849983wrx.10 for ; Wed, 03 Apr 2019 15:18:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bfIlPIdrRzyCk4DM79SzuuR3xqBJzBd5V/CyZ7ITpBU=; b=f29wQzObsamMAGcz0wszlVPKUPA2KEKX3MaEvSHdZKuv+njCZHoYeoEonAq06SXFL9 VSrR3N6YVftKyyEm8yVnXzM0DM55RMAJVzwlc3FlYKJ87OtG/5xpUUqdwWgZcVp7ijYu 2nE3G/nMH7+D1keWyTYkWgNZfSfNc2w5UdrE8eeZvTfDuzTvX6I2IY7e949hIEqwkFZv 21wT0vICYzdCZw8a8L0RCdJdWobwNdZiyoZgxnYR11jG89HVfQh3oBjpRYbZMF85PWPY djzKfiZ+dvwUQsjcoOYsdMPw9fuTLo1dszz6ndb9yPWlObhcproliBrRr1W5CBymuWNp CPXw== 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:in-reply-to :references; bh=bfIlPIdrRzyCk4DM79SzuuR3xqBJzBd5V/CyZ7ITpBU=; b=Smyhsm+UeSS9/IpvnDw6/uczvVotm5/KAbIA6tawWMwAb+XzHJseqKsepdB65ulX2d yeiGmSjn87HmBRq0dzYVAVN0cMIwBN0YAZ7N0cCRvztotexLUVtCYVIb303Slo1rS3DT S4Rhd4Ig1mZJ6Khz+eMlKjoYS2qBHk7/68qRzytmMe+vGGudG5Ry8wOT6sHtFmPGdR7W hORvkzN78ylsuz5LXVeG0j+dzNoXaYB+8c3zac91pRJX6xEMVGrWzRgY+vjzGjI5XxVP rODKYCqhFGsWxKzE3QLhooCNv3ZDExb0NBr9mxaYahYdTFa8xvW6LDvjR6LXNLjrm5AJ 3qfg== X-Gm-Message-State: APjAAAXxFA2tQwybVGzt/cE5eHBR0JtIYcXFc4BPlqa/ZbcOCq4BB6OI OytgYlaPfJQ95vPffKD5W20= X-Google-Smtp-Source: APXvYqzc+Fb2gylWoHr9KLBm2b+0MUd38mSOIG26VxVXTEJE5jGFzZrH8IaI+53zaa3HC6o+blLZwA== X-Received: by 2002:a5d:6988:: with SMTP id g8mr1334808wru.117.1554329896754; Wed, 03 Apr 2019 15:18:16 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:16 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH v2 07/16] vicodec: restrict decoder format list when src fmt is known Date: Wed, 3 Apr 2019 15:14:52 -0700 Message-Id: <20190403221501.32814-8-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 From: Hans Verkuil Report the full list of supported decoder formats until the format encoded in the bitstream is known. After that only report the formats compatible with that initial format. Signed-off-by: Hans Verkuil --- drivers/media/platform/vicodec/vicodec-core.c | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index a9a0f6a1b69e..21000cc2f395 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -671,7 +671,6 @@ static int job_ready(void *priv) v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); update_capture_data_from_header(ctx); - ctx->first_source_change_sent = true; v4l2_event_queue_fh(&ctx->fh, &rs_event); set_last_buffer(dst_buf, src_buf, ctx); ctx->source_changed = true; @@ -718,7 +717,7 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx, const struct v4l2_fwht_pixfmt_info *info = get_q_data(ctx, f->type)->info; - if (!info || ctx->is_enc) + if (!ctx->first_source_change_sent || ctx->is_enc) info = v4l2_fwht_get_pixfmt(f->index); else info = v4l2_fwht_find_nth_fmt(info->width_div, @@ -769,9 +768,6 @@ static int vidioc_g_fmt(struct vicodec_ctx *ctx, struct v4l2_format *f) q_data = get_q_data(ctx, f->type); info = q_data->info; - if (!info) - info = v4l2_fwht_get_pixfmt(0); - switch (f->type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_OUTPUT: @@ -1371,6 +1367,16 @@ static int vicodec_subscribe_event(struct v4l2_fh *fh, } } +static int vicodec_streamon(struct file *file, void *fh, enum v4l2_buf_type i) +{ + struct vicodec_ctx *ctx = container_of(fh, struct vicodec_ctx, fh); + int ret = v4l2_m2m_ioctl_streamon(file, fh, i); + + if (!ret && !ctx->is_enc && V4L2_TYPE_IS_OUTPUT(i)) + ctx->first_source_change_sent = true; + return ret; +} + static const struct v4l2_ioctl_ops vicodec_ioctl_ops = { .vidioc_querycap = vidioc_querycap, @@ -1402,7 +1408,7 @@ static const struct v4l2_ioctl_ops vicodec_ioctl_ops = { .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, .vidioc_expbuf = v4l2_m2m_ioctl_expbuf, - .vidioc_streamon = v4l2_m2m_ioctl_streamon, + .vidioc_streamon = vicodec_streamon, .vidioc_streamoff = v4l2_m2m_ioctl_streamoff, .vidioc_g_selection = vidioc_g_selection, @@ -1618,9 +1624,6 @@ static int vicodec_start_streaming(struct vb2_queue *q, unsigned int total_planes_size; u8 *new_comp_frame = NULL; - if (!info) - return -EINVAL; - chroma_div = info->width_div * info->height_div; q_data->sequence = 0; @@ -1726,6 +1729,8 @@ static void vicodec_stop_streaming(struct vb2_queue *q) ctx->next_is_last = false; } } + if (!ctx->is_enc && V4L2_TYPE_IS_OUTPUT(q->type)) + ctx->first_source_change_sent = false; if ((!V4L2_TYPE_IS_OUTPUT(q->type) && !ctx->is_enc) || (V4L2_TYPE_IS_OUTPUT(q->type) && ctx->is_enc)) { From patchwork Wed Apr 3 22:14:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884587 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D0C83922 for ; Wed, 3 Apr 2019 22:18:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B85B7285D9 for ; Wed, 3 Apr 2019 22:18:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACEDC28985; Wed, 3 Apr 2019 22:18:21 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 5E4DE285D9 for ; Wed, 3 Apr 2019 22:18:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726633AbfDCWSU (ORCPT ); Wed, 3 Apr 2019 18:18:20 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33465 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726568AbfDCWSU (ORCPT ); Wed, 3 Apr 2019 18:18:20 -0400 Received: by mail-wr1-f68.google.com with SMTP id q1so922720wrp.0 for ; Wed, 03 Apr 2019 15:18:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Iw+AiiVSZiXn+dUTNAfRPSjZqjh6DGkXBoEk8Pxaxkk=; b=i6iSFLOAT9VKQzILeGTkIr4d3yFukxiVTNkmcuRutEbsjOLrVvm+lE57MM98SdF+0V rIqBBnMgAAdjomvcDTgNbgcpiWNWO8ccl3xAC5G3FScNrVj+uHUaxlGt5CT9I6WFZt7b pLYD73gx30rCfwpWmDpyVhxXHVIh5LJaZ2Umlj9vxwEyhN7s9gDikvMwZocRepC3WL8B eC0nTHJHUlohxafx5M1etatpj+LF37F9pY0urbcQm6N8xObxT8CZizmgD7J8MnAZhYly hlEpNpSOAZO7UpEYdfPBcPZt+oPBXC8FyxkFrnNmWJ/KT+hhgu0n54sZLhAayDYMBt5t R5tQ== 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:in-reply-to :references; bh=Iw+AiiVSZiXn+dUTNAfRPSjZqjh6DGkXBoEk8Pxaxkk=; b=crqqQ22og3D89cr6DZtG44MXfwz6B5BfDAitCtMZdw/o/L+dolIBJe/91UogOdvTwl KGlAFxIXxJrIw8pMtolYGK7nJ0FLsJTPaxuGBQGHxeT9hERW8OlDgADXxQ96eknHqcEg f5Fz6KKbfey7syOJShW7NLm8mxSCaejT3X3sQ/pxDasji8Xap9kjgsfeD6+LCwf9sffc 6k0s4BBIoZYMqzVwmLynQnoR11SJ9ulBShsgDXHtBWjrD9XokGA+aMWwLlAMRtyso/lV OXzliWNO0MaYnkJcDHVOvwVyTmKhwiesZQuQEQuHUWPTGrV4Ie3YRrd07Zm9UWfI1r5Z x3zg== X-Gm-Message-State: APjAAAXODeyVD9b7QePDDocAzNGXzL7kJ6Pr3nT5k8AYTL6o7hvlcYo1 ctMbz+A8E0RzYe8/Ue4VeEk= X-Google-Smtp-Source: APXvYqwebJK5uHXwvjiJ/5AqZvt7p9jv+p8BseRtbU+OiFtn/jbQbCB7lRlF+mYw2S8hWhJsJWHGgg== X-Received: by 2002:adf:f101:: with SMTP id r1mr1342253wro.251.1554329898022; Wed, 03 Apr 2019 15:18:18 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:17 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH v2 08/16] vicodec: set KEY/PFRAME flag when decoding Date: Wed, 3 Apr 2019 15:14:53 -0700 Message-Id: <20190403221501.32814-9-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 From: Hans Verkuil Set V4L2_BUF_FLAG_P/KEYFRAME after decoding a frame. Signed-off-by: Hans Verkuil --- drivers/media/platform/vicodec/vicodec-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 21000cc2f395..4896f349b4aa 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -335,6 +335,10 @@ static int device_process(struct vicodec_ctx *ctx, copy_cap_to_ref(p_dst, ctx->state.info, &ctx->state); vb2_set_plane_payload(&dst_vb->vb2_buf, 0, q_dst->sizeimage); + if (ntohl(ctx->state.header.flags) & FWHT_FL_I_FRAME) + dst_vb->flags |= V4L2_BUF_FLAG_KEYFRAME; + else + dst_vb->flags |= V4L2_BUF_FLAG_PFRAME; } return ret; } @@ -410,7 +414,6 @@ static void device_run(void *priv) u32 state; struct media_request *src_req; - src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); src_req = src_buf->vb2_buf.req_obj.req; @@ -424,7 +427,7 @@ static void device_run(void *priv) else dst_buf->sequence = q_dst->sequence++; dst_buf->flags &= ~V4L2_BUF_FLAG_LAST; - v4l2_m2m_buf_copy_metadata(src_buf, dst_buf, !ctx->is_enc); + v4l2_m2m_buf_copy_metadata(src_buf, dst_buf, false); spin_lock(ctx->lock); if (!ctx->comp_has_next_frame && src_buf == ctx->last_src_buf) { From patchwork Wed Apr 3 22:14:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DBA691575 for ; Wed, 3 Apr 2019 22:18:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3930285D9 for ; Wed, 3 Apr 2019 22:18:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7FA828985; Wed, 3 Apr 2019 22:18:22 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 53976285D9 for ; Wed, 3 Apr 2019 22:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726624AbfDCWSV (ORCPT ); Wed, 3 Apr 2019 18:18:21 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:37494 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726545AbfDCWSU (ORCPT ); Wed, 3 Apr 2019 18:18:20 -0400 Received: by mail-wm1-f66.google.com with SMTP id v14so678960wmf.2 for ; Wed, 03 Apr 2019 15:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i5hySsiSdpJ8GOLdDU4HYynean1/a10NETeKXmN1rS8=; b=uxsgUEQ+SAcYWI4glakiPWcYpTzh0eFms9GpiKh6BCjIXthAb3hUuHuTzVtLCkRNNW nl47zi83AKUYjSOuHr5jsNldvfaL1SZ7HSFhZiLwH1uvZdDVF/pIat868VpyKje6aqu2 QXdnsTYh644hwVRBU6IZoSzC8Td6ozfqqizU1kryXIIwq+uhEtmYA8Mr5eBmQOQtxboh 2iJh2JdlMaMyyxaZiXZnMESGvRGcbZE84Oq+xYik76DO+xAQPyAzAksUODa58RtoyF3m ghymS6rO+l9FCifpKokNuKkGIfybh8++zhhLSnQsKWVAgPxw+mK6oCCmbqlpTVX2YbS6 yC1g== 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:in-reply-to :references; bh=i5hySsiSdpJ8GOLdDU4HYynean1/a10NETeKXmN1rS8=; b=hVOzgdC7LjAVQmhlcaTcH6Nhw2m+Gz/0uiVLo/iiPa9CdAiL9Illi/gxzDeBKrM8Ts A7FtfjLCNfHwEmCffoteq2RJCWfDIChnS8xQInwtNrlwuLa9jkuAHHXdpxYijyT+3TEu n1Mvj1EEYIULetJ/du4/DqMCZyA0bpHBrfDtyyryIkSPvXmjxOGiLLex0V4Ra4Rf2wm4 J68A4M2Nee51gCM4cvCPmUsD1NCaCI8os9MxhqnRVxPqGN2vUARbXFsQcqKatjMGK3Oa 3r6eikRGY9rB/NPmv2g4RnBiMFtV0NK8uqJ0+xZZEzbTMjKfEMg7CWZYUndK6krlMQD4 7pfQ== X-Gm-Message-State: APjAAAVtM1k9O8qsR13fcwA69C0zlj3y4auZELdwFTqVyzh5n3OV+Lzd 5ApooEUcgukfRVZUbq6sRpY= X-Google-Smtp-Source: APXvYqzAUjL6/iFbU4UfJyBRHGvNKM1VDbC3AdNtgv3roRNSDVIjf51bk3EUUy4KG9VpAtB4lme5Ow== X-Received: by 2002:a1c:1b10:: with SMTP id b16mr1689216wmb.90.1554329899301; Wed, 03 Apr 2019 15:18:19 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:18 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH v2 09/16] v4l2-ctrls: add v4l2_ctrl_s_ctrl_ptr() Date: Wed, 3 Apr 2019 15:14:54 -0700 Message-Id: <20190403221501.32814-10-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 From: Hans Verkuil Add a function to set a compound control by passing a pointer to the new data. Functions to set other control types already existed, but not for this. This is needed for stateless encoders. Signed-off-by: Hans Verkuil --- drivers/media/v4l2-core/v4l2-ctrls.c | 11 ++++++++ include/media/v4l2-ctrls.h | 42 ++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index b1ae2e555c68..c6e8f5838b65 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -3855,6 +3855,17 @@ int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s) } EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_string); +int __v4l2_ctrl_s_ctrl_ptr(struct v4l2_ctrl *ctrl, const void *ptr) +{ + lockdep_assert_held(ctrl->handler->lock); + + /* It's a driver bug if this happens. */ + WARN_ON(!ctrl->is_ptr); + memcpy(ctrl->p_new.p, ptr, ctrl->elems * ctrl->elem_size); + return set_ctrl(NULL, ctrl, 0); +} +EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_ptr); + void v4l2_ctrl_request_complete(struct media_request *req, struct v4l2_ctrl_handler *main_hdl) { diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index bd621cec65a5..87c4ade17e22 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -1060,6 +1060,48 @@ static inline int v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s) return rval; } +/** + * __v4l2_ctrl_s_ctrl_ptr() - Unlocked variant of v4l2_ctrl_s_ctrl_ptr(). + * + * @ctrl: The control. + * @ptr: Pointer to the new control contents. + * + * This sets the control's new content safely by going through the control + * framework. This function assumes the control's handler is already locked, + * allowing it to be used from within the &v4l2_ctrl_ops functions. + * + * This function is for pointer type controls only and will memcpy() + * @ctrl->elems * @ctrl->elem_size bytes from @ptr to the internal + * control data. + */ +int __v4l2_ctrl_s_ctrl_ptr(struct v4l2_ctrl *ctrl, const void *ptr); + +/** + * v4l2_ctrl_s_ctrl_ptr() - Helper function to set a control's string value + * from within a driver. + * + * @ctrl: The control. + * @ptr: Pointer to the new control contents. + * + * This sets the control's new content safely by going through the control + * framework. This function will lock the control's handler, so it cannot be + * used from within the &v4l2_ctrl_ops functions. + * + * This function is for pointer type controls only and will memcpy() + * @ctrl->elems * @ctrl->elem_size bytes from @ptr to the internal + * control data. + */ +static inline int v4l2_ctrl_s_ctrl_ptr(struct v4l2_ctrl *ctrl, const void *ptr) +{ + int rval; + + v4l2_ctrl_lock(ctrl); + rval = __v4l2_ctrl_s_ctrl_ptr(ctrl, ptr); + v4l2_ctrl_unlock(ctrl); + + return rval; +} + /* Internal helper functions that deal with control events. */ extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops; From patchwork Wed Apr 3 22:14:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884591 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 816AF1575 for ; Wed, 3 Apr 2019 22:18:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A346285D9 for ; Wed, 3 Apr 2019 22:18:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E8F628985; Wed, 3 Apr 2019 22:18:24 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 F2AEA285D9 for ; Wed, 3 Apr 2019 22:18:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726654AbfDCWSX (ORCPT ); Wed, 3 Apr 2019 18:18:23 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39733 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726568AbfDCWSW (ORCPT ); Wed, 3 Apr 2019 18:18:22 -0400 Received: by mail-wm1-f65.google.com with SMTP id n25so670902wmk.4 for ; Wed, 03 Apr 2019 15:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tiHamkKU0v4G5mxdRp25JO8TtysD+Z28oKNuheGm3+g=; b=qdeGkYCqWuEKAtREA134kvkAEAH3TR/QoDRPapp6/FGTKL0K2N3kMaIyZemCsPIJw1 gN58BbFOemux3hNqUptQcdIf5GVCfBKp58CUrw5Iubdi49tlSWMpH0yNKCp/Mq7jX9Js 2teDuLliJCg51o+x1Lb2PV2lU9Y46SAWA9mg/N1r7d8BmbQyP9rJYKbfHgNUahnmPzd2 /XTxN1VERRNYWYW5iV5inF8CuXBn1dIulzfIvP2yEwUdz7k0Q3vPKqagIJPEQ/xf9zcn 9/5k7YS37k0SSTfwIQH5euPYj+RF/E3PiQoGNON7Thzg/wP095ddfFwJjuMNqnFK2V3M CDRA== 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:in-reply-to :references; bh=tiHamkKU0v4G5mxdRp25JO8TtysD+Z28oKNuheGm3+g=; b=OIZdIxVRQ+6f77oLhLkOpMvtFAkm3tAMxXmQ/tW3agfpUcpFPA6d1oGu9uVIjygvVe SqZAIl9lOdxSO5bwCv1Lz6C54VJ85GT9e2/LYYWbIfepQc8zqoy4kf2R33clQ1C3EbFb LiigzNmB4uCZX2ayc/tfTuRiT7ceELnUOAYILP/oKg5F63zlGYtGJ7YHZIBRwQJAI3Tr dnUTZ3KFBrREm64eEkQyoBKxCfVGL0wqhEcV19s4TVSgyF0j0kcx4Gs+7N6xeLhvhDxr gIq61mP2NplYsD2qHdX421CBmVH8tc8RZUenC93vz44w0RG5M72z3rghnt8D4ufGXbnl oz8g== X-Gm-Message-State: APjAAAX1ei7Pz2Uf3UnLYKszh9tOnISvl7cEp0iV0FZiA6mvgipU6cqB YMiCMyRyHMroUSQDB/Avw6LoWiAc31c= X-Google-Smtp-Source: APXvYqzVoFRXm02xTU29+lEVU+7rFGLkXyhNZNZqplk8CQusb94M2fxXEl1KDcNYorsrGLr3yIjrpA== X-Received: by 2002:a1c:bac2:: with SMTP id k185mr1476742wmf.5.1554329900421; Wed, 03 Apr 2019 15:18:20 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:19 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com Subject: [PATCH v2 10/16] media: vicodec: don't test if info is NULL Date: Wed, 3 Apr 2019 15:14:55 -0700 Message-Id: <20190403221501.32814-11-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 pixel info of q_data is never set to NULL so there is no need to test if it is. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 4896f349b4aa..52e8128d2d28 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -662,7 +662,6 @@ static int job_ready(void *priv) if (ntohl(ctx->state.header.width) != q_dst->visible_width || ntohl(ctx->state.header.height) != q_dst->visible_height || - !q_dst->info || hdr_width_div != q_dst->info->width_div || hdr_height_div != q_dst->info->height_div) { static const struct v4l2_event rs_event = { @@ -992,7 +991,6 @@ static int vidioc_s_fmt(struct vicodec_ctx *ctx, struct v4l2_format *f) pix = &f->fmt.pix; if (ctx->is_enc && V4L2_TYPE_IS_OUTPUT(f->type)) fmt_changed = - !q_data->info || q_data->info->id != pix->pixelformat || q_data->coded_width != pix->width || q_data->coded_height != pix->height; @@ -1015,7 +1013,6 @@ static int vidioc_s_fmt(struct vicodec_ctx *ctx, struct v4l2_format *f) pix_mp = &f->fmt.pix_mp; if (ctx->is_enc && V4L2_TYPE_IS_OUTPUT(f->type)) fmt_changed = - !q_data->info || q_data->info->id != pix_mp->pixelformat || q_data->coded_width != pix_mp->width || q_data->coded_height != pix_mp->height; @@ -1601,10 +1598,6 @@ static unsigned int total_frame_size(struct vicodec_q_data *q_data) unsigned int size; unsigned int chroma_div; - if (!q_data->info) { - WARN_ON(1); - return 0; - } size = q_data->coded_width * q_data->coded_height; chroma_div = q_data->info->width_div * q_data->info->height_div; @@ -1825,8 +1818,6 @@ static int vicodec_try_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_MPEG_VIDEO_FWHT_PARAMS: - if (!q_dst->info) - return -EINVAL; params = ctrl->p_new.p_fwht_params; if (params->width > q_dst->coded_width || params->width < MIN_WIDTH || From patchwork Wed Apr 3 22:14:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0AE95922 for ; Wed, 3 Apr 2019 22:18:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA0D8285D9 for ; Wed, 3 Apr 2019 22:18:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DED2428986; Wed, 3 Apr 2019 22:18:25 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 6EBFD285D9 for ; Wed, 3 Apr 2019 22:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726655AbfDCWSY (ORCPT ); Wed, 3 Apr 2019 18:18:24 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:37499 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726600AbfDCWSY (ORCPT ); Wed, 3 Apr 2019 18:18:24 -0400 Received: by mail-wm1-f67.google.com with SMTP id v14so679070wmf.2 for ; Wed, 03 Apr 2019 15:18:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wB7R+yjlvrN4rznzfX00KVoewVB8tpani/gC/kIYGuE=; b=XsU3hn3nBGLvKIGNkFPxRGo/sXuyxEEkrWOVh2Wqs+FWZ8+/YIUmT/69A8X0hmKpmF r3JFdYTu8p7TMfRanfSmQTfrRIvlaf714vinjOtsGChLQ4ApPiP/Xy9REbRBDKxWRfoF FBUF/zZIq+IyD/+0xUO8w++7LBEIdlrDT+0JQ5R7B+MwFYmJt0Yn3Q0KeXbRFtsqhOOZ Um3egXjnPt/O73gIYix+XmwZqIMT/8lF2Scdf/0mcujTifYppMwpuR7Qt/jfmegSog7x g6gLbXmBFQhmeSwsDA5uIWhNM6YlHOTPHUYLoy38xtDGj8C91hrPMH4a4hSpka/8hVkq FFOg== 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:in-reply-to :references; bh=wB7R+yjlvrN4rznzfX00KVoewVB8tpani/gC/kIYGuE=; b=LfFBB8t8MWPClZBTSX6wsmA+NIjubKnxqp0cWv1Mh71Ah7AOmylUNiBo3uQmWYRA8Y 5NYRjriHd6EIxDwhwb44stLRcLPc8+CZSLijkUdQYDFoIOItvBH1xjYys8VPgA3GrkeD nXHuzvuQhLVahB+q0BFsCNLHnCyjpU9wyJ3FaX1qkVXju2CBo8lgX0Fw5o8o2macFlN2 +C7nJKMosT1cN/t7JvR9Eww+TuSjxegc1hpI/TUBDgL4f+kGP22RBuO8GvABMXj3YFrk Vci1tOnMdYDjjOJDAIc8VET11PbDViqiAP0Kzu3MN5OkuM+WCnmU9Td99U10UwJ+LC6I Xw4Q== X-Gm-Message-State: APjAAAVH+sVDoEUuzDrxgMO7eZZMfD+15Mk8jhVLUoY2WSPz1lzSMvYN nIu9BVcJahD+I8AkoTAfmzE= X-Google-Smtp-Source: APXvYqzoi+hvbY+n81Cis2RReQk4lLVH8kn6CHHWLY0yJCbVeXewzw+1CvfX8L0nYyPobt7+GP3VVg== X-Received: by 2002:a1c:a8d3:: with SMTP id r202mr1645080wme.106.1554329901628; Wed, 03 Apr 2019 15:18:21 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:21 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com Subject: [PATCH v2 11/16] media: vicodec: change fwht_encode_frame to get the header separately Date: Wed, 3 Apr 2019 15:14:56 -0700 Message-Id: <20190403221501.32814-12-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 pass a pointer to the compressed frame header as a different variable. This is a preparation for the stateless encoder where the header is not in the same buffer with the data. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/codec-v4l2-fwht.c | 9 ++++----- drivers/media/platform/vicodec/codec-v4l2-fwht.h | 3 ++- drivers/media/platform/vicodec/vicodec-core.c | 9 +++++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.c b/drivers/media/platform/vicodec/codec-v4l2-fwht.c index 01e7f09efc4e..6a88c6defd1e 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.c +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.c @@ -199,12 +199,12 @@ static int prepare_raw_frame(struct fwht_raw_frame *rf, return 0; } -int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) +int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out, + struct fwht_cframe_hdr *p_hdr) { unsigned int size = state->stride * state->coded_height; unsigned int chroma_stride = state->stride; const struct v4l2_fwht_pixfmt_info *info = state->info; - struct fwht_cframe_hdr *p_hdr; struct fwht_cframe cf; struct fwht_raw_frame rf; u32 encoding; @@ -225,7 +225,7 @@ int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) cf.i_frame_qp = state->i_frame_qp; cf.p_frame_qp = state->p_frame_qp; - cf.rlc_data = (__be16 *)(p_out + sizeof(*p_hdr)); + cf.rlc_data = (__be16 *)p_out; encoding = fwht_encode_frame(&rf, &state->ref_frame, &cf, !state->gop_cnt, @@ -238,7 +238,6 @@ int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) if (++state->gop_cnt >= state->gop_size) state->gop_cnt = 0; - p_hdr = (struct fwht_cframe_hdr *)p_out; p_hdr->magic1 = FWHT_MAGIC1; p_hdr->magic2 = FWHT_MAGIC2; p_hdr->version = htonl(FWHT_VERSION); @@ -266,7 +265,7 @@ int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) p_hdr->ycbcr_enc = htonl(state->ycbcr_enc); p_hdr->quantization = htonl(state->quantization); p_hdr->size = htonl(cf.size); - return cf.size + sizeof(*p_hdr); + return cf.size; } int v4l2_fwht_decode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.h b/drivers/media/platform/vicodec/codec-v4l2-fwht.h index 1a0d2a9f931a..e540cd58cf97 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.h +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.h @@ -58,7 +58,8 @@ const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_nth_fmt(u32 width_div, u32 pixenc, unsigned int start_idx); -int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out); +int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out, + struct fwht_cframe_hdr *hdr); int v4l2_fwht_decode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out); #endif diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 52e8128d2d28..08073f914fd6 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -313,13 +313,18 @@ static int device_process(struct vicodec_ctx *ctx, if (ctx->is_enc) { struct vicodec_q_data *q_src; int comp_sz_or_errcode; + struct fwht_cframe_hdr *p_hdr = (struct fwht_cframe_hdr *) p_dst; + u8 *comp_buf = p_dst + sizeof(struct fwht_cframe_hdr); + q_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); state->info = q_src->info; - comp_sz_or_errcode = v4l2_fwht_encode(state, p_src, p_dst); + comp_sz_or_errcode = v4l2_fwht_encode(state, p_src, comp_buf, + p_hdr); if (comp_sz_or_errcode < 0) return comp_sz_or_errcode; - vb2_set_plane_payload(&dst_vb->vb2_buf, 0, comp_sz_or_errcode); + vb2_set_plane_payload(&dst_vb->vb2_buf, 0, + comp_sz_or_errcode + sizeof(*p_hdr)); } else { struct vicodec_q_data *q_dst; unsigned int comp_frame_size = ntohl(ctx->state.header.size); From patchwork Wed Apr 3 22:14:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884595 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A2331575 for ; Wed, 3 Apr 2019 22:18:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 357E6285D9 for ; Wed, 3 Apr 2019 22:18:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A04E28985; Wed, 3 Apr 2019 22:18:26 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 DB8C728984 for ; Wed, 3 Apr 2019 22:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726668AbfDCWSZ (ORCPT ); Wed, 3 Apr 2019 18:18:25 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:36749 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726615AbfDCWSY (ORCPT ); Wed, 3 Apr 2019 18:18:24 -0400 Received: by mail-wm1-f66.google.com with SMTP id h18so685202wml.1 for ; Wed, 03 Apr 2019 15:18:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RjtThrQrlanvTRGAnpBc2WBNTUw6DBZbSimhC1b0dKY=; b=mgTSJc2qr2GcHdvE4r+XoyFRYWccN5S+O6v4hqM72KvyTa0Lku9o+RMacaEnPip4BO ctQLMFQMbojweoUbvp7ncBl0UuU7VPuk2Ozy2pknH+raU6sNGVj8D+lEV/g8l4f0CFUP 6oE+5x0gMtZA5VpGFX+qknm20EtpRTJUqjSuBQkuDQl0+eIpbpgwQp5TOg5+d2daRMUP YOKd43OXY2e5Xn67OG+27XjmCyBrSmF5SiOfN854D0GvGNzUij7L9DBDxNDtnYx41ZcA CDz7NmWzrCysl/m3/gVdamUdxbTpA1O2kLRXj8KXqJsK/rt8gJZISidx6ZdtS2/yBRP1 sGHw== 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:in-reply-to :references; bh=RjtThrQrlanvTRGAnpBc2WBNTUw6DBZbSimhC1b0dKY=; b=LumtQkO2xnwZ2RUOMTLgPQgI4GTuBZxo/1j96keExrZF3LDagyl/MgmPIY+2PU3RV2 N+jSWwx7w0WA+tm+81xZDZ5wcct5HCXHRxdHncwdXj1VGxE4EnX41jmXj1XEHzkBauyn aqny2hVcJscUoUD7KAzyJSDhrmS5uUrxbj0uWHReWVDlcVtgG6tuneFxPv/tSkuxUkym 7VLuULPy+3a1NokzYD21x9Hp/l2GMFuNyzEV0QFxV3svYzAWz7zTVKC8yW4YUkSpHI95 jd0JTvoz0yx5Pxqn8KeXZCiVm+2cNAvvD1p0NTUqx5kqHqQLOeo0yJ7SBadpEDBi7bgA Cuqw== X-Gm-Message-State: APjAAAWK+fWlFV2w3NShaSshwlf9p45TkoJAA1yXdDZ0qfJGdBfyd5aI MeFbitrCPv6KQMhjOZV4bsI= X-Google-Smtp-Source: APXvYqxXpo0yowVQ63gOLc0EHdt4oFJUFeSFXu7y6AppDSTXu9wGg6tKZk2Ky4djcMyfEMWIYBKTdg== X-Received: by 2002:a7b:c7d0:: with SMTP id z16mr1533559wmk.136.1554329902797; Wed, 03 Apr 2019 15:18:22 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:22 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com Subject: [PATCH v2 12/16] media: vicodec: bugfix: release stateless dec m2m_dev in vicodec_remove Date: Wed, 3 Apr 2019 15:14:57 -0700 Message-Id: <20190403221501.32814-13-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 add a call 'v4l2_m2m_release(dev->stateless_dec.m2m_dev)' in vicodec_remove Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 08073f914fd6..3e93e86041f7 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -2254,6 +2254,7 @@ static int vicodec_remove(struct platform_device *pdev) v4l2_m2m_release(dev->stateful_enc.m2m_dev); v4l2_m2m_release(dev->stateful_dec.m2m_dev); + v4l2_m2m_release(dev->stateless_dec.m2m_dev); video_unregister_device(&dev->stateful_enc.vfd); video_unregister_device(&dev->stateful_dec.vfd); video_unregister_device(&dev->stateless_dec.vfd); From patchwork Wed Apr 3 22:14:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884597 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9BC7922 for ; Wed, 3 Apr 2019 22:18:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2B7A285D9 for ; Wed, 3 Apr 2019 22:18:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A70F828985; Wed, 3 Apr 2019 22:18:27 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 39577285D9 for ; Wed, 3 Apr 2019 22:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726680AbfDCWS0 (ORCPT ); Wed, 3 Apr 2019 18:18:26 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44245 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726545AbfDCWSZ (ORCPT ); Wed, 3 Apr 2019 18:18:25 -0400 Received: by mail-wr1-f67.google.com with SMTP id y7so836309wrn.11 for ; Wed, 03 Apr 2019 15:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GhYAn7sb09ddBtLgtf1whCexcwR1iul0vubvq6vR/dg=; b=g5kvQ3g53PyiYlw1ZTLdBJ8J2zkFABqbKJzc3X+KwDZBiWfzYbU8eH81SQsMyo/tX8 YLdT5MphZRUwBsSw7OKHz6T+zeH2yUSxADXUa4nv0vqt7pVVxzNnx5zbF7qcivWQYGwM 4UXO4ttuScyaJC1xVmSVPM45+iePlFzOYyPM5Uh4Y+ThlJ+Ti0XOKkHAkIgtkBvQAzIw 8OVYjBNA90S9giFGSYsRER7/poF/YfSKiYk/YjXQcVuDfMwtNdwq6DnTsdyeq24qvPyC Km19ZRz27ocjadHs1tZxPkeCtzi8kvR4IrKiOSBdQl38bQ04e2yIfy00/RmqrxPUqhWU 3CNA== 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:in-reply-to :references; bh=GhYAn7sb09ddBtLgtf1whCexcwR1iul0vubvq6vR/dg=; b=RCgIstmJl20jIW4QyOBEMvPTUth7z3NRN/vGVI2vsnzZG+EwY2Q+O6O9h6DSHVOdHL Hknl+XNUzNTGr2oOsxN4Piw1voc3RNNBLrDdNvnwCJgi80BGt3c3Xk9hc6chLlpZ+Nso Eg3I3/PyaQfi+FPfhmdmvMWDU6aF9xVi3oIPQm+xdLbWj5LRJilh+4AxManelYmJdcGU cn1pex+kCjQsbLtXqkdc+F0h1GRCZ6GzjXXnR+ODnYvtM7sR9rIq2cw0GqFLVTQo1WAt w/7h+K8SJJ0HuaWcaKCcdtHQIWYmi2VNa75WtSHne08hG4/2wErqHbJ7i66zneTC0L0j ZiSA== X-Gm-Message-State: APjAAAVmdLzVmhKnBzFzrhvgT+gLmjcstZAUo5mbb93vKgb4SDQBcdlc UTcMJVpGiqWE8WuE7IpoVfI= X-Google-Smtp-Source: APXvYqwSCRKtd97ucF/DzZ1auSMNbux9HK7Xd19m+HMDbJ7oVKNAm6pjhzM5zS57McMFsO6vUo0G9A== X-Received: by 2002:adf:dc88:: with SMTP id r8mr1355858wrj.28.1554329903851; Wed, 03 Apr 2019 15:18:23 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:23 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com Subject: [PATCH v2 13/16] media: vicodec: add field 'dev_inst' to vicodec_ctx Date: Wed, 3 Apr 2019 15:14:58 -0700 Message-Id: <20190403221501.32814-14-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 Add the field 'dev_inst' to vicodec_ctx that points to the 'vicodec_dev_instance'. This saves many if-elses Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 42 ++++++------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 3e93e86041f7..73661bc96671 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -121,6 +121,7 @@ struct vicodec_ctx { bool has_stopped; spinlock_t *lock; + struct vicodec_dev_instance *dev_inst; struct v4l2_ctrl_handler hdl; struct vb2_v4l2_buffer *last_src_buf; @@ -413,7 +414,6 @@ static enum vb2_buffer_state get_next_header(struct vicodec_ctx *ctx, static void device_run(void *priv) { struct vicodec_ctx *ctx = priv; - struct vicodec_dev *dev = ctx->dev; struct vb2_v4l2_buffer *src_buf, *dst_buf; struct vicodec_q_data *q_src, *q_dst; u32 state; @@ -462,13 +462,7 @@ static void device_run(void *priv) if (ctx->is_stateless && src_req) v4l2_ctrl_request_complete(src_req, &ctx->hdl); - if (ctx->is_enc) - v4l2_m2m_job_finish(dev->stateful_enc.m2m_dev, ctx->fh.m2m_ctx); - else if (ctx->is_stateless) - v4l2_m2m_job_finish(dev->stateless_dec.m2m_dev, - ctx->fh.m2m_ctx); - else - v4l2_m2m_job_finish(dev->stateful_dec.m2m_dev, ctx->fh.m2m_ctx); + v4l2_m2m_job_finish(ctx->dev_inst->m2m_dev, ctx->fh.m2m_ctx); } static void job_remove_src_buf(struct vicodec_ctx *ctx, u32 state) @@ -1787,12 +1781,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, src_vq->ops = &vicodec_qops; src_vq->mem_ops = &vb2_vmalloc_memops; src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; - if (ctx->is_enc) - src_vq->lock = &ctx->dev->stateful_enc.mutex; - else if (ctx->is_stateless) - src_vq->lock = &ctx->dev->stateless_dec.mutex; - else - src_vq->lock = &ctx->dev->stateful_dec.mutex; + src_vq->lock = &ctx->dev_inst->mutex; src_vq->supports_requests = ctx->is_stateless; src_vq->requires_requests = ctx->is_stateless; ret = vb2_queue_init(src_vq); @@ -1915,10 +1904,15 @@ static int vicodec_open(struct file *file) goto open_unlock; } - if (vfd == &dev->stateful_enc.vfd) + if (vfd == &dev->stateful_enc.vfd) { ctx->is_enc = true; - else if (vfd == &dev->stateless_dec.vfd) + ctx->dev_inst = &dev->stateful_enc; + } else if (vfd == &dev->stateless_dec.vfd) { ctx->is_stateless = true; + ctx->dev_inst = &dev->stateless_dec; + } else { + ctx->dev_inst = &dev->stateful_dec; + } v4l2_fh_init(&ctx->fh, video_devdata(file)); file->private_data = &ctx->fh; @@ -1975,19 +1969,9 @@ static int vicodec_open(struct file *file) ctx->state.colorspace = V4L2_COLORSPACE_REC709; - if (ctx->is_enc) { - ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateful_enc.m2m_dev, - ctx, &queue_init); - ctx->lock = &dev->stateful_enc.lock; - } else if (ctx->is_stateless) { - ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateless_dec.m2m_dev, - ctx, &queue_init); - ctx->lock = &dev->stateless_dec.lock; - } else { - ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateful_dec.m2m_dev, - ctx, &queue_init); - ctx->lock = &dev->stateful_dec.lock; - } + ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(ctx->dev_inst->m2m_dev, + ctx, &queue_init); + ctx->lock = &ctx->dev_inst->lock; if (IS_ERR(ctx->fh.m2m_ctx)) { rc = PTR_ERR(ctx->fh.m2m_ctx); From patchwork Wed Apr 3 22:14:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884599 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 66087922 for ; Wed, 3 Apr 2019 22:18:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DEF5285D9 for ; Wed, 3 Apr 2019 22:18:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4265228985; Wed, 3 Apr 2019 22:18:29 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 B94AE285D9 for ; Wed, 3 Apr 2019 22:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726671AbfDCWS2 (ORCPT ); Wed, 3 Apr 2019 18:18:28 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:37545 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726615AbfDCWS1 (ORCPT ); Wed, 3 Apr 2019 18:18:27 -0400 Received: by mail-wr1-f67.google.com with SMTP id w10so902915wrm.4 for ; Wed, 03 Apr 2019 15:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Iu/Dkly6zfXuj2CvLdACm3Z+rO003CO1txCsJMayGpQ=; b=Ko34ZPayzju9nuNPkKe+CssP+q2vONJbXK+d/yIq97Tkh+oc6qkGO6+/8iwcmaBjtj C4xaqQ09vD/rQ04ZJqUg9B0FzaMyHwnjNT524SyohdPUjsC9UmsKavQShe/ZMLvcQZFY XZ/46HakvZfisemERqQsSMHqHapR2aS6R3P2EqRmvSPDrjisqHJ+CNVgncaTFSjN6aFV ViT1+7/AKMI3N3QHMjSBJ5LMAb9YdMuboKMEs7qcqLL59PTtYrx4UVGP/0md9b6neLka LqyeQAMkmbl+oY+WBqhC9jS1poBdG50YeSTtf0zGJcaoBl7MmH03cSdw/e/elYnK5Z/P rwIg== 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:in-reply-to :references; bh=Iu/Dkly6zfXuj2CvLdACm3Z+rO003CO1txCsJMayGpQ=; b=jeO+U31HiJ59OHExQmcjcueM4TMcpIEw92KwLmX8MSUC5pu11f6CEwc60qbDV/fTjt pbycbZ2zLz21lr5f68uMuTIU33ZwqBW/mGzIzHnTMQgdUtw/n7RpiwOkQYsZSZ+WTTkx 0OTtSJCgqIsaTvlOA5IT80TorrJZa4wLk1Svw02s4K+7f4OszWd56pGxeNza99a4sM37 wJX2FLhI4YtbPSHCOiA1Td7YgP9ob3bPyQXT6QIGpC2cZEeC9N7SMrRRnHYrSUW69rIz aUG5X+6oQ+2dmWYQ0DGEXZJchjWHqIiOL2YWc9AAWEyD235cQNcDOWEeBb/GqNvHILk+ tHMA== X-Gm-Message-State: APjAAAWPcvuWypTXLDfzu8hUxoX9W1/l/TYpHBr4LFVWhCpt8S4AWVAx +wUWD9CoIBcBYuXwPJmMzRA= X-Google-Smtp-Source: APXvYqx5q2HYVGqniUm+nRNJVhKT7jk8/madMAvRxQ81tLnBAY5sCnXHHNcplCWpsUmWS5T8woPPFQ== X-Received: by 2002:adf:fe03:: with SMTP id n3mr1259232wrr.59.1554329905082; Wed, 03 Apr 2019 15:18:25 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:24 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com Subject: [PATCH v2 14/16] media: vicodec: Register another node for stateless encoder Date: Wed, 3 Apr 2019 15:14:59 -0700 Message-Id: <20190403221501.32814-15-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 Add stateless encoder instance field to the dev struct and register another node for the stateless encoder. The stateless API for the node will be implemented in further patches. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 44 +++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 73661bc96671..8780df73a41f 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -104,6 +104,7 @@ struct vicodec_dev { struct v4l2_device v4l2_dev; struct vicodec_dev_instance stateful_enc; struct vicodec_dev_instance stateful_dec; + struct vicodec_dev_instance stateless_enc; struct vicodec_dev_instance stateless_dec; #ifdef CONFIG_MEDIA_CONTROLLER struct media_device mdev; @@ -1903,16 +1904,20 @@ static int vicodec_open(struct file *file) rc = -ENOMEM; goto open_unlock; } + ctx->is_enc = (vfd == &dev->stateful_enc.vfd || + vfd == &dev->stateless_enc.vfd); - if (vfd == &dev->stateful_enc.vfd) { - ctx->is_enc = true; + ctx->is_stateless = (vfd == &dev->stateless_dec.vfd || + vfd == &dev->stateless_enc.vfd); + + if (vfd == &dev->stateful_enc.vfd) ctx->dev_inst = &dev->stateful_enc; - } else if (vfd == &dev->stateless_dec.vfd) { - ctx->is_stateless = true; - ctx->dev_inst = &dev->stateless_dec; - } else { + else if (vfd == &dev->stateful_dec.vfd) ctx->dev_inst = &dev->stateful_dec; - } + else if (vfd == &dev->stateless_enc.vfd) + ctx->dev_inst = &dev->stateless_enc; + else + ctx->dev_inst = &dev->stateless_dec; v4l2_fh_init(&ctx->fh, video_devdata(file)); file->private_data = &ctx->fh; @@ -2162,9 +2167,13 @@ static int vicodec_probe(struct platform_device *pdev) "stateful-decoder", false)) goto unreg_sf_enc; + if (register_instance(dev, &dev->stateless_enc, + "stateless-encoder", false)) + goto unreg_sf_dec; + if (register_instance(dev, &dev->stateless_dec, "stateless-decoder", false)) - goto unreg_sf_dec; + goto unreg_sl_enc; #ifdef CONFIG_MEDIA_CONTROLLER ret = v4l2_m2m_register_media_controller(dev->stateful_enc.m2m_dev, @@ -2183,14 +2192,23 @@ static int vicodec_probe(struct platform_device *pdev) goto unreg_m2m_sf_enc_mc; } + ret = v4l2_m2m_register_media_controller(dev->stateless_enc.m2m_dev, + &dev->stateless_enc.vfd, + MEDIA_ENT_F_PROC_VIDEO_ENCODER); + if (ret) { + v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem media controller for stateless enc\n"); + goto unreg_m2m_sf_dec_mc; + } + ret = v4l2_m2m_register_media_controller(dev->stateless_dec.m2m_dev, &dev->stateless_dec.vfd, MEDIA_ENT_F_PROC_VIDEO_DECODER); if (ret) { v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem media controller for stateless dec\n"); - goto unreg_m2m_sf_dec_mc; + goto unreg_m2m_sl_enc_mc; } + ret = media_device_register(&dev->mdev); if (ret) { v4l2_err(&dev->v4l2_dev, "Failed to register mem2mem media device\n"); @@ -2202,6 +2220,8 @@ static int vicodec_probe(struct platform_device *pdev) #ifdef CONFIG_MEDIA_CONTROLLER unreg_m2m_sl_dec_mc: v4l2_m2m_unregister_media_controller(dev->stateless_dec.m2m_dev); +unreg_m2m_sl_enc_mc: + v4l2_m2m_unregister_media_controller(dev->stateless_enc.m2m_dev); unreg_m2m_sf_dec_mc: v4l2_m2m_unregister_media_controller(dev->stateful_dec.m2m_dev); unreg_m2m_sf_enc_mc: @@ -2210,6 +2230,9 @@ static int vicodec_probe(struct platform_device *pdev) video_unregister_device(&dev->stateless_dec.vfd); v4l2_m2m_release(dev->stateless_dec.m2m_dev); #endif +unreg_sl_enc: + video_unregister_device(&dev->stateless_enc.vfd); + v4l2_m2m_release(dev->stateless_enc.m2m_dev); unreg_sf_dec: video_unregister_device(&dev->stateful_dec.vfd); v4l2_m2m_release(dev->stateful_dec.m2m_dev); @@ -2232,15 +2255,18 @@ static int vicodec_remove(struct platform_device *pdev) media_device_unregister(&dev->mdev); v4l2_m2m_unregister_media_controller(dev->stateful_enc.m2m_dev); v4l2_m2m_unregister_media_controller(dev->stateful_dec.m2m_dev); + v4l2_m2m_unregister_media_controller(dev->stateless_enc.m2m_dev); v4l2_m2m_unregister_media_controller(dev->stateless_dec.m2m_dev); media_device_cleanup(&dev->mdev); #endif v4l2_m2m_release(dev->stateful_enc.m2m_dev); v4l2_m2m_release(dev->stateful_dec.m2m_dev); + v4l2_m2m_release(dev->stateless_enc.m2m_dev); v4l2_m2m_release(dev->stateless_dec.m2m_dev); video_unregister_device(&dev->stateful_enc.vfd); video_unregister_device(&dev->stateful_dec.vfd); + video_unregister_device(&dev->stateless_enc.vfd); video_unregister_device(&dev->stateless_dec.vfd); v4l2_device_unregister(&dev->v4l2_dev); From patchwork Wed Apr 3 22:15:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B6111575 for ; Wed, 3 Apr 2019 22:18:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54422285D9 for ; Wed, 3 Apr 2019 22:18:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48C0928985; Wed, 3 Apr 2019 22:18:30 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 DA17F285D9 for ; Wed, 3 Apr 2019 22:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726676AbfDCWS3 (ORCPT ); Wed, 3 Apr 2019 18:18:29 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34487 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726545AbfDCWS2 (ORCPT ); Wed, 3 Apr 2019 18:18:28 -0400 Received: by mail-wr1-f66.google.com with SMTP id p10so924341wrq.1 for ; Wed, 03 Apr 2019 15:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ispdb462hbKT51g52eJZ6tHm3l/BTCofEhGezrMbwmk=; b=Umlnx+h6J6TUNtXVYWVJrDgzNt4y3QsnKDlkI9ImUpE1OMghyI+bJ+zQKCkJentg1G 50AK42BjoqwlHHkT3V7ioMpmZ4+CqqCt89OC1rJgg+cKubyXeytxZT82gLQ3s5WY6pGA /JnGDT/9pxevFWSMA2xnbYHE4UOJLNof0IkHdtPCClxDw5U/SM7Nmgn1HK3UlrImy/5I nvPRQI2WPdieIQNAkzSpR9yAlIMlkCo/qJO5z8T6ii0g8Eyc3YcmhGrCsMTWQ/oaSGcc X24bk39EvRuXEinzUh6ZOKiJVUAIb3F14LrjGE/I7WIo/P+470uBTKFUYz5NnXRDN6mn 2dNw== 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:in-reply-to :references; bh=ispdb462hbKT51g52eJZ6tHm3l/BTCofEhGezrMbwmk=; b=JHFzB6rOkJeo8NeuT6CPoEMngFRWthHfc5JVgeGqxhas4UBukcKCbaBgpJYztEEsxj W995uSlAAZvA9xKvF94lK4oVVlsMwLU4yE12bckRPmhMOHwFTS0trZOEKYmUzPDIK0q2 WbeOYUMhXaIu0UnsQeuiY/3mSc5cstzUkZb9AiHZEfIfKa2n/B/cmazPlkerKfS4JAoT hNw7Mhcd8R0HJTN7oL5U/DV674Zp84b4G0D08mD7hSbeHY9WxVxnOFXFvXdoFGCZvRo8 X5hjBc/En9UG3ewc5qGb5EnvAtSguLBR19ZQe3U2nrSU9ydA9ExRp2NYobdX+PBmPBbz JgaQ== X-Gm-Message-State: APjAAAXfA4yapsg+dOp4WS0N/oeflta0/C5qOHEbh8MGB4tb55cBJvbm MM8I34rFdYi8NU0IgaX/NF8= X-Google-Smtp-Source: APXvYqwJv7jgRzoMTTtblNHooVlraet3AP0HGrLJ50a1mcL72Q8eemyiA3YB6XO4cEipu6vsDStf8A== X-Received: by 2002:adf:f110:: with SMTP id r16mr1259832wro.153.1554329906232; Wed, 03 Apr 2019 15:18:26 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:25 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com Subject: [PATCH v2 15/16] media: vicodec: set pixelformat V4L2_PIX_FMT_FWHT_STATELESS for stateless encoder Date: Wed, 3 Apr 2019 15:15:00 -0700 Message-Id: <20190403221501.32814-16-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 for stateless encoder, set the capture pixelformat to V4L2_PIX_FMT_FWHT_STATELESS and the pix info to pixfmt_stateless_fwht Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 8780df73a41f..c972c175707c 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -903,8 +903,12 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, if (multiplanar) return -EINVAL; pix = &f->fmt.pix; - pix->pixelformat = ctx->is_enc ? V4L2_PIX_FMT_FWHT : - find_fmt(f->fmt.pix.pixelformat)->id; + if (!ctx->is_enc) + pix->pixelformat = find_fmt(f->fmt.pix.pixelformat)->id; + else if (ctx->is_stateless) + pix->pixelformat = V4L2_PIX_FMT_FWHT_STATELESS; + else + pix->pixelformat = V4L2_PIX_FMT_FWHT; pix->colorspace = ctx->state.colorspace; pix->xfer_func = ctx->state.xfer_func; pix->ycbcr_enc = ctx->state.ycbcr_enc; @@ -914,8 +918,13 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, if (!multiplanar) return -EINVAL; pix_mp = &f->fmt.pix_mp; - pix_mp->pixelformat = ctx->is_enc ? V4L2_PIX_FMT_FWHT : - find_fmt(pix_mp->pixelformat)->id; + if (!ctx->is_enc) + pix_mp->pixelformat = + find_fmt(f->fmt.pix_mp.pixelformat)->id; + else if (ctx->is_stateless) + pix_mp->pixelformat = V4L2_PIX_FMT_FWHT_STATELESS; + else + pix_mp->pixelformat = V4L2_PIX_FMT_FWHT; pix_mp->colorspace = ctx->state.colorspace; pix_mp->xfer_func = ctx->state.xfer_func; pix_mp->ycbcr_enc = ctx->state.ycbcr_enc; @@ -1647,22 +1656,22 @@ static int vicodec_start_streaming(struct vb2_queue *q, state->stride = q_data->coded_width * info->bytesperline_mult; - if (ctx->is_stateless) { + if (!ctx->is_enc && ctx->is_stateless) { state->ref_stride = state->stride; return 0; } state->ref_stride = q_data->coded_width * info->luma_alpha_step; state->ref_frame.buf = kvmalloc(total_planes_size, GFP_KERNEL); - state->ref_frame.luma = state->ref_frame.buf; new_comp_frame = kvmalloc(ctx->comp_max_size, GFP_KERNEL); - if (!state->ref_frame.luma || !new_comp_frame) { - kvfree(state->ref_frame.luma); + if (!state->ref_frame.buf || !new_comp_frame) { + kvfree(state->ref_frame.buf); kvfree(new_comp_frame); vicodec_return_bufs(q, VB2_BUF_STATE_QUEUED); return -ENOMEM; } + state->ref_frame.luma = state->ref_frame.buf; /* * if state->compressed_frame was already allocated then * it contain data of the first frame of the new resolution @@ -1964,9 +1973,10 @@ static int vicodec_open(struct file *file) comp_size + sizeof(struct fwht_cframe_hdr); ctx->q_data[V4L2_M2M_DST] = ctx->q_data[V4L2_M2M_SRC]; if (ctx->is_enc) { - ctx->q_data[V4L2_M2M_DST].info = &pixfmt_fwht; - ctx->q_data[V4L2_M2M_DST].sizeimage = - comp_size + sizeof(struct fwht_cframe_hdr); + ctx->q_data[V4L2_M2M_DST].info = ctx->is_stateless ? + &pixfmt_stateless_fwht : &pixfmt_fwht; + ctx->q_data[V4L2_M2M_DST].sizeimage = comp_size + + sizeof(struct fwht_cframe_hdr); } else { ctx->q_data[V4L2_M2M_DST].info = info; ctx->q_data[V4L2_M2M_DST].sizeimage = raw_size; From patchwork Wed Apr 3 22:15:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10884603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B88711575 for ; Wed, 3 Apr 2019 22:18:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A21E8285D9 for ; Wed, 3 Apr 2019 22:18:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9645428985; Wed, 3 Apr 2019 22:18:31 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 07F95285D9 for ; Wed, 3 Apr 2019 22:18:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726690AbfDCWSa (ORCPT ); Wed, 3 Apr 2019 18:18:30 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:34985 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726568AbfDCWS3 (ORCPT ); Wed, 3 Apr 2019 18:18:29 -0400 Received: by mail-wm1-f66.google.com with SMTP id y197so695998wmd.0 for ; Wed, 03 Apr 2019 15:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=53+zCVrSNNXnGB2H2mZfd8ai2PG61TezGRoLM40CipI=; b=OWzlWgxRkieR08VvIf4/FUhhiy2EsYyTM3kZdpb/h+eCdI36DFyufUOpS33mKStYv0 wm32iETOTK2Jkip6NNOwfAJ1Vbtf7IYNFQJPUGMEToxkR1A1r4RczpNyM4Eg1BoIIzRH Gtq2ql+J8YDWR12KO7SuRuxFHKf8t49k3Pjoa0oDutVjJPzy/gpvwqNz/i04MdU/r/N1 XgG0wRrK7kjdSkZh6n8OYc81jarS4CA929WQ7gCHFf23rMi3HZj+p0h4WxQ+dU+0fdYu nGK9t9plN/pI2oUtCQw72BUVMtz911hraJAvZ1Wc9c95y08duPGnzTCPQWYob5pYDiSt u8gw== 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:in-reply-to :references; bh=53+zCVrSNNXnGB2H2mZfd8ai2PG61TezGRoLM40CipI=; b=IQ7V5iddRKxy20Fu/kkJFPk52ZO1cuI1gXDgymHxJCAEEqCgdhfwlA9m+Sdu3FG9Iz WbYPV3c6/lLoIzKPRXhBs7HTa69hDmuI88/f6x3MBzQq5tn7zbRKcD6Gdf/hWjZ0UGbz 5W9iNhitDp5uZoYcO/mIbgaEgO1U9uOGrmq9MohjPY46MY3/0d8ltY+uLIq/4h9962fr SD0LpmY5qL6c+6q9/v0bHJFCCg5rk89F12O59QE9Aue56AvYOWaKlVnMOAROG0mApBfU ds5jiZOWAxntCazG0hHjHuih8vEDccdXzSiGK3c2sa1CprInpJgEiKRueiBiQsmN1Cyk Xx4g== X-Gm-Message-State: APjAAAXghhYS0s6ln/hdp/G1E1APA3K79XC5F7kI8kEgi7SlQQY8U4a4 GhVYzhY7Pkhjgi9AW7ll4KI= X-Google-Smtp-Source: APXvYqyOlyjObL0b5epquJIwL+Gn8rkSfzlFamTnYX4LFaKuMIbGSPfw0bjrnuP5V4HI1RLutHx6yg== X-Received: by 2002:a1c:5f06:: with SMTP id t6mr1633803wmb.7.1554329907441; Wed, 03 Apr 2019 15:18:27 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id d6sm26019552wrx.62.2019.04.03.15.18.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 15:18:26 -0700 (PDT) From: Dafna Hirschfeld To: dafna3@gmail.com, linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com Subject: [PATCH v2 16/16] media: vicodec: Add support for stateless encoder Date: Wed, 3 Apr 2019 15:15:01 -0700 Message-Id: <20190403221501.32814-17-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403221501.32814-1-dafna3@gmail.com> References: <20190403221501.32814-1-dafna3@gmail.com> 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 Adjust the stateless API code to support both encoder and decoder. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 106 ++++++++++++------ 1 file changed, 73 insertions(+), 33 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index c972c175707c..e1bfcc480716 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -140,6 +140,7 @@ struct vicodec_ctx { bool comp_has_next_frame; bool first_source_change_sent; bool source_changed; + struct v4l2_ctrl *ctrl_fwht_params; }; static const struct v4l2_event vicodec_eos_event = { @@ -256,6 +257,21 @@ static void update_state_from_header(struct vicodec_ctx *ctx) ctx->state.quantization = ntohl(p_hdr->quantization); } +static void update_stateless_params_from_header(const struct vicodec_ctx *ctx, + struct v4l2_ctrl_fwht_params *params) +{ + const struct fwht_cframe_hdr *p_hdr = &ctx->state.header; + + params->version = ntohl(p_hdr->version); + params->width = ntohl(p_hdr->width); + params->height = ntohl(p_hdr->height); + params->flags = ntohl(p_hdr->flags); + params->colorspace = ntohl(p_hdr->colorspace); + params->xfer_func = ntohl(p_hdr->xfer_func); + params->ycbcr_enc = ntohl(p_hdr->ycbcr_enc); + params->quantization = ntohl(p_hdr->quantization); +} + static int device_process(struct vicodec_ctx *ctx, struct vb2_v4l2_buffer *src_vb, struct vb2_v4l2_buffer *dst_vb) @@ -276,33 +292,35 @@ static int device_process(struct vicodec_ctx *ctx, ret = v4l2_ctrl_request_setup(src_req, &ctx->hdl); if (ret) return ret; - update_state_from_header(ctx); - - ctx->state.header.size = - htonl(vb2_get_plane_payload(&src_vb->vb2_buf, 0)); - /* - * set the reference buffer from the reference timestamp - * only if this is a P-frame - */ - if (!(ntohl(ctx->state.header.flags) & FWHT_FL_I_FRAME)) { - struct vb2_buffer *ref_vb2_buf; - int ref_buf_idx; - struct vb2_queue *vq_cap = + if (!ctx->is_enc) { + update_state_from_header(ctx); + + ctx->state.header.size = + htonl(vb2_get_plane_payload(&src_vb->vb2_buf, 0)); + /* + * set the reference buffer from the reference timestamp + * only if this is a P-frame + */ + if (!(ntohl(ctx->state.header.flags) & FWHT_FL_I_FRAME)) { + struct vb2_buffer *ref_vb2_buf; + int ref_buf_idx; + struct vb2_queue *vq_cap = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, - V4L2_BUF_TYPE_VIDEO_CAPTURE); - - ref_buf_idx = vb2_find_timestamp(vq_cap, - ctx->state.ref_frame_ts, 0); - if (ref_buf_idx < 0) - return -EINVAL; - - ref_vb2_buf = vq_cap->bufs[ref_buf_idx]; - if (ref_vb2_buf->state == VB2_BUF_STATE_ERROR) - ret = -EINVAL; - ctx->state.ref_frame.buf = - vb2_plane_vaddr(ref_vb2_buf, 0); - } else { - ctx->state.ref_frame.buf = NULL; + V4L2_BUF_TYPE_VIDEO_CAPTURE); + + ref_buf_idx = vb2_find_timestamp(vq_cap, + ctx->state.ref_frame_ts, 0); + if (ref_buf_idx < 0) + return -EINVAL; + + ref_vb2_buf = vq_cap->bufs[ref_buf_idx]; + if (ref_vb2_buf->state == VB2_BUF_STATE_ERROR) + ret = -EINVAL; + ctx->state.ref_frame.buf = + vb2_plane_vaddr(ref_vb2_buf, 0); + } else { + ctx->state.ref_frame.buf = NULL; + } } } p_dst = vb2_plane_vaddr(&dst_vb->vb2_buf, 0); @@ -315,18 +333,36 @@ static int device_process(struct vicodec_ctx *ctx, if (ctx->is_enc) { struct vicodec_q_data *q_src; int comp_sz_or_errcode; - struct fwht_cframe_hdr *p_hdr = (struct fwht_cframe_hdr *) p_dst; - u8 *comp_buf = p_dst + sizeof(struct fwht_cframe_hdr); - + struct fwht_cframe_hdr *p_hdr; + u8 *comp_buf; + if (ctx->is_stateless) { + p_hdr = &ctx->state.header; + comp_buf = p_dst; + } else { + p_hdr = (struct fwht_cframe_hdr *) p_dst; + comp_buf = p_dst + sizeof(struct fwht_cframe_hdr); + } q_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); state->info = q_src->info; comp_sz_or_errcode = v4l2_fwht_encode(state, p_src, comp_buf, p_hdr); if (comp_sz_or_errcode < 0) return comp_sz_or_errcode; - vb2_set_plane_payload(&dst_vb->vb2_buf, 0, - comp_sz_or_errcode + sizeof(*p_hdr)); + + if (!ctx->is_stateless) { + comp_sz_or_errcode += sizeof(*p_hdr); + } else { + int ret; + struct v4l2_ctrl_fwht_params params; + + update_stateless_params_from_header(ctx, ¶ms); + ret = v4l2_ctrl_s_ctrl_ptr(ctx->ctrl_fwht_params, + ¶ms); + if (ret) + return ret; + } + vb2_set_plane_payload(&dst_vb->vb2_buf, 0, comp_sz_or_errcode); } else { struct vicodec_q_data *q_dst; unsigned int comp_frame_size = ntohl(ctx->state.header.size); @@ -1739,7 +1775,7 @@ static void vicodec_stop_streaming(struct vb2_queue *q) if ((!V4L2_TYPE_IS_OUTPUT(q->type) && !ctx->is_enc) || (V4L2_TYPE_IS_OUTPUT(q->type) && ctx->is_enc)) { - if (!ctx->is_stateless) + if (!ctx->is_stateless || ctx->is_enc) kvfree(ctx->state.ref_frame.buf); ctx->state.ref_frame.buf = NULL; ctx->state.ref_frame.luma = NULL; @@ -1819,6 +1855,8 @@ static int vicodec_try_ctrl(struct v4l2_ctrl *ctrl) const struct v4l2_ctrl_fwht_params *params; struct vicodec_q_data *q_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); + if (ctx->is_enc) + return 0; switch (ctrl->id) { case V4L2_CID_MPEG_VIDEO_FWHT_PARAMS: @@ -1943,7 +1981,9 @@ static int vicodec_open(struct file *file) v4l2_ctrl_new_std(hdl, &vicodec_ctrl_ops, V4L2_CID_MIN_BUFFERS_FOR_OUTPUT, 1, 1, 1, 1); if (ctx->is_stateless) - v4l2_ctrl_new_custom(hdl, &vicodec_ctrl_stateless_state, NULL); + ctx->ctrl_fwht_params = + v4l2_ctrl_new_custom(hdl, &vicodec_ctrl_stateless_state, + NULL); if (hdl->error) { rc = hdl->error; v4l2_ctrl_handler_free(hdl);