From patchwork Mon Feb 25 22:19:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829201 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 E0BC61805 for ; Mon, 25 Feb 2019 22:19:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCFB7297A8 for ; Mon, 25 Feb 2019 22:19:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1ED72B336; Mon, 25 Feb 2019 22:19:57 +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 5726A297A8 for ; Mon, 25 Feb 2019 22:19:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727703AbfBYWT4 (ORCPT ); Mon, 25 Feb 2019 17:19:56 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:42863 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726919AbfBYWT4 (ORCPT ); Mon, 25 Feb 2019 17:19:56 -0500 Received: by mail-wr1-f68.google.com with SMTP id r5so11693711wrg.9 for ; Mon, 25 Feb 2019 14:19:54 -0800 (PST) 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=MAunhPLiQsMAY05okqvSKPPo8Hd0S9bQIXD1NW17kLg=; b=AR7mfGuQKQzThRZ4JkrhihIObcCxaCY5xbqFCDtedj36ljB/wRCbDtxm4d0CG7fBDt r6q6wZMazAwC7r0VeoRdzfsXonbLMnefOZOeaZub071FQRrWnuSFKW6ivE/sPznIMUte yCM6Yt0iARU5NLpILB2G1cvJZEDlMOkUDyauLE9jvuvNNY2mlRNMHJZpfuzhYpdzlDNa ZuOw1OJLWDpyjq9/XBu4c4ovXVwrU9eCC7krLHTDkNvd7QZPWfVVyqOfw7JgHWsEjgOx r+2K7HTechQWpeLrTPFIfvOXqCmlndzx9L7a6omFiGah4RyQi6f70v3+ujny4aXFIyaZ t+gQ== 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=MAunhPLiQsMAY05okqvSKPPo8Hd0S9bQIXD1NW17kLg=; b=rvBYnucteH8Yxvf37o1dxD53SoZD/VaePu/MNDfkRa5zY9NcJYTnNi4q05FWiCljn1 M2SQxOQfy3bkOmWgG+JIi8lUO6FxByKmYlMA5AA6wQsydOX8c/YF/Y7JuLG2sbkh+TYy 0YhATHP+Bx0w17ODPocpAq3mNgOXvVbK87SsYjG0jRYpW/gxA3wl9OkuCO45IaI8Bppb TH3B9NpSpIgaF4soEGF0KVQnxwhcbVknuGEh8fcUuEtQ+DUsZjEyULOTUwtHOu4Ei7lM HSvP6kVi25zDDBrIzevynTC1UJyktHp78a/iaPjvlFcGLM2KrGFFoSCo6LGVth89VcID aJ0g== X-Gm-Message-State: AHQUAubtZRgXuHghU2c1E4wJdvDtb/sUpWUcgBSQ/AnVoL0pRKhqvK9b 7YSvWkSG4RrTblYnAMUoI1SAWsCTH3M= X-Google-Smtp-Source: AHgI3Iazb4rDPvR1pGmUOeuR4sMoZWqnrq5iDVRBIyCM/6q7Hx8U4Q7or+J5s6XtVDLI4A3iArOePg== X-Received: by 2002:adf:ecd2:: with SMTP id s18mr13836320wro.293.1551133193519; Mon, 25 Feb 2019 14:19:53 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id a20sm4168033wmb.17.2019.02.25.14.19.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:19:52 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH v4 01/21] vb2: add requires_requests bit for stateless codecs Date: Mon, 25 Feb 2019 14:19:25 -0800 Message-Id: <20190225221933.121653-2-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225221933.121653-1-dafna3@gmail.com> References: <20190225221933.121653-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 Stateless codecs require the use of the Request API as opposed of it being optional. So add a bit to indicate this and let vb2 check for this. Signed-off-by: Hans Verkuil --- drivers/media/common/videobuf2/videobuf2-core.c | 5 ++++- drivers/media/common/videobuf2/videobuf2-v4l2.c | 6 ++++++ include/media/videobuf2-core.h | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 15b6b9c0a2e4..d8cf9d3ec54d 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -1518,7 +1518,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb, if ((req && q->uses_qbuf) || (!req && vb->state != VB2_BUF_STATE_IN_REQUEST && - q->uses_requests)) { + (q->uses_requests || q->requires_requests))) { dprintk(1, "queue in wrong mode (qbuf vs requests)\n"); return -EBUSY; } @@ -2247,6 +2247,9 @@ int vb2_core_queue_init(struct vb2_queue *q) WARN_ON(!q->ops->buf_queue)) return -EINVAL; + if (WARN_ON(q->requires_requests && !q->supports_requests)) + return -EINVAL; + INIT_LIST_HEAD(&q->queued_list); INIT_LIST_HEAD(&q->done_list); spin_lock_init(&q->done_lock); diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index d09dee20e421..4dc4855056f1 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -385,6 +385,10 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md dprintk(1, "%s: queue uses requests\n", opname); return -EBUSY; } + if (q->requires_requests) { + dprintk(1, "%s: queue requires requests\n", opname); + return -EACCES; + } return 0; } else if (!q->supports_requests) { dprintk(1, "%s: queue does not support requests\n", opname); @@ -658,6 +662,8 @@ static void fill_buf_caps(struct vb2_queue *q, u32 *caps) #ifdef CONFIG_MEDIA_CONTROLLER_REQUEST_API if (q->supports_requests) *caps |= V4L2_BUF_CAP_SUPPORTS_REQUESTS; + if (q->requires_requests) + *caps |= V4L2_BUF_CAP_REQUIRES_REQUESTS; #endif } diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index a844abcae71e..bf50090af859 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -484,6 +484,8 @@ struct vb2_buf_ops { * has not been called. This is a vb1 idiom that has been adopted * also by vb2. * @supports_requests: this queue supports the Request API. + * @requires_requests: this queue requires the Request API. If this is set to 1, + * then supports_requests must be set to 1 as well. * @uses_qbuf: qbuf was used directly for this queue. Set to 1 the first * time this is called. Set to 0 when the queue is canceled. * If this is 1, then you cannot queue buffers from a request. @@ -558,6 +560,7 @@ struct vb2_queue { unsigned allow_zero_bytesused:1; unsigned quirk_poll_must_check_waiting_for_buffers:1; unsigned supports_requests:1; + unsigned requires_requests:1; unsigned uses_qbuf:1; unsigned uses_requests:1; From patchwork Mon Feb 25 22:19:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829207 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 08FEA1390 for ; Mon, 25 Feb 2019 22:20:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC5E72B32B for ; Mon, 25 Feb 2019 22:20:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFF9B2B4F1; Mon, 25 Feb 2019 22:20:08 +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 C4DE12B32B for ; Mon, 25 Feb 2019 22:20:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727927AbfBYWT6 (ORCPT ); Mon, 25 Feb 2019 17:19:58 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39605 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726845AbfBYWT5 (ORCPT ); Mon, 25 Feb 2019 17:19:57 -0500 Received: by mail-wr1-f66.google.com with SMTP id l5so11713265wrw.6 for ; Mon, 25 Feb 2019 14:19:56 -0800 (PST) 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=Wd3HgaUvH1soc/yfyWI6dAQdM9lUwSjfn9ndiCGooyo=; b=FjA74HV/re31HZmPe8uHtbN7Zei6TnSs4XMQ+jNnexkyAE9Lt43MMSZCBY7VLVW9aK CxXLOFy7R6PyZKGAdv2GgIWxbjc0pKVStDL1FXI9iiKAzca7HjY1ACowS+/CxZ6i456z Jy3wwq+RL2vFpqamdLBRHDyprXBu8JRmGhrFKGbA63PoynkzhOxDgTWXrz2EYoJWNR/V AFFUYThz50RfFQOByTcQWQDcloCt2afKySNwqJTetnZKTSp4Kb2gHG9KS4WIasRa/H+4 c9GOvchqUX9Zjifrc8VB4JZrSS3GeBrUrqqLm3WYrcE4TEEsuVRiofukgAGWSErQQjNg oPQQ== 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=Wd3HgaUvH1soc/yfyWI6dAQdM9lUwSjfn9ndiCGooyo=; b=q0GtY9piXHBL/6dnu1rSOjBcebKCnIJzgBpynYfFK6b9/GyTINv8KqRywCK54dLnLF l+LXeWiryfvOaY1B/uAkAZlm1qfTdkQn5KJOZjvAYqpoQ6lWZBZLN3TqLU+IMRmqkNOw T/ncW+yvekfbtM2nZDVhXhhkML6RAdowXdqNC/awdMQ43vBeQJVIlDtFIw9dLVYy4Mjo qKptD9fcyV+GXi7ZGrDSciBLUA+FwQHC4Oy/vR9YfC0IN47xeBkrrd9gw1zaaBa37fLg G/Hz2GKrY9Y69Mk6JyWwh9Wd5tMXGR8HBYJ3BzGImofYECrFyiODDE4T08CcOtGSduYX JcvA== X-Gm-Message-State: AHQUAub4Hgd5H9yLlXIPsYAibC0vLlW1tXZ62r5wP1bTEcOZwRDq20zy sKdEkAsNfKMs7/4h4AOkNo8pJwCJEB4= X-Google-Smtp-Source: AHgI3IZRMgCFfXkf5pGdC0Opq/Cql2KEIAFfh0eqT7mt3zQhoooBAVpdYTO7xmyM4ZCWjCMuyMRffw== X-Received: by 2002:a05:6000:128f:: with SMTP id f15mr13505295wrx.74.1551133194967; Mon, 25 Feb 2019 14:19:54 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id a20sm4168033wmb.17.2019.02.25.14.19.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:19:54 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH v4 02/21] videodev2.h: add V4L2_BUF_CAP_REQUIRES_REQUESTS Date: Mon, 25 Feb 2019 14:19:26 -0800 Message-Id: <20190225221933.121653-3-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225221933.121653-1-dafna3@gmail.com> References: <20190225221933.121653-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 capability to indicate that requests are required instead of merely supported. Signed-off-by: Hans Verkuil --- Documentation/media/uapi/v4l/vidioc-reqbufs.rst | 4 ++++ include/uapi/linux/videodev2.h | 1 + 2 files changed, 5 insertions(+) diff --git a/Documentation/media/uapi/v4l/vidioc-reqbufs.rst b/Documentation/media/uapi/v4l/vidioc-reqbufs.rst index d7faef10e39b..d42a3d9a7db3 100644 --- a/Documentation/media/uapi/v4l/vidioc-reqbufs.rst +++ b/Documentation/media/uapi/v4l/vidioc-reqbufs.rst @@ -125,6 +125,7 @@ aborting or finishing any DMA in progress, an implicit .. _V4L2-BUF-CAP-SUPPORTS-DMABUF: .. _V4L2-BUF-CAP-SUPPORTS-REQUESTS: .. _V4L2-BUF-CAP-SUPPORTS-ORPHANED-BUFS: +.. _V4L2-BUF-CAP-REQUIRES-REQUESTS: .. cssclass:: longtable @@ -150,6 +151,9 @@ aborting or finishing any DMA in progress, an implicit - The kernel allows calling :ref:`VIDIOC_REQBUFS` while buffers are still mapped or exported via DMABUF. These orphaned buffers will be freed when they are unmapped or when the exported DMABUF fds are closed. + * - ``V4L2_BUF_CAP_REQUIRES_REQUESTS`` + - 0x00000020 + - This buffer type requires the use of :ref:`requests `. Return Value ============ diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 1db220da3bcc..97e6a6a968ba 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -895,6 +895,7 @@ struct v4l2_requestbuffers { #define V4L2_BUF_CAP_SUPPORTS_DMABUF (1 << 2) #define V4L2_BUF_CAP_SUPPORTS_REQUESTS (1 << 3) #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS (1 << 4) +#define V4L2_BUF_CAP_REQUIRES_REQUESTS (1 << 5) /** * struct v4l2_plane - plane info for multi-planar buffers From patchwork Mon Feb 25 22:19:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829203 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 2C0531805 for ; Mon, 25 Feb 2019 22:20:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AA94297A8 for ; Mon, 25 Feb 2019 22:20:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C87E2B338; Mon, 25 Feb 2019 22:20:01 +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 90ACA297A8 for ; Mon, 25 Feb 2019 22:20:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728043AbfBYWT6 (ORCPT ); Mon, 25 Feb 2019 17:19:58 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43503 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726919AbfBYWT6 (ORCPT ); Mon, 25 Feb 2019 17:19:58 -0500 Received: by mail-wr1-f65.google.com with SMTP id d17so11674943wre.10 for ; Mon, 25 Feb 2019 14:19:57 -0800 (PST) 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=Z1jDQ2uZhsiJD3Dk2zOYxfBXHk1iczGdhf5c/i9EnwA=; b=HwsjWL/JVyFSgbyaeCIr9kkeoSyrY8cJPJgoO3FYF1qUZFi/fLiIM7CcKcYxwa2SxF 88CsmKssie9Hg2woDIhOIMmycyM5ulfm5ipd9xXm2hu7FWub01+j5Ay2TUGwsWNirHqo LJ4e6HzwJN6K+WMDVz+wyj7+8laOGheElvqPmIiodmMzVUrrDTjIVxwYkVz6zlFkEvEQ qyGBXGo8LAzwFBUcvzwbD64DEEMHAHxu7sZZBaXZtIkQTCDM2KM/CZVEQrsWcCOD7Rat skVAyesllx9cwPw0+K6McoJ1aBl1/kebW+dXbNJNz5iNPSz7hTmt8KUSQ1H1ltsuyZss A79Q== 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=Z1jDQ2uZhsiJD3Dk2zOYxfBXHk1iczGdhf5c/i9EnwA=; b=RzMW1gPS9QMsWQQaJQKm4jtqic2Hdvs4IXf0mdIOgFSq4CprAArRohgSPb/9dhwgn5 AaXkl8MHzBJdZ/L6jgo3V5Ws6tBdkabgkBEW3smpd622f3OUet1h9fvU16VUsbaBArMN dRcUZibFGiGDVB3GHiduDgilWaPfIneMS2rFep8WYDCdEbotl04GPqz530FokVudZs78 9NZXhhfAZUZ1SbXWVrY3PYK+N42DSgzvFITXfrbBWlfNbRZqEcSKdkSbUlKJW1Ae6BkV q4iLcUqK+o7ZwW/jkjCevfghlUFUxZ9twBbcDNlm+X8hF9iii0R2wF5+0uNiBCbeF7pP 2hsg== X-Gm-Message-State: AHQUAuZhKdeSHNKd+8zs3DKc9pfXfzlGMx9Hvjkc8LIYmAgad3fTpZpK EEt5rJdQB9pt7oKo7rNckSITFT3KEyk= X-Google-Smtp-Source: AHgI3IbeZk/VPxJDHLoNx+3g8oipVEMnTj5j5wB5i4/rHYw+7M4wu2QDmXvlunSRySN4u0IjkylQxg== X-Received: by 2002:a5d:6810:: with SMTP id w16mr13864586wru.62.1551133196295; Mon, 25 Feb 2019 14:19:56 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id a20sm4168033wmb.17.2019.02.25.14.19.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:19:55 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH v4 03/21] cedrus: set requires_requests Date: Mon, 25 Feb 2019 14:19:27 -0800 Message-Id: <20190225221933.121653-4-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225221933.121653-1-dafna3@gmail.com> References: <20190225221933.121653-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 cedrus stateless decoder requires the use of request, so indicate this by setting requires_requests to 1. Signed-off-by: Hans Verkuil --- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index b47854b3bce4..9673874ece10 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -536,6 +536,7 @@ int cedrus_queue_init(void *priv, struct vb2_queue *src_vq, src_vq->lock = &ctx->dev->dev_mutex; src_vq->dev = ctx->dev->dev; src_vq->supports_requests = true; + src_vq->requires_requests = true; ret = vb2_queue_init(src_vq); if (ret) From patchwork Mon Feb 25 22:19:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829205 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 901451805 for ; Mon, 25 Feb 2019 22:20:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F2832B32B for ; Mon, 25 Feb 2019 22:20:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73ECA2B4F1; Mon, 25 Feb 2019 22:20:02 +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 1A2902B32B for ; Mon, 25 Feb 2019 22:20:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728071AbfBYWUB (ORCPT ); Mon, 25 Feb 2019 17:20:01 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:50607 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727357AbfBYWUA (ORCPT ); Mon, 25 Feb 2019 17:20:00 -0500 Received: by mail-wm1-f67.google.com with SMTP id x7so511898wmj.0 for ; Mon, 25 Feb 2019 14:19:58 -0800 (PST) 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=zKajMQ8qbbs/vF9eB7W61cC95ASl/yiwMSYyCZNuyJA=; b=rbJts2OPoO0sRnga0/YQjYxEdoMuWxrXv1FxFlq+xQUCfSdKawpIvYJkTRDALjcFLh L/7BVGtqt+UUAfvdPlh0WfHFWyqzwfC2ofCBm2JBbD9GHP6lstmiOaC/vp88iBvijryZ v6/ZepKiHHAZ4QrloAgbbQLiH3NhcEonsBozTxkptMAYwhklqNTM2DuXEY6oI27iQw3S EMTAqd3z9W9MVLQMoXnq/eZfwbJi9vvblInjEe/eMDXSDa6c0iBvYzDuhQuWgOy1+lHM ZwoDMnfUNLvevX4YyvybM8UdkSHAAc/CACQHlvv68OlYVj/4VASrf9ofkWVWVgNG1IEs hf0A== 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=zKajMQ8qbbs/vF9eB7W61cC95ASl/yiwMSYyCZNuyJA=; b=Cn6kaeuQUzTaW9ISDnCKjsS0y69v25E5fd8nPngv/CV2Bu7OYZh9h53zv2QLr61Zhi wUw83to7k7/ixomBiUiFyKsqFKyO7UCyL/+KFhsz8jlzziROJYx+KyJEZr6x/QVpizF3 8TedY/UGKwkpGkIIoYRR2LY9eg8gBakXrTiPTNH3+3oQomgWTKC1nx4xZwW18kpi+kwj T3M/kJ3YtMqOxQzHAmNRIawfabtVc2J/vsews0vbp7SH1l7VScb9wO70CE3mzMkIhzLL Om8CQnftmsFBddXAY9VtVgZnVmKk1bOW1rZAXhrrL0IrXsiNpj7oP2trzCX+41RqM2+X 30Tw== X-Gm-Message-State: AHQUAuYfcUO2P3tyWm8XCmFWn0QcM2fgqGFuFcT62gZ0ZRKFZcQDfBkq aWkkAzvKw/65JB4BBk3tUDWL+pSnM1c= X-Google-Smtp-Source: AHgI3IbJyf7bJTlFyihaIzbXEVeOcP8H3PUHYN6cwbvS/kzCB3m6wW6B6aEgpWJhgqI7f3pL1U9SRQ== X-Received: by 2002:a7b:c34c:: with SMTP id l12mr528356wmj.147.1551133197657; Mon, 25 Feb 2019 14:19:57 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id a20sm4168033wmb.17.2019.02.25.14.19.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:19:57 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 04/21] media: vicodec: selection api should only check single buffer types Date: Mon, 25 Feb 2019 14:19:28 -0800 Message-Id: <20190225221933.121653-5-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225221933.121653-1-dafna3@gmail.com> References: <20190225221933.121653-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 The selection api should check only single buffer types because multiplanar types are converted to single in drivers/media/v4l2-core/v4l2-ioctl.c Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index d7636fe9e174..b92a91e06e18 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -945,16 +945,6 @@ static int vidioc_g_selection(struct file *file, void *priv, { struct vicodec_ctx *ctx = file2ctx(file); struct vicodec_q_data *q_data; - enum v4l2_buf_type valid_cap_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - enum v4l2_buf_type valid_out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - - if (multiplanar) { - valid_cap_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; - valid_out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; - } - - if (s->type != valid_cap_type && s->type != valid_out_type) - return -EINVAL; q_data = get_q_data(ctx, s->type); if (!q_data) @@ -963,8 +953,8 @@ static int vidioc_g_selection(struct file *file, void *priv, * encoder supports only cropping on the OUTPUT buffer * decoder supports only composing on the CAPTURE buffer */ - if ((ctx->is_enc && s->type == valid_out_type) || - (!ctx->is_enc && s->type == valid_cap_type)) { + if ((ctx->is_enc && s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) || + (!ctx->is_enc && s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)) { switch (s->target) { case V4L2_SEL_TGT_COMPOSE: case V4L2_SEL_TGT_CROP: @@ -992,12 +982,8 @@ static int vidioc_s_selection(struct file *file, void *priv, { struct vicodec_ctx *ctx = file2ctx(file); struct vicodec_q_data *q_data; - enum v4l2_buf_type out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - - if (multiplanar) - out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; - if (s->type != out_type) + if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) return -EINVAL; q_data = get_q_data(ctx, s->type); From patchwork Mon Feb 25 22:19:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829209 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 9B3521805 for ; Mon, 25 Feb 2019 22:20:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89F77297A8 for ; Mon, 25 Feb 2019 22:20:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B5F42B338; Mon, 25 Feb 2019 22:20: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=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI 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 484A92B32B for ; Mon, 25 Feb 2019 22:20:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728128AbfBYWUC (ORCPT ); Mon, 25 Feb 2019 17:20:02 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:47020 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726919AbfBYWUB (ORCPT ); Mon, 25 Feb 2019 17:20:01 -0500 Received: by mail-wr1-f65.google.com with SMTP id i16so11676804wrs.13 for ; Mon, 25 Feb 2019 14:19:59 -0800 (PST) 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=dvajL4wp99YEdlSFfMaxVmGJLQp55KLRy+dOmN6R5Zk=; b=G6WhFluTIr8+Np1J5/2+MiOU6meGNuPZ26838n/ZZxzC2cpsuN+molId41QI0FIXkk FcFXKoHk4bHiwauQepFUyUe+TH8sc+RqrJGKiddnLUYccugYEloydcdAFvRP8rpOZsE/ vAD58pc5lKWPFHtYm1KYZsib0AnhCmfLyX8pJqEZhMTw9by8xvM90ep0ZW279KfeOd1o pzmF7qqAc/mUzdQqUPFN/n+A5IV7NIsebR4s0Qq29ClqsqLyUyN4DybL3hELcvb+X1Rg syNVQjlpsU1Dngi25vdsxjYeoQRfIlWwQP6Tply142gc14U384Sb+Rpcdpm6v1Bef5n4 P6Qg== 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=dvajL4wp99YEdlSFfMaxVmGJLQp55KLRy+dOmN6R5Zk=; b=HR+pORtc3LmZrQakx0NbIm4KeQ9fuQyEKm6/SAKGteRRdH2DXn4FXc8rQEGwjCbtTc 3XRgeH68gawWWi0RfxtLcnXgzDT00UA+e7hlYm+9ock39+7PdXRPKfTdq9mP9jfUBdhk hha3r8fgs5/3feldFi6zHEk9VIq9pHxPOoVM7FdTHW4zOXphvREMauT9KzxIoG5osxFZ mx9S88BZmB4Ym6mOHu926HLR3CG+DadbwsVPkK76xhty7RQOwq6sdY3pPgdUde5gaYl5 PcQflNNyc80m2QdVjnYK6V5WJc1EoAJgBTwBTbrQaUjJ2ouCxDXqmyIsXgeSzTar63yi fzNg== X-Gm-Message-State: AHQUAuZQQsS2CM0vU3lq4t8zttIQDZPLg3mCpQ3RYoe6vKrV0VtGhGTO +FVx7y8AITJUFPzSu4Gpb5hxjoNTojA= X-Google-Smtp-Source: AHgI3IYQgoiqUBR2wAbaY4G6UlmwvYbd/OWS+l4AZcLex2cXQwOJY+g/8odQhqiedH9znXcLi6MikA== X-Received: by 2002:adf:f7c9:: with SMTP id a9mr14939865wrq.39.1551133198962; Mon, 25 Feb 2019 14:19:58 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id a20sm4168033wmb.17.2019.02.25.14.19.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:19:58 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 05/21] media: vicodec: upon release, call m2m release before freeing ctrl handler Date: Mon, 25 Feb 2019 14:19:29 -0800 Message-Id: <20190225221933.121653-6-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225221933.121653-1-dafna3@gmail.com> References: <20190225221933.121653-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 'v4l2_m2m_ctx_release' calls request complete so it should be called before 'v4l2_ctrl_handler_free'. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index b92a91e06e18..0909f86547f1 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -1606,12 +1606,12 @@ static int vicodec_release(struct file *file) struct video_device *vfd = video_devdata(file); struct vicodec_ctx *ctx = file2ctx(file); - v4l2_fh_del(&ctx->fh); - v4l2_fh_exit(&ctx->fh); - v4l2_ctrl_handler_free(&ctx->hdl); mutex_lock(vfd->lock); v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); mutex_unlock(vfd->lock); + v4l2_fh_del(&ctx->fh); + v4l2_fh_exit(&ctx->fh); + v4l2_ctrl_handler_free(&ctx->hdl); kfree(ctx); return 0; From patchwork Mon Feb 25 22:19:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829211 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 B8F611805 for ; Mon, 25 Feb 2019 22:20:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A92C42B4D5 for ; Mon, 25 Feb 2019 22:20:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6F1D2BF60; Mon, 25 Feb 2019 22:20: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=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI 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 6AC192B4D5 for ; Mon, 25 Feb 2019 22:20:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728178AbfBYWUE (ORCPT ); Mon, 25 Feb 2019 17:20:04 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:41484 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727357AbfBYWUC (ORCPT ); Mon, 25 Feb 2019 17:20:02 -0500 Received: by mail-wr1-f67.google.com with SMTP id n2so11698947wrw.8 for ; Mon, 25 Feb 2019 14:20:01 -0800 (PST) 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=iPmSdIbe4trCHxbnuMCBZC6tC1phNVbZzz8x8XUekG8=; b=NPOJpWJp8IvR1QYJ/EFHN4VQ+rt2hh4bn88OdUixkeG6I3QZyKrPcPGbhj2W2tP3Ax 3fYfVJ7QumokCf7lGwoCKPvVqA7SECl+4lL0voAuYj1bbbK77yimNwFWPSyqNmz/9WsY 3oqCS6a3DibFyjT/9rPWTZjpNtUtjMeV5vuC96YCIhxqGi1IzZ8u3V9tC1N+aQoIMGHE acKEiqxlKCeapaPRWcz55svjhh35rfWX5Q44fl/uyvwiCP236TBAVVYaEOghuOauXQSH 6ZBXp2Rd1LkQm8TzdrJG0wThWIaB7YQgYw4A71h0jMMhs7MqzJ5t1METYVOJzw8f9eD3 4wXw== 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=iPmSdIbe4trCHxbnuMCBZC6tC1phNVbZzz8x8XUekG8=; b=D9YWdBaRnDtzAX7YHcCPNu4MADApAuDkJKhgEeHS6CNYKTVMY5YxXTUzej0aehaf6T H8jjr1AVq9YcHLkM8aCqYOiM/a17SveJNe+NaLY3gSMiK6HxZ6rDIVlNK0IRrYunlM80 i6Er0oaQ2vnRetDw1gE9kUl+uTt9H1zpBKrdda/7sCtAcsqJtYqSxM7t4NyJxkHPFpo6 8nK4kH/d9Z/4toKPd9mfEmmE5Je1dWGoaOdqWioza9X7Tjkndd6H9MpY4SFdYrj3BRNV WjatbCLhmH6K5EZ3uybtl65bV+H79rKkrHJ2uchSiaWQCMbjnzVGzm1dh9482yKKY6wf ikuQ== X-Gm-Message-State: AHQUAuZRIl+oxyq6OqGmlH8FcRz5XZZnJzq41Lp3LC+S5Mstn6XNms3k fy1TN0le+jtw20d9U3Wyv7x63DxHWLc= X-Google-Smtp-Source: AHgI3IZFOJya8z76XC2eYureV1OrVWq8u7/Znqkgw4vMED+yhcvKTpOUcPScC+2R7Mxy3gyHCHq9Pw== X-Received: by 2002:a5d:4710:: with SMTP id y16mr13916348wrq.305.1551133200344; Mon, 25 Feb 2019 14:20:00 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id a20sm4168033wmb.17.2019.02.25.14.19.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:19:59 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 06/21] media: v4l2-ctrl: v4l2_ctrl_request_setup returns with error upon failure Date: Mon, 25 Feb 2019 14:19:30 -0800 Message-Id: <20190225221933.121653-7-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225221933.121653-1-dafna3@gmail.com> References: <20190225221933.121653-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 If one of the controls fails to set, then 'v4l2_ctrl_request_setup' immediately returns with the error code. Signed-off-by: Dafna Hirschfeld --- drivers/media/v4l2-core/v4l2-ctrls.c | 18 +++++++++++------- include/media/v4l2-ctrls.h | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index b79d3bbd8350..54d66dbc2a31 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -3899,18 +3899,19 @@ void v4l2_ctrl_request_complete(struct media_request *req, } EXPORT_SYMBOL(v4l2_ctrl_request_complete); -void v4l2_ctrl_request_setup(struct media_request *req, +int v4l2_ctrl_request_setup(struct media_request *req, struct v4l2_ctrl_handler *main_hdl) { struct media_request_object *obj; struct v4l2_ctrl_handler *hdl; struct v4l2_ctrl_ref *ref; + int ret = 0; if (!req || !main_hdl) - return; + return 0; if (WARN_ON(req->state != MEDIA_REQUEST_STATE_QUEUED)) - return; + return -EBUSY; /* * Note that it is valid if nothing was found. It means @@ -3919,10 +3920,10 @@ void v4l2_ctrl_request_setup(struct media_request *req, */ obj = media_request_object_find(req, &req_ops, main_hdl); if (!obj) - return; + return 0; if (obj->completed) { media_request_object_put(obj); - return; + return -EBUSY; } hdl = container_of(obj, struct v4l2_ctrl_handler, req_obj); @@ -3990,12 +3991,15 @@ void v4l2_ctrl_request_setup(struct media_request *req, update_from_auto_cluster(master); } - try_or_set_cluster(NULL, master, true, 0); - + ret = try_or_set_cluster(NULL, master, true, 0); v4l2_ctrl_unlock(master); + + if (ret) + break; } media_request_object_put(obj); + return ret; } EXPORT_SYMBOL(v4l2_ctrl_request_setup); diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index d63cf227b0ab..c40dcf79b5b9 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -1127,7 +1127,7 @@ __poll_t v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait); * applying control values in a request is only applicable to memory-to-memory * devices. */ -void v4l2_ctrl_request_setup(struct media_request *req, +int v4l2_ctrl_request_setup(struct media_request *req, struct v4l2_ctrl_handler *parent); /** From patchwork Mon Feb 25 22:19:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829215 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 D42DA1390 for ; Mon, 25 Feb 2019 22:20:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C69FE2B4F1 for ; Mon, 25 Feb 2019 22:20:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C49062BF4F; Mon, 25 Feb 2019 22:20:34 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI 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 8CDE32B4F1 for ; Mon, 25 Feb 2019 22:20:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728204AbfBYWUF (ORCPT ); Mon, 25 Feb 2019 17:20:05 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:50611 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728139AbfBYWUD (ORCPT ); Mon, 25 Feb 2019 17:20:03 -0500 Received: by mail-wm1-f68.google.com with SMTP id x7so512011wmj.0 for ; Mon, 25 Feb 2019 14:20:02 -0800 (PST) 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=vMyMpGqqdM36AhawPTalbjw4IFBI0qu83CyqC1tgsXE=; b=gH6KMbTM5xJWaFOGx+HFo8xj5w8EJeAscfCHlofmsHnLe28YMYAfOQwq+msXxx1DEU F3bbiSAXM83w7GUtOQ/6cx6OOpDvXhte4WmzP7EhuBqlvZhb4uy0Gx9gn3wrqk6dqxya EJwzvFG50U+bHL69eiwz05jaNQ1JLkHV+DuWtr4K/K4wECERDBTkyibc7Rla1jhxUnRd IJDcMOf5GMY6jwB6fJ6aGWzEY0SXCemI3UAcgZshFVQoJIjcK+k9PfePEqsV5qDRIRSs XfKfJ4zLjcjLlFAo4Qylc9waEAxMEOC8Is3aKeSAES1x+9mScTUmD0gH6bWXboI1sNat Lb7Q== 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=vMyMpGqqdM36AhawPTalbjw4IFBI0qu83CyqC1tgsXE=; b=bqUNDi3oxUHxsfU894+4vsaPZBbz1MfUrPk1phjGLP1hj1VEXCvWqTXtvLeLWsdAIj 9MK3Z184SoGHJU/OyNAj6zGIeMYunJfrdagDGihhwMp2AGbKH4P5qd4G5HVHFcNvOcmp wBxfKWNbnY+EB/MUOc+i6b4k9Rqc9DeXAwLSKFx4iK3xCE7WicaQcRkV67GfLWrQ/KOp TUW7f+QO7TKXAv6/cXZkaB2+no0oEJNQXKZQQXNf5ndGbO5Nt/tQY2cQBKsGWWX8FsE8 qFqYKIkwDEBFGja41P6kK8MgDvVRPH6o9VB7gs8YKZ2p2fWbq3oAscd/xRCZg2VsA8FJ uYXw== X-Gm-Message-State: AHQUAuZKkpBgtoBwhEV5ZW1tmazn1tNaKPGhxzrEelJw1kjAq4X/O96O +qz319P8HPyP/3xWUG0GU+/Girm9GtA= X-Google-Smtp-Source: AHgI3IYL06u3K+z3rl1njWuZ1yxEewpwkFjExBGmQi06tNJEm19ZLowhJ6sJSl2sFr21MIvUCgewDA== X-Received: by 2002:a1c:720f:: with SMTP id n15mr518172wmc.64.1551133201730; Mon, 25 Feb 2019 14:20:01 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id a20sm4168033wmb.17.2019.02.25.14.20.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:20:01 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 07/21] media: vicodec: change variable name for the return value of v4l2_fwht_encode Date: Mon, 25 Feb 2019 14:19:31 -0800 Message-Id: <20190225221933.121653-8-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225221933.121653-1-dafna3@gmail.com> References: <20190225221933.121653-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 v4l2_fwht_encode returns either an error code on failure or the size of the compressed frame on success. So change the var assigned to it from 'ret' to 'comp_sz_or_errcode' to clarify that. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 0909f86547f1..eec31b144d56 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -178,13 +178,14 @@ static int device_process(struct vicodec_ctx *ctx, if (ctx->is_enc) { struct vicodec_q_data *q_src; + int comp_sz_or_errcode; q_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); state->info = q_src->info; - ret = v4l2_fwht_encode(state, p_src, p_dst); - if (ret < 0) - return ret; - vb2_set_plane_payload(&dst_vb->vb2_buf, 0, ret); + comp_sz_or_errcode = v4l2_fwht_encode(state, p_src, p_dst); + if (comp_sz_or_errcode < 0) + return comp_sz_or_errcode; + vb2_set_plane_payload(&dst_vb->vb2_buf, 0, comp_sz_or_errcode); } else { unsigned int comp_frame_size = ntohl(ctx->state.header.size); From patchwork Mon Feb 25 22:19:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829217 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 F0FD41515 for ; Mon, 25 Feb 2019 22:20:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E25782BF4B for ; Mon, 25 Feb 2019 22:20:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0B482B423; Mon, 25 Feb 2019 22:20:39 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI 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 AED76297A8 for ; Mon, 25 Feb 2019 22:20:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728316AbfBYWUG (ORCPT ); Mon, 25 Feb 2019 17:20:06 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:39618 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728146AbfBYWUF (ORCPT ); Mon, 25 Feb 2019 17:20:05 -0500 Received: by mail-wr1-f65.google.com with SMTP id l5so11713588wrw.6 for ; Mon, 25 Feb 2019 14:20:04 -0800 (PST) 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=4ayEOXWVt6sti0jEKrJJnU5rJOmMEFp+b2iYryD4XyI=; b=RbtseVLXq6URdeqBjGg8SQ9TQwxb+MlW/8kdP9pJI1sjG0SeTp+Ro7CMHtYitQr1nu hUZiHmAqWmtqE0oY1NJwqFtk/76rK49cvAcfGVi0WF5mcUiRZPLwtyLdD6GsL4RH0kmV K/cEVSgP66RZ719ptBzAaDMmRiBQ09+hU83pe5stJHCLmR4YH5AlYnc0p0pCWpYeg6tI avoJ2E6QAmsyTYkISR38PnHHTmS1ujycNgphcD96ORYHYhsMvEavkLVsCe1NM87/MMlE VbC+3tYad3OzYEz8LuyK2p4WAQk17WM8KVxTqSjCtR8CrAAd1jENOQUw2zDJdb149vaj 9V8Q== 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=4ayEOXWVt6sti0jEKrJJnU5rJOmMEFp+b2iYryD4XyI=; b=V0DucoeIBArat9eLYMz2FmL4vBIcNdlVpt4Gv051pxrg3ZTbDhh1QVHzsWbs61WDtc lwQz8OhU9T/I//braN/LSOop9uT2Em8476YWrLEc1r41RjIgots6swGq7DpLE+S6xJUQ W0OnOwNV0f81DWyVEYN1BAMUubfcCSY7K9l2CKon1xvjMfkCHbPheWQVP06KlAlamamh EEu8PhNkZ+1EE/ayZ55FAMWayoRxmlARuItVSeULQgYjQdLTrflTx2N7eQXHqYzoe191 VfQLIbsc94tA6FQprqf6TmxhNCbIII2gOqk1u+P791hzQpIKkxvy2L3+Z8GC3pAscMBP huEw== X-Gm-Message-State: AHQUAuYgnLGL3UK4+R4BSOKttyyKf8hpViGnMHwQpNdL+c9ENvyv5lqw eML4JR2eQsBtEVobeHaafIpdIGMLzhg= X-Google-Smtp-Source: AHgI3IaI6mkbPoJvJA3AlNOumOiRhGe6gSEZ7K6adDp2flCM6KUPlhXXwQu/XGEpnZpUAPo6n9Rlxw== X-Received: by 2002:a5d:4f91:: with SMTP id d17mr15211704wru.67.1551133203166; Mon, 25 Feb 2019 14:20:03 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id a20sm4168033wmb.17.2019.02.25.14.20.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:20:02 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 08/21] media: vicodec: bugfix - call v4l2_m2m_buf_copy_metadata also if decoding fails Date: Mon, 25 Feb 2019 14:19:32 -0800 Message-Id: <20190225221933.121653-9-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225221933.121653-1-dafna3@gmail.com> References: <20190225221933.121653-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 The function 'v4l2_m2m_buf_copy_metadata' should be called even if decoding/encoding ends with status VB2_BUF_STATE_ERROR, so that the metadata is copied from the source buffer to the dest buffer. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index eec31b144d56..8205a602bb38 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -159,12 +159,10 @@ static int device_process(struct vicodec_ctx *ctx, struct vb2_v4l2_buffer *dst_vb) { struct vicodec_dev *dev = ctx->dev; - struct vicodec_q_data *q_dst; struct v4l2_fwht_state *state = &ctx->state; u8 *p_src, *p_dst; int ret; - q_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); if (ctx->is_enc) p_src = vb2_plane_vaddr(&src_vb->vb2_buf, 0); else @@ -187,8 +185,10 @@ static int device_process(struct vicodec_ctx *ctx, return comp_sz_or_errcode; 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); + q_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); if (comp_frame_size > ctx->comp_max_size) return -EINVAL; state->info = q_dst->info; @@ -197,11 +197,6 @@ static int device_process(struct vicodec_ctx *ctx, return ret; vb2_set_plane_payload(&dst_vb->vb2_buf, 0, q_dst->sizeimage); } - - dst_vb->sequence = q_dst->sequence++; - dst_vb->flags &= ~V4L2_BUF_FLAG_LAST; - v4l2_m2m_buf_copy_metadata(src_vb, dst_vb, !ctx->is_enc); - return 0; } @@ -275,16 +270,22 @@ 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; + struct vicodec_q_data *q_src, *q_dst; u32 state; src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); q_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); + q_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); state = VB2_BUF_STATE_DONE; if (device_process(ctx, src_buf, dst_buf)) state = VB2_BUF_STATE_ERROR; + 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); + ctx->last_dst_buf = dst_buf; spin_lock(ctx->lock); From patchwork Mon Feb 25 22:19:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829213 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 2E4CE1390 for ; Mon, 25 Feb 2019 22:20:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 211F12BF60 for ; Mon, 25 Feb 2019 22:20:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F21B2BF6B; Mon, 25 Feb 2019 22:20: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 D17EC2BF60 for ; Mon, 25 Feb 2019 22:20:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728326AbfBYWUH (ORCPT ); Mon, 25 Feb 2019 17:20:07 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:51873 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728207AbfBYWUG (ORCPT ); Mon, 25 Feb 2019 17:20:06 -0500 Received: by mail-wm1-f65.google.com with SMTP id n19so505824wmi.1 for ; Mon, 25 Feb 2019 14:20:05 -0800 (PST) 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=W9KqbqFn/6YfJv+YuJSvZWh6iSIWrSMsB1/ivTkTeB8=; b=rRZk9JQSXEmWbNLdFGeXYvfZM8QQlYJIozno3gInAVEnE/GbL83kwJ9fJYnFtSUEYQ GEzZwGiNt8xP++ywgGkmPcYszKUC4J7g9JsoZvDuo7DxISrgCgIXg+5QZAiB5wWBqU04 cIZq04iMppk7yPVptNsTtuk0xndxx8pSeN5rws0voJNs5jY6G1tVYo5RB9dXBIi1b+sM 5H89zR385GPZ0qeuQJisvHDNVHnuEFE+4nWk40916XIQcP4uthBgPu/u6Trwbkzomp39 JqOnQ2oYmGMgSOnhOhejcH97gpugmy4VOCOy25daMH39BQ/mCuS3scT30ZKvEp99KPxL UCwQ== 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=W9KqbqFn/6YfJv+YuJSvZWh6iSIWrSMsB1/ivTkTeB8=; b=IJmGkEWJqmkn9v8eFNxkjuHOAroFaBA1CDkArsN/1iZQCymHBae6RWIUQoIh5nq+Wj xu7+r+Egq5fL321PZYIvZx0zqUWrqo5oTyIcew+7F6LNi8iHoYaXfKwrma3li71iNS2C rmEuddubckUrg9jWCvIxy8B00qpSAE10SyTErFSEMtnEh9/dwL/RNoEGT1bFzJ35OyyW gnacGpXpXzfcZ0W3FzBYsdLQ3s+xSuL4kv8rIILU7YnBieR8eKfYLG7KnSp82Xri4hGG s2p9gSDwp1PAHXKNyveDHC4aWxpaeUiZyedQHI/JqAb/FCvIrT0HQe4zVqfAByN7EMJs d0nQ== X-Gm-Message-State: AHQUAuZEuknV2WAsKpM5VxXxogd09O8K/QU4GAV41sLdyYv6DV5zloED BR6rDvPgdbHSr3dVe5Ih189piEJeEAM= X-Google-Smtp-Source: AHgI3Ibl/wNNJeMH1T7vWO0nJzqrx7rY9dCWii0M0+1stpTGRss/zP/Id+pcA2mP8aFcrFXvJ64n5Q== X-Received: by 2002:a7b:cbcd:: with SMTP id n13mr597778wmi.92.1551133204495; Mon, 25 Feb 2019 14:20:04 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id a20sm4168033wmb.17.2019.02.25.14.20.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:20:03 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 09/21] media: vicodec: bugfix: free compressed_frame upon device release Date: Mon, 25 Feb 2019 14:19:33 -0800 Message-Id: <20190225221933.121653-10-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225221933.121653-1-dafna3@gmail.com> References: <20190225221933.121653-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 Free compressed_frame buffer upon device release. 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 8205a602bb38..8128ea6d1948 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -1614,6 +1614,7 @@ static int vicodec_release(struct file *file) v4l2_fh_del(&ctx->fh); v4l2_fh_exit(&ctx->fh); v4l2_ctrl_handler_free(&ctx->hdl); + kvfree(ctx->state.compressed_frame); kfree(ctx); return 0; From patchwork Mon Feb 25 22:22: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: 10829219 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 89F1B1515 for ; Mon, 25 Feb 2019 22:22:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C5D12BFD5 for ; Mon, 25 Feb 2019 22:22:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 709E92BFD4; Mon, 25 Feb 2019 22:22:23 +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 D78D02BFD6 for ; Mon, 25 Feb 2019 22:22:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727502AbfBYWWW (ORCPT ); Mon, 25 Feb 2019 17:22:22 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41670 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726842AbfBYWWV (ORCPT ); Mon, 25 Feb 2019 17:22:21 -0500 Received: by mail-wr1-f66.google.com with SMTP id n2so11703947wrw.8 for ; Mon, 25 Feb 2019 14:22:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=N3iDG/yikMh8AExZiSWQRYKCi89Q3tUUiOmO5GOcbl0=; b=klUe9fKl1cz/XpbqmyqNNPrLvgzo3Hjdj43RyC7waG58vah4xXqOd8DVO4U/SpN284 8Woq6KH6Oua6cI+2vk8d9fJb8+HWOmwGxq3aoayK6rbr0E01gOpe4mMSfXEK1uEQsMMc Cq8qbIYfBA/523TWTH4hbTF2uXkf+tUTF52oxNnMJ0Mo6FX1cByvOebewNF3bEd1bNBH fa/JbqjSA9EI9QObNQbHReeOQUqLg4dpXfRf/wcwZnW+51nPIHFVi75UuKW6R3IDpErs 0nMgR4JUBDwfqC/UuJmrvI0ZKgSoAgiAEDwdhg7btkDGWTNOksGMHfTIRsoPjRt4ikPY zQ+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=N3iDG/yikMh8AExZiSWQRYKCi89Q3tUUiOmO5GOcbl0=; b=EYt0IW6sPQ7dOxommHnRqSHQmz/LB9OWGoUa/4Vk48TMMWX17Qf3I4i36xczjMOqv/ TiyflIrPMhb3k8n4RCrWXt0imFcGTze1Q/blTwhamNdw3trSIIAVk/dgPwLEfNFijQ7h 8BqlPFlmbUJqbN7nwgDrK0rbO/EMAy1RACzlzB8QKFlx4rsRDT7BA4zFDasBd5NLT2PZ gQF5B/EqZ6QxrKYwMu8UyseOtEViHYK8jURjBXB1zsKZ3gvNcftun89H43fFcdze1c0y w5X2NC6CftCwELsFEhZx/cVHB94Xfr+XKxdLjyPRZzGGD4hfRfgR3qJShvs0Q+AvcB38 eokw== X-Gm-Message-State: AHQUAub06dVaXnRirVIJMPIy8dCSl+60d1n0a4w+wLgyXUD+StaLJ3PT 2BRlFlgAf0oOwn0VYuwsJju/asET72I= X-Google-Smtp-Source: AHgI3IZ4+kdykQhh09ize+BoHIEO6C+VI0BGZeMcNWUujPJIyx5j6iHE0OAoSeX6T/LaApT2GkJvWw== X-Received: by 2002:adf:df0d:: with SMTP id y13mr13662492wrl.69.1551133338909; Mon, 25 Feb 2019 14:22:18 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id d206sm16981422wmc.11.2019.02.25.14.22.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:22:18 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 10/21] media: vicodec: Move raw frame preparation code to a function Date: Mon, 25 Feb 2019 14:22:01 -0800 Message-Id: <20190225222210.121713-1-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 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 Introduce 'prepare_raw_frame' function that fills the values of a raw frame struct according to the format. Signed-off-by: Dafna Hirschfeld --- .../media/platform/vicodec/codec-v4l2-fwht.c | 143 ++++++++++-------- 1 file changed, 78 insertions(+), 65 deletions(-) diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.c b/drivers/media/platform/vicodec/codec-v4l2-fwht.c index 6573a471c5ca..515b3115b3c6 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.c +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.c @@ -75,117 +75,130 @@ const struct v4l2_fwht_pixfmt_info *v4l2_fwht_get_pixfmt(u32 idx) return v4l2_fwht_pixfmts + idx; } -int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) +static int prepare_raw_frame(struct fwht_raw_frame *rf, + const struct v4l2_fwht_pixfmt_info *info, u8 *buf, + unsigned int size) { - 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; - u32 flags = 0; - - if (!info) - return -EINVAL; - - rf.luma = p_in; - rf.width_div = info->width_div; - rf.height_div = info->height_div; - rf.luma_alpha_step = info->luma_alpha_step; - rf.chroma_step = info->chroma_step; - rf.alpha = NULL; - rf.components_num = info->components_num; + rf->luma = buf; + rf->width_div = info->width_div; + rf->height_div = info->height_div; + rf->luma_alpha_step = info->luma_alpha_step; + rf->chroma_step = info->chroma_step; + rf->alpha = NULL; + rf->components_num = info->components_num; switch (info->id) { case V4L2_PIX_FMT_GREY: - rf.cb = NULL; - rf.cr = NULL; + rf->cb = NULL; + rf->cr = NULL; break; case V4L2_PIX_FMT_YUV420: - rf.cb = rf.luma + size; - rf.cr = rf.cb + size / 4; - chroma_stride /= 2; + rf->cb = rf->luma + size; + rf->cr = rf->cb + size / 4; break; case V4L2_PIX_FMT_YVU420: - rf.cr = rf.luma + size; - rf.cb = rf.cr + size / 4; - chroma_stride /= 2; + rf->cr = rf->luma + size; + rf->cb = rf->cr + size / 4; break; case V4L2_PIX_FMT_YUV422P: - rf.cb = rf.luma + size; - rf.cr = rf.cb + size / 2; - chroma_stride /= 2; + rf->cb = rf->luma + size; + rf->cr = rf->cb + size / 2; break; case V4L2_PIX_FMT_NV12: case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_NV24: - rf.cb = rf.luma + size; - rf.cr = rf.cb + 1; + rf->cb = rf->luma + size; + rf->cr = rf->cb + 1; break; case V4L2_PIX_FMT_NV21: case V4L2_PIX_FMT_NV61: case V4L2_PIX_FMT_NV42: - rf.cr = rf.luma + size; - rf.cb = rf.cr + 1; + rf->cr = rf->luma + size; + rf->cb = rf->cr + 1; break; case V4L2_PIX_FMT_YUYV: - rf.cb = rf.luma + 1; - rf.cr = rf.cb + 2; + rf->cb = rf->luma + 1; + rf->cr = rf->cb + 2; break; case V4L2_PIX_FMT_YVYU: - rf.cr = rf.luma + 1; - rf.cb = rf.cr + 2; + rf->cr = rf->luma + 1; + rf->cb = rf->cr + 2; break; case V4L2_PIX_FMT_UYVY: - rf.cb = rf.luma; - rf.cr = rf.cb + 2; - rf.luma++; + rf->cb = rf->luma; + rf->cr = rf->cb + 2; + rf->luma++; break; case V4L2_PIX_FMT_VYUY: - rf.cr = rf.luma; - rf.cb = rf.cr + 2; - rf.luma++; + rf->cr = rf->luma; + rf->cb = rf->cr + 2; + rf->luma++; break; case V4L2_PIX_FMT_RGB24: case V4L2_PIX_FMT_HSV24: - rf.cr = rf.luma; - rf.cb = rf.cr + 2; - rf.luma++; + rf->cr = rf->luma; + rf->cb = rf->cr + 2; + rf->luma++; break; case V4L2_PIX_FMT_BGR24: - rf.cb = rf.luma; - rf.cr = rf.cb + 2; - rf.luma++; + rf->cb = rf->luma; + rf->cr = rf->cb + 2; + rf->luma++; break; case V4L2_PIX_FMT_RGB32: case V4L2_PIX_FMT_XRGB32: case V4L2_PIX_FMT_HSV32: - rf.cr = rf.luma + 1; - rf.cb = rf.cr + 2; - rf.luma += 2; + rf->cr = rf->luma + 1; + rf->cb = rf->cr + 2; + rf->luma += 2; break; case V4L2_PIX_FMT_BGR32: case V4L2_PIX_FMT_XBGR32: - rf.cb = rf.luma; - rf.cr = rf.cb + 2; - rf.luma++; + rf->cb = rf->luma; + rf->cr = rf->cb + 2; + rf->luma++; break; case V4L2_PIX_FMT_ARGB32: - rf.alpha = rf.luma; - rf.cr = rf.luma + 1; - rf.cb = rf.cr + 2; - rf.luma += 2; + rf->alpha = rf->luma; + rf->cr = rf->luma + 1; + rf->cb = rf->cr + 2; + rf->luma += 2; break; case V4L2_PIX_FMT_ABGR32: - rf.cb = rf.luma; - rf.cr = rf.cb + 2; - rf.luma++; - rf.alpha = rf.cr + 1; + rf->cb = rf->luma; + rf->cr = rf->cb + 2; + rf->luma++; + rf->alpha = rf->cr + 1; break; default: return -EINVAL; } + return 0; +} + +int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) +{ + 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; + u32 flags = 0; + + if (!info) + return -EINVAL; + + if (prepare_raw_frame(&rf, info, p_in, size)) + return -EINVAL; + + if (info->planes_num == 3) + chroma_stride /= 2; + + if (info->id == V4L2_PIX_FMT_NV24 || + info->id == V4L2_PIX_FMT_NV42) + chroma_stride *= 2; cf.i_frame_qp = state->i_frame_qp; cf.p_frame_qp = state->p_frame_qp; From patchwork Mon Feb 25 22:22:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829221 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 E30A215AC for ; Mon, 25 Feb 2019 22:22:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D47E32BFC9 for ; Mon, 25 Feb 2019 22:22:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C91BC2BFC8; Mon, 25 Feb 2019 22:22:23 +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 726B62BFAF for ; Mon, 25 Feb 2019 22:22:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727546AbfBYWWW (ORCPT ); Mon, 25 Feb 2019 17:22:22 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:39805 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726845AbfBYWWW (ORCPT ); Mon, 25 Feb 2019 17:22:22 -0500 Received: by mail-wr1-f67.google.com with SMTP id l5so11718723wrw.6 for ; Mon, 25 Feb 2019 14:22:21 -0800 (PST) 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=ZvTkVhC004g66pVAoaWQCbnS0Q4Lnh5O0JAznaE+x18=; b=ZR0ujHCGPS5Ji8TRXlyTLpfytdHyz3vtL8NM3+G1ABkPrzzIXGY4pB527su615oNeU kNR5jPkbL/eOQff/IKcEdVzFp5FqIcBuXc4pNkc0H4nLXE0EQDWuepR+JaQfGnEzwwFT KnGGFAbav2YNhbexkxydomzjffdWrCLGUuZuG4PmyQZUuVRN1oN4IJ4ukXm+dX4fbdn8 st4OmuPInWDFPdW1h/rE25hZsvIYc2g3Mn+jaJQqLnuW1iYEv/I8KOX+O2Wa794ow4j/ 6HNWr3i9y3nlzi4aZ2OAbvDs12YgRAz32JEQkA2JdSSxj/ZeIEMt+hgeRRcOM5NATnXa aNVw== 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=ZvTkVhC004g66pVAoaWQCbnS0Q4Lnh5O0JAznaE+x18=; b=dpZR4QiWv5NNp8XVaQkESSD2Z/nmj66WnCrz7VAR03dB7qElgOYC2bsQayhcL8ImYm YhfvlWA/cUp6NSKhymbRZb84E6XEv1KFl331AVt/lIbgJLDsEyNXIpQzyzse1pldMmHK Rd8MNROLdnVbPHL5g3vpIvNFfSifC7M+Ongqgu8tswd5d9TmL8FF0/bUJsbnEGJnClBU RW7GwJB+ZZG8U/2uRdOxH5zEPqz6N05grZfeYVKNOORIGAJyGiwspQwT1UQ2slZggniF RDyJMuLsdU9nhuH672Vk6+eWeIEaJ49KmyJYDpZU8x8YmzzvOGD5rRcxTlPtga9hPRwu Y+sQ== X-Gm-Message-State: AHQUAuZyRIztsm7Yb3OfJPmBOp2sHEsbmQl802PoseisM9IkeJfHFsnM zx7P2UKPqj3I5tysyvvFzvoZbM1sXcs= X-Google-Smtp-Source: AHgI3IYEONfjA2TF0J2brWzHf2ZeaJKm0rhEh5qmPfvRLLIaPFkC36qoeJSxPsbaXTt/YZ8voeKaLw== X-Received: by 2002:adf:f5d0:: with SMTP id k16mr12478654wrp.325.1551133340241; Mon, 25 Feb 2019 14:22:20 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id d206sm16981422wmc.11.2019.02.25.14.22.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:22:19 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 11/21] media: vicodec: add field 'buf' to fwht_raw_frame Date: Mon, 25 Feb 2019 14:22:02 -0800 Message-Id: <20190225222210.121713-2-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225222210.121713-1-dafna3@gmail.com> References: <20190225222210.121713-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 'buf' to fwht_raw_frame to indicate the start of the raw frame buffer. This field will be used to copy the capture buffer to the reference buffer in the next patch. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/codec-fwht.h | 1 + drivers/media/platform/vicodec/vicodec-core.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/vicodec/codec-fwht.h b/drivers/media/platform/vicodec/codec-fwht.h index c410512d47c5..8f0b790839f8 100644 --- a/drivers/media/platform/vicodec/codec-fwht.h +++ b/drivers/media/platform/vicodec/codec-fwht.h @@ -124,6 +124,7 @@ struct fwht_raw_frame { unsigned int luma_alpha_step; unsigned int chroma_step; unsigned int components_num; + u8 *buf; u8 *luma, *cb, *cr, *alpha; }; diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 8128ea6d1948..42af0e922249 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -1352,7 +1352,8 @@ static int vicodec_start_streaming(struct vb2_queue *q, state->stride = q_data->coded_width * info->bytesperline_mult; - state->ref_frame.luma = kvmalloc(total_planes_size, GFP_KERNEL); + state->ref_frame.buf = kvmalloc(total_planes_size, GFP_KERNEL); + state->ref_frame.luma = state->ref_frame.buf; ctx->comp_max_size = total_planes_size; new_comp_frame = kvmalloc(ctx->comp_max_size, GFP_KERNEL); @@ -1401,7 +1402,9 @@ 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)) { - kvfree(ctx->state.ref_frame.luma); + kvfree(ctx->state.ref_frame.buf); + ctx->state.ref_frame.buf = NULL; + ctx->state.ref_frame.luma = NULL; ctx->comp_max_size = 0; ctx->source_changed = false; } From patchwork Mon Feb 25 22:22:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829225 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 48F301515 for ; Mon, 25 Feb 2019 22:22:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38F3F2BF83 for ; Mon, 25 Feb 2019 22:22:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36CF72BFDF; Mon, 25 Feb 2019 22:22:28 +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 DDDD92BFDA for ; Mon, 25 Feb 2019 22:22:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727987AbfBYWW0 (ORCPT ); Mon, 25 Feb 2019 17:22:26 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34652 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726845AbfBYWWZ (ORCPT ); Mon, 25 Feb 2019 17:22:25 -0500 Received: by mail-wr1-f66.google.com with SMTP id f14so11745845wrg.1 for ; Mon, 25 Feb 2019 14:22:23 -0800 (PST) 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=Mdiw33VQVsyIp0tyh2/dE0nHUFM8oGXwije4Jw5HgM4=; b=A2VvtB9uiJVMvn6LbIwbUMXOLFjhWswzNCD19nSF9NlmvspbmTNcyWPm1IAn9kJ4FX ydyPFZMZttcU0+4FyFzYVRFZRcBIQ66+OpJ1ceScckjz4TrclDwrbBZi5jQiqtIA34xi EhquJqfEopD0BCJfTXY3qaPVAxafFwxvlhR3cJXjHSsKgcQub8lMCW7ppXuJb8gp3HCS F6c3ulOIr8dnDiort73tB/RnShe+9i4b8tl+g6hOFmneUjkASAlL6qAIj/Za6QufkwgA pY0OgBo6dvoJonIxrMUV6NYzH0wFmGt1jp5ownlYI2NErv9w0E/PTBx+3cJqzxa4woLk ANZA== 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=Mdiw33VQVsyIp0tyh2/dE0nHUFM8oGXwije4Jw5HgM4=; b=sOC96eT0C0depFgly7Qr57Gjjrm752nYnvt0KMobBTgZJOY/tCTWgpxsQGCjDaJKEn 8LeyhHjRRMNgqhY7mVN+HdTl2SYSag2mR7QnwKHbtiVX238JlbvuLp7eLYTbMcTp2qH6 XTnXQsfd9Q6KzgBFWBUSs+5wYve6lQnJNqEgVlwtBRvpJUDIfWCObyiMVET49YSUsDHW /FiaDeRyeA3brwBd0yv4ZcvsF1efhwCrmqb8LKyUsvFxhB2gZAO/UP3ytnEoK7EQDB+D 9XFyFUJNu5/XOfbb+FZAX9L7XgcZx++u1bxlm30ITSTuW6x4P0po9TeyHinzuiYOuSHm bpXg== X-Gm-Message-State: AHQUAualYe2kAmR0kbgMrEmfyJnAoPoY1GdHTshUn2Ywcy35xhPR22EP nvG2q4cfX2Fsm5tHPO6+mUsxd9WfSOg= X-Google-Smtp-Source: AHgI3IYIENifEmM8X+GC8yFe7UReEFxRUARJQEtDhGJf/Yaw87wXLiPs0Xo+6A070lTb3TVijdFeTA== X-Received: by 2002:a05:6000:50:: with SMTP id k16mr9485533wrx.153.1551133342006; Mon, 25 Feb 2019 14:22:22 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id d206sm16981422wmc.11.2019.02.25.14.22.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:22:21 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 12/21] media: vicodec: keep the ref frame according to the format in decoder Date: Mon, 25 Feb 2019 14:22:03 -0800 Message-Id: <20190225222210.121713-3-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225222210.121713-1-dafna3@gmail.com> References: <20190225222210.121713-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 In the decoder, save the inner reference frame in the same format as the capture buffer. The decoder writes directly to the capture buffer and then the capture buffer is copied to the reference buffer. This will simplify the stateless decoder. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/codec-fwht.c | 83 +++--- drivers/media/platform/vicodec/codec-fwht.h | 11 +- .../media/platform/vicodec/codec-v4l2-fwht.c | 255 ++---------------- .../media/platform/vicodec/codec-v4l2-fwht.h | 1 + drivers/media/platform/vicodec/vicodec-core.c | 40 +++ 5 files changed, 122 insertions(+), 268 deletions(-) diff --git a/drivers/media/platform/vicodec/codec-fwht.c b/drivers/media/platform/vicodec/codec-fwht.c index d1d6085da9f1..9a0dc739c58c 100644 --- a/drivers/media/platform/vicodec/codec-fwht.c +++ b/drivers/media/platform/vicodec/codec-fwht.c @@ -632,12 +632,13 @@ static int decide_blocktype(const u8 *cur, const u8 *reference, return vari <= vard ? IBLOCK : PBLOCK; } -static void fill_decoder_block(u8 *dst, const s16 *input, int stride) +static void fill_decoder_block(u8 *dst, const s16 *input, int stride, + unsigned int dst_step) { int i, j; for (i = 0; i < 8; i++) { - for (j = 0; j < 8; j++, input++, dst++) { + for (j = 0; j < 8; j++, input++, dst += dst_step) { if (*input < 0) *dst = 0; else if (*input > 255) @@ -645,17 +646,19 @@ static void fill_decoder_block(u8 *dst, const s16 *input, int stride) else *dst = *input; } - dst += stride - 8; + dst += stride - (8 * dst_step); } } -static void add_deltas(s16 *deltas, const u8 *ref, int stride) +static void add_deltas(s16 *deltas, const u8 *ref, int stride, + unsigned int ref_step) { int k, l; for (k = 0; k < 8; k++) { for (l = 0; l < 8; l++) { - *deltas += *ref++; + *deltas += *ref; + ref += ref_step; /* * Due to quantizing, it might possible that the * decoded coefficients are slightly out of range @@ -666,7 +669,7 @@ static void add_deltas(s16 *deltas, const u8 *ref, int stride) *deltas = 255; deltas++; } - ref += stride - 8; + ref += stride - (8 * ref_step); } } @@ -711,8 +714,8 @@ static u32 encode_plane(u8 *input, u8 *refp, __be16 **rlco, __be16 *rlco_max, ifwht(cf->de_coeffs, cf->de_fwht, blocktype); if (blocktype == PBLOCK) - add_deltas(cf->de_fwht, refp, 8); - fill_decoder_block(refp, cf->de_fwht, 8); + add_deltas(cf->de_fwht, refp, 8, 1); + fill_decoder_block(refp, cf->de_fwht, 8, 1); } input += 8 * input_step; @@ -821,8 +824,10 @@ u32 fwht_encode_frame(struct fwht_raw_frame *frm, return encoding; } -static bool decode_plane(struct fwht_cframe *cf, const __be16 **rlco, u8 *ref, - u32 height, u32 width, u32 coded_width, +static bool decode_plane(struct fwht_cframe *cf, const __be16 **rlco, + u32 height, u32 width, const u8 *ref, u32 ref_stride, + unsigned int ref_step, u8 *dst, + unsigned int dst_stride, unsigned int dst_step, bool uncompressed, const __be16 *end_of_rlco_buf) { unsigned int copies = 0; @@ -834,10 +839,15 @@ static bool decode_plane(struct fwht_cframe *cf, const __be16 **rlco, u8 *ref, height = round_up(height, 8); if (uncompressed) { + int i; + if (end_of_rlco_buf + 1 < *rlco + width * height / 2) return false; - memcpy(ref, *rlco, width * height); - *rlco += width * height / 2; + for (i = 0; i < height; i++) { + memcpy(dst, *rlco, width); + dst += dst_stride; + *rlco += width / 2; + } return true; } @@ -849,15 +859,17 @@ static bool decode_plane(struct fwht_cframe *cf, const __be16 **rlco, u8 *ref, */ for (j = 0; j < height / 8; j++) { for (i = 0; i < width / 8; i++) { - u8 *refp = ref + j * 8 * coded_width + i * 8; + const u8 *refp = ref + j * 8 * ref_stride + + i * 8 * ref_step; + u8 *dstp = dst + j * 8 * dst_stride + i * 8 * dst_step; if (copies) { memcpy(cf->de_fwht, copy, sizeof(copy)); if (stat & PFRAME_BIT) add_deltas(cf->de_fwht, refp, - coded_width); - fill_decoder_block(refp, cf->de_fwht, - coded_width); + ref_stride, ref_step); + fill_decoder_block(dstp, cf->de_fwht, + dst_stride, dst_step); copies--; continue; } @@ -877,23 +889,29 @@ static bool decode_plane(struct fwht_cframe *cf, const __be16 **rlco, u8 *ref, if (copies) memcpy(copy, cf->de_fwht, sizeof(copy)); if (stat & PFRAME_BIT) - add_deltas(cf->de_fwht, refp, coded_width); - fill_decoder_block(refp, cf->de_fwht, coded_width); + add_deltas(cf->de_fwht, refp, + ref_stride, ref_step); + fill_decoder_block(dstp, cf->de_fwht, dst_stride, + dst_step); } } return true; } -bool fwht_decode_frame(struct fwht_cframe *cf, struct fwht_raw_frame *ref, - u32 hdr_flags, unsigned int components_num, - unsigned int width, unsigned int height, - unsigned int coded_width) +bool fwht_decode_frame(struct fwht_cframe *cf, u32 hdr_flags, + unsigned int components_num, unsigned int width, + unsigned int height, const struct fwht_raw_frame *ref, + unsigned int ref_stride, unsigned int ref_chroma_stride, + struct fwht_raw_frame *dst, unsigned int dst_stride, + unsigned int dst_chroma_stride) { const __be16 *rlco = cf->rlc_data; const __be16 *end_of_rlco_buf = cf->rlc_data + (cf->size / sizeof(*rlco)) - 1; - if (!decode_plane(cf, &rlco, ref->luma, height, width, coded_width, + if (!decode_plane(cf, &rlco, height, width, ref->luma, ref_stride, + ref->luma_alpha_step, dst->luma, dst_stride, + dst->luma_alpha_step, hdr_flags & FWHT_FL_LUMA_IS_UNCOMPRESSED, end_of_rlco_buf)) return false; @@ -901,27 +919,30 @@ bool fwht_decode_frame(struct fwht_cframe *cf, struct fwht_raw_frame *ref, if (components_num >= 3) { u32 h = height; u32 w = width; - u32 c = coded_width; if (!(hdr_flags & FWHT_FL_CHROMA_FULL_HEIGHT)) h /= 2; - if (!(hdr_flags & FWHT_FL_CHROMA_FULL_WIDTH)) { + if (!(hdr_flags & FWHT_FL_CHROMA_FULL_WIDTH)) w /= 2; - c /= 2; - } - if (!decode_plane(cf, &rlco, ref->cb, h, w, c, + + if (!decode_plane(cf, &rlco, h, w, ref->cb, ref_chroma_stride, + ref->chroma_step, dst->cb, dst_chroma_stride, + dst->chroma_step, hdr_flags & FWHT_FL_CB_IS_UNCOMPRESSED, end_of_rlco_buf)) return false; - if (!decode_plane(cf, &rlco, ref->cr, h, w, c, + if (!decode_plane(cf, &rlco, h, w, ref->cr, ref_chroma_stride, + ref->chroma_step, dst->cr, dst_chroma_stride, + dst->chroma_step, hdr_flags & FWHT_FL_CR_IS_UNCOMPRESSED, end_of_rlco_buf)) return false; } if (components_num == 4) - if (!decode_plane(cf, &rlco, ref->alpha, height, width, - coded_width, + if (!decode_plane(cf, &rlco, height, width, ref->alpha, ref_stride, + ref->luma_alpha_step, dst->alpha, dst_stride, + dst->luma_alpha_step, hdr_flags & FWHT_FL_ALPHA_IS_UNCOMPRESSED, end_of_rlco_buf)) return false; diff --git a/drivers/media/platform/vicodec/codec-fwht.h b/drivers/media/platform/vicodec/codec-fwht.h index 8f0b790839f8..b6fec2b1cbca 100644 --- a/drivers/media/platform/vicodec/codec-fwht.h +++ b/drivers/media/platform/vicodec/codec-fwht.h @@ -141,9 +141,10 @@ u32 fwht_encode_frame(struct fwht_raw_frame *frm, bool is_intra, bool next_is_intra, unsigned int width, unsigned int height, unsigned int stride, unsigned int chroma_stride); -bool fwht_decode_frame(struct fwht_cframe *cf, struct fwht_raw_frame *ref, - u32 hdr_flags, unsigned int components_num, - unsigned int width, unsigned int height, - unsigned int coded_width); - +bool fwht_decode_frame(struct fwht_cframe *cf, u32 hdr_flags, + unsigned int components_num, unsigned int width, + unsigned int height, const struct fwht_raw_frame *ref, + unsigned int ref_stride, unsigned int ref_chroma_stride, + struct fwht_raw_frame *dst, unsigned int dst_stride, + unsigned int dst_chroma_stride); #endif diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.c b/drivers/media/platform/vicodec/codec-v4l2-fwht.c index 515b3115b3c6..f15d76fae45c 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.c +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.c @@ -248,14 +248,17 @@ int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) int v4l2_fwht_decode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) { - unsigned int i, j, k; u32 flags; struct fwht_cframe cf; - u8 *p, *ref_p; unsigned int components_num = 3; unsigned int version; const struct v4l2_fwht_pixfmt_info *info; unsigned int hdr_width_div, hdr_height_div; + struct fwht_raw_frame dst_rf; + unsigned int dst_chroma_stride = state->stride; + unsigned int ref_chroma_stride = state->ref_stride; + unsigned int dst_size = state->stride * state->coded_height; + unsigned int ref_size; if (!state->info) return -EINVAL; @@ -303,241 +306,29 @@ int v4l2_fwht_decode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) hdr_height_div != info->height_div) return -EINVAL; - if (!fwht_decode_frame(&cf, &state->ref_frame, flags, components_num, - state->visible_width, state->visible_height, - state->coded_width)) + if (prepare_raw_frame(&dst_rf, info, p_out, dst_size)) return -EINVAL; + if (info->planes_num == 3) { + dst_chroma_stride /= 2; + ref_chroma_stride /= 2; + } + if (info->id == V4L2_PIX_FMT_NV24 || + info->id == V4L2_PIX_FMT_NV42) { + dst_chroma_stride *= 2; + ref_chroma_stride *= 2; + } - /* - * TODO - handle the case where the compressed stream encodes a - * different format than the requested decoded format. - */ - switch (state->info->id) { - case V4L2_PIX_FMT_GREY: - ref_p = state->ref_frame.luma; - for (i = 0; i < state->coded_height; i++) { - memcpy(p_out, ref_p, state->visible_width); - p_out += state->stride; - ref_p += state->coded_width; - } - break; - case V4L2_PIX_FMT_YUV420: - case V4L2_PIX_FMT_YUV422P: - ref_p = state->ref_frame.luma; - for (i = 0; i < state->coded_height; i++) { - memcpy(p_out, ref_p, state->visible_width); - p_out += state->stride; - ref_p += state->coded_width; - } - - ref_p = state->ref_frame.cb; - for (i = 0; i < state->coded_height / 2; i++) { - memcpy(p_out, ref_p, state->visible_width / 2); - p_out += state->stride / 2; - ref_p += state->coded_width / 2; - } - ref_p = state->ref_frame.cr; - for (i = 0; i < state->coded_height / 2; i++) { - memcpy(p_out, ref_p, state->visible_width / 2); - p_out += state->stride / 2; - ref_p += state->coded_width / 2; - } - break; - case V4L2_PIX_FMT_YVU420: - ref_p = state->ref_frame.luma; - for (i = 0; i < state->coded_height; i++) { - memcpy(p_out, ref_p, state->visible_width); - p_out += state->stride; - ref_p += state->coded_width; - } - ref_p = state->ref_frame.cr; - for (i = 0; i < state->coded_height / 2; i++) { - memcpy(p_out, ref_p, state->visible_width / 2); - p_out += state->stride / 2; - ref_p += state->coded_width / 2; - } - ref_p = state->ref_frame.cb; - for (i = 0; i < state->coded_height / 2; i++) { - memcpy(p_out, ref_p, state->visible_width / 2); - p_out += state->stride / 2; - ref_p += state->coded_width / 2; - } - break; - case V4L2_PIX_FMT_NV12: - case V4L2_PIX_FMT_NV16: - case V4L2_PIX_FMT_NV24: - ref_p = state->ref_frame.luma; - for (i = 0; i < state->coded_height; i++) { - memcpy(p_out, ref_p, state->visible_width); - p_out += state->stride; - ref_p += state->coded_width; - } + ref_size = state->ref_stride * state->coded_height; - k = 0; - for (i = 0; i < state->coded_height / 2; i++) { - for (j = 0, p = p_out; j < state->coded_width / 2; j++) { - *p++ = state->ref_frame.cb[k]; - *p++ = state->ref_frame.cr[k]; - k++; - } - p_out += state->stride; - } - break; - case V4L2_PIX_FMT_NV21: - case V4L2_PIX_FMT_NV61: - case V4L2_PIX_FMT_NV42: - ref_p = state->ref_frame.luma; - for (i = 0; i < state->coded_height; i++) { - memcpy(p_out, ref_p, state->visible_width); - p_out += state->stride; - ref_p += state->coded_width; - } + if (prepare_raw_frame(&state->ref_frame, info, state->ref_frame.buf, + ref_size)) + return -EINVAL; - k = 0; - for (i = 0; i < state->coded_height / 2; i++) { - for (j = 0, p = p_out; j < state->coded_width / 2; j++) { - *p++ = state->ref_frame.cr[k]; - *p++ = state->ref_frame.cb[k]; - k++; - } - p_out += state->stride; - } - break; - case V4L2_PIX_FMT_YUYV: - k = 0; - for (i = 0; i < state->coded_height; i++) { - for (j = 0, p = p_out; j < state->coded_width / 2; j++) { - *p++ = state->ref_frame.luma[k]; - *p++ = state->ref_frame.cb[k / 2]; - *p++ = state->ref_frame.luma[k + 1]; - *p++ = state->ref_frame.cr[k / 2]; - k += 2; - } - p_out += state->stride; - } - break; - case V4L2_PIX_FMT_YVYU: - k = 0; - for (i = 0; i < state->coded_height; i++) { - for (j = 0, p = p_out; j < state->coded_width / 2; j++) { - *p++ = state->ref_frame.luma[k]; - *p++ = state->ref_frame.cr[k / 2]; - *p++ = state->ref_frame.luma[k + 1]; - *p++ = state->ref_frame.cb[k / 2]; - k += 2; - } - p_out += state->stride; - } - break; - case V4L2_PIX_FMT_UYVY: - k = 0; - for (i = 0; i < state->coded_height; i++) { - for (j = 0, p = p_out; j < state->coded_width / 2; j++) { - *p++ = state->ref_frame.cb[k / 2]; - *p++ = state->ref_frame.luma[k]; - *p++ = state->ref_frame.cr[k / 2]; - *p++ = state->ref_frame.luma[k + 1]; - k += 2; - } - p_out += state->stride; - } - break; - case V4L2_PIX_FMT_VYUY: - k = 0; - for (i = 0; i < state->coded_height; i++) { - for (j = 0, p = p_out; j < state->coded_width / 2; j++) { - *p++ = state->ref_frame.cr[k / 2]; - *p++ = state->ref_frame.luma[k]; - *p++ = state->ref_frame.cb[k / 2]; - *p++ = state->ref_frame.luma[k + 1]; - k += 2; - } - p_out += state->stride; - } - break; - case V4L2_PIX_FMT_RGB24: - case V4L2_PIX_FMT_HSV24: - k = 0; - for (i = 0; i < state->coded_height; i++) { - for (j = 0, p = p_out; j < state->coded_width; j++) { - *p++ = state->ref_frame.cr[k]; - *p++ = state->ref_frame.luma[k]; - *p++ = state->ref_frame.cb[k]; - k++; - } - p_out += state->stride; - } - break; - case V4L2_PIX_FMT_BGR24: - k = 0; - for (i = 0; i < state->coded_height; i++) { - for (j = 0, p = p_out; j < state->coded_width; j++) { - *p++ = state->ref_frame.cb[k]; - *p++ = state->ref_frame.luma[k]; - *p++ = state->ref_frame.cr[k]; - k++; - } - p_out += state->stride; - } - break; - case V4L2_PIX_FMT_RGB32: - case V4L2_PIX_FMT_XRGB32: - case V4L2_PIX_FMT_HSV32: - k = 0; - for (i = 0; i < state->coded_height; i++) { - for (j = 0, p = p_out; j < state->coded_width; j++) { - *p++ = 0; - *p++ = state->ref_frame.cr[k]; - *p++ = state->ref_frame.luma[k]; - *p++ = state->ref_frame.cb[k]; - k++; - } - p_out += state->stride; - } - break; - case V4L2_PIX_FMT_BGR32: - case V4L2_PIX_FMT_XBGR32: - k = 0; - for (i = 0; i < state->coded_height; i++) { - for (j = 0, p = p_out; j < state->coded_width; j++) { - *p++ = state->ref_frame.cb[k]; - *p++ = state->ref_frame.luma[k]; - *p++ = state->ref_frame.cr[k]; - *p++ = 0; - k++; - } - p_out += state->stride; - } - break; - case V4L2_PIX_FMT_ARGB32: - k = 0; - for (i = 0; i < state->coded_height; i++) { - for (j = 0, p = p_out; j < state->coded_width; j++) { - *p++ = state->ref_frame.alpha[k]; - *p++ = state->ref_frame.cr[k]; - *p++ = state->ref_frame.luma[k]; - *p++ = state->ref_frame.cb[k]; - k++; - } - p_out += state->stride; - } - break; - case V4L2_PIX_FMT_ABGR32: - k = 0; - for (i = 0; i < state->coded_height; i++) { - for (j = 0, p = p_out; j < state->coded_width; j++) { - *p++ = state->ref_frame.cb[k]; - *p++ = state->ref_frame.luma[k]; - *p++ = state->ref_frame.cr[k]; - *p++ = state->ref_frame.alpha[k]; - k++; - } - p_out += state->stride; - } - break; - default: + if (!fwht_decode_frame(&cf, flags, components_num, + state->visible_width, state->visible_height, + &state->ref_frame, state->ref_stride, ref_chroma_stride, + &dst_rf, state->stride, dst_chroma_stride)) return -EINVAL; - } return 0; } diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.h b/drivers/media/platform/vicodec/codec-v4l2-fwht.h index aa6fa90a48be..53eba97ebc83 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.h +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.h @@ -30,6 +30,7 @@ struct v4l2_fwht_state { unsigned int coded_width; unsigned int coded_height; unsigned int stride; + unsigned int ref_stride; unsigned int gop_size; unsigned int gop_cnt; u16 i_frame_qp; diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 42af0e922249..4b97ba30fec3 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -154,6 +154,43 @@ static struct vicodec_q_data *get_q_data(struct vicodec_ctx *ctx, return NULL; } +static void copy_cap_to_ref(const u8 *cap, const struct v4l2_fwht_pixfmt_info *info, + struct v4l2_fwht_state *state) +{ + int plane_idx; + u8 *p_ref = state->ref_frame.buf; + unsigned int cap_stride = state->stride; + unsigned int ref_stride = state->ref_stride; + + for (plane_idx = 0; plane_idx < info->planes_num; plane_idx++) { + int i; + unsigned int h_div = (plane_idx == 1 || plane_idx == 2) ? + info->height_div : 1; + const u8 *row_cap = cap; + u8 *row_ref = p_ref; + + if (info->planes_num == 3 && plane_idx == 1) { + cap_stride /= 2; + ref_stride /= 2; + } + + if (plane_idx == 1 && + (info->id == V4L2_PIX_FMT_NV24 || + info->id == V4L2_PIX_FMT_NV42)) { + cap_stride *= 2; + ref_stride *= 2; + } + + for (i = 0; i < state->visible_height / h_div; i++) { + memcpy(row_ref, row_cap, ref_stride); + row_ref += ref_stride; + row_cap += cap_stride; + } + cap += cap_stride * (state->coded_height / h_div); + p_ref += ref_stride * (state->coded_height / h_div); + } +} + static int device_process(struct vicodec_ctx *ctx, struct vb2_v4l2_buffer *src_vb, struct vb2_v4l2_buffer *dst_vb) @@ -195,6 +232,8 @@ static int device_process(struct vicodec_ctx *ctx, ret = v4l2_fwht_decode(state, p_src, p_dst); if (ret < 0) return ret; + copy_cap_to_ref(p_dst, ctx->state.info, &ctx->state); + vb2_set_plane_payload(&dst_vb->vb2_buf, 0, q_dst->sizeimage); } return 0; @@ -1352,6 +1391,7 @@ static int vicodec_start_streaming(struct vb2_queue *q, state->stride = q_data->coded_width * info->bytesperline_mult; + 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; ctx->comp_max_size = total_planes_size; From patchwork Mon Feb 25 22:22:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829223 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 3963F139A for ; Mon, 25 Feb 2019 22:22:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BA5B2BFD2 for ; Mon, 25 Feb 2019 22:22:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2029D2BFDE; Mon, 25 Feb 2019 22:22: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 87CF42BFD4 for ; Mon, 25 Feb 2019 22:22:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727616AbfBYWW0 (ORCPT ); Mon, 25 Feb 2019 17:22:26 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:42033 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727554AbfBYWWZ (ORCPT ); Mon, 25 Feb 2019 17:22:25 -0500 Received: by mail-wr1-f68.google.com with SMTP id r5so11699404wrg.9 for ; Mon, 25 Feb 2019 14:22:24 -0800 (PST) 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=GEbCD/ih7J+/ZvXmFpUkDA3R5lsMRrCkygPLKoaIavw=; b=MauBkCUIGR++dPfS171zKSBMnrNGIJwEdzD4s+0Y1fNjkUTMlCzWMBJ2x+3dEZ2sgK +6SJwwrtvXkd9sfRCHgL7mn55V3lPTl5IN4F7x8NI4K4EQZ9rX+r0uUdE9dr2Up1Eg0/ uN0rVYyhL8ozOG3dgWYOozZds1BdQNBkehHKxAG+zX93j0L12251jrWRVljj0wcy+2jn OtsvmgFXWS+hCMxu8Si7JZ9zxrsbR287+uAKlohOb9idaJlz4d5GsEF0UWkNXJVzo27L kJRg1TpD3TwHLxrfmYT7j0Yj0hjtZXTHlUySMwBVi6QUAnTF9dTkpJme3x47SmoDF32j H79Q== 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=GEbCD/ih7J+/ZvXmFpUkDA3R5lsMRrCkygPLKoaIavw=; b=q33s9SNuaaUEDf0nXwMoPKtOCr65bSX6VuDF9YFVTnZWuifG90b6y03IAbxuwjVOiV ciiRvsL3GM+Krq0GLdj03iqcx6V72l2J7epC82l4Uboska5uD4NgPowiPCKrDI7RTgEP M2wiiv254ydkQWNsPEvEPuplz833b01HYN2hcf38LW4g2qqYj/fUgDiC8QCI8DfUORqY dfR4ZT0vOIweQKDR10ExBpjpPSMJBOP7UbQhnSBYoSUJaOGgkNmZY/vik9RfQ81LYZlo aAweMvA5S8id0S2dj9880AfWd9c5AXeg6o2tTo+ltrVX+EJvbrQZuN2j+26IJTXk+mql tn8w== X-Gm-Message-State: AHQUAuYdxvGt3DW3N1pwLCPFgl6ehLy0jiDNblqLKSgYO7Ufm7+BT+qw 5z92MpbWXpXZbzJdSXMAHgUKiH9B4zc= X-Google-Smtp-Source: AHgI3IbyHcKnF1pBPUhURGYr63OEPsEik2/KyExj4gTSpb0QTYhdWbHQ19dCJzSsfJLrEhPP6jcaIg== X-Received: by 2002:a5d:6a8e:: with SMTP id s14mr13856748wru.31.1551133343498; Mon, 25 Feb 2019 14:22:23 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id d206sm16981422wmc.11.2019.02.25.14.22.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:22:22 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 13/21] media: vicodec: Validate version dependent header values in a separate function Date: Mon, 25 Feb 2019 14:22:04 -0800 Message-Id: <20190225222210.121713-4-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225222210.121713-1-dafna3@gmail.com> References: <20190225222210.121713-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 Move the code that validates version dependent header values to a separate function 'validate_by_version' Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 4b97ba30fec3..d051f9901409 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -191,6 +191,23 @@ static void copy_cap_to_ref(const u8 *cap, const struct v4l2_fwht_pixfmt_info *i } } +static bool validate_by_version(unsigned int flags, unsigned int version) +{ + if (!version || version > FWHT_VERSION) + return false; + + if (version >= 2) { + unsigned int components_num = 1 + + ((flags & FWHT_FL_COMPONENTS_NUM_MSK) >> + FWHT_FL_COMPONENTS_NUM_OFFSET); + unsigned int pixenc = flags & FWHT_FL_PIXENC_MSK; + + if (components_num == 0 || components_num > 4 || !pixenc) + return false; + } + return true; +} + static int device_process(struct vicodec_ctx *ctx, struct vb2_v4l2_buffer *src_vb, struct vb2_v4l2_buffer *dst_vb) @@ -397,21 +414,11 @@ static bool is_header_valid(const struct fwht_cframe_hdr *p_hdr) unsigned int version = ntohl(p_hdr->version); unsigned int flags = ntohl(p_hdr->flags); - if (!version || version > FWHT_VERSION) - return false; - if (w < MIN_WIDTH || w > MAX_WIDTH || h < MIN_HEIGHT || h > MAX_HEIGHT) return false; - if (version >= 2) { - unsigned int components_num = 1 + - ((flags & FWHT_FL_COMPONENTS_NUM_MSK) >> - FWHT_FL_COMPONENTS_NUM_OFFSET); - unsigned int pixenc = flags & FWHT_FL_PIXENC_MSK; - - if (components_num == 0 || components_num > 4 || !pixenc) - return false; - } + if (!validate_by_version(flags, version)) + return false; info = info_from_header(p_hdr); if (!info) From patchwork Mon Feb 25 22:22:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829227 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 DA51215AC for ; Mon, 25 Feb 2019 22:22:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC5992BFD6 for ; Mon, 25 Feb 2019 22:22:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA4442BFDA; Mon, 25 Feb 2019 22:22:28 +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 5D1672BFD6 for ; Mon, 25 Feb 2019 22:22:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728029AbfBYWW1 (ORCPT ); Mon, 25 Feb 2019 17:22:27 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44485 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727801AbfBYWW1 (ORCPT ); Mon, 25 Feb 2019 17:22:27 -0500 Received: by mail-wr1-f67.google.com with SMTP id w2so11689328wrt.11 for ; Mon, 25 Feb 2019 14:22:25 -0800 (PST) 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=heYc5STj/DtjwMTB1aRdzi/H1gIEy4dN2wTw1s5CEaI=; b=R3iUdtnVE98bl54jHlqTdiqPZY2yTbRuRONTEpCrHem45FhdcXXMdETqhUQsO9OYAy IZvTOXfsHXFNkFojOkWUyYJkHRvQ3KTrsA9vFRykySkBdWPAaeN2znyckoKlz08xddMj agP0/xM9nVu97DDDEe66FJyzg2dS7b1HYEDsROaL5sQPTH9Es2Tzmc0HSWHFLxlxUAWa ///V1kXcRLJmE1Xn/F42CLluD3mL9w60xqH4/snQ75a1oTrANUsiLSojbI/B4OO4Op5r Zds4O2I8whPVTKURCbT7jh6Sc/zNN/0YGCVffn360otTNU4FeY9NJJ0t6qHKrpSIzKOv xVSQ== 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=heYc5STj/DtjwMTB1aRdzi/H1gIEy4dN2wTw1s5CEaI=; b=HPaCZ+8UNmFseMgjbUC0GKKchJbrsUuRyEDtF57rQYg19HF161g/8imR1ubvrz2qaC 3sPXKePikc/wx6df34lGvm3hppVk8y3KmJNV9vhWsXWxf8YV9pK7508OC8QPBP3VBugn SJpnkWJtXqXd++ux20wSKGsTqLGukadZwjhTdZOnFGjRZTnd9Ubu6lC2uqGJk2bBdx5s BR++VUXcgTwGwOTrhO64aq20wkuar5+GKpaOowDaUNGypuJhC/ltiZyZnoMIZH1nQp0h p7vIGpCBMRaOSTl0Qboh0RAnTf+zLgxB2IZMfY+JDRW47Ck0XjIK4jDlx7lkJlZGPhp7 Pmgw== X-Gm-Message-State: AHQUAuYTD0WuAGMWCEkPA5dwuBaYDUvPPFahzlRhBNTuVgv/LMUSNxbe hpbr2wvZyimVCtSw+V59l1oaGIzFTV4= X-Google-Smtp-Source: AHgI3IYYZ6CF3dmx1CE4KArrm++Il0TwTaL7v2Wewq3zynLDY+27K4PRr7z5fN8w+AaTgppbSZW+mA== X-Received: by 2002:adf:dd12:: with SMTP id a18mr13166617wrm.4.1551133344877; Mon, 25 Feb 2019 14:22:24 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id d206sm16981422wmc.11.2019.02.25.14.22.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:22:24 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 14/21] media: vicodec: rename v4l2_fwht_default_fmt to v4l2_fwht_find_nth_fmt Date: Mon, 25 Feb 2019 14:22:05 -0800 Message-Id: <20190225222210.121713-5-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225222210.121713-1-dafna3@gmail.com> References: <20190225222210.121713-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 Rename 'v4l2_fwht_default_fmt' to 'v4l2_fwht_find_nth_fmt' and add a function 'v4l2_fwht_validate_fmt' to check if a format info matches the parameters. This function will also be used to validate the stateless params when adding support for stateless codecs. Signed-off-by: Dafna Hirschfeld --- .../media/platform/vicodec/codec-v4l2-fwht.c | 22 ++++++++++++++----- .../media/platform/vicodec/codec-v4l2-fwht.h | 5 ++++- drivers/media/platform/vicodec/vicodec-core.c | 4 ++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.c b/drivers/media/platform/vicodec/codec-v4l2-fwht.c index f15d76fae45c..372ed95e1a1f 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.c +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.c @@ -37,7 +37,19 @@ static const struct v4l2_fwht_pixfmt_info v4l2_fwht_pixfmts[] = { { V4L2_PIX_FMT_GREY, 1, 1, 1, 1, 0, 1, 1, 1, 1, FWHT_FL_PIXENC_RGB}, }; -const struct v4l2_fwht_pixfmt_info *v4l2_fwht_default_fmt(u32 width_div, +bool v4l2_fwht_validate_fmt(const struct v4l2_fwht_pixfmt_info *info, + u32 width_div, u32 height_div, u32 components_num, + u32 pixenc) +{ + if (info->width_div == width_div && + info->height_div == height_div && + (!pixenc || info->pixenc == pixenc) && + info->components_num == components_num) + return true; + return false; +} + +const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_nth_fmt(u32 width_div, u32 height_div, u32 components_num, u32 pixenc, @@ -46,10 +58,10 @@ const struct v4l2_fwht_pixfmt_info *v4l2_fwht_default_fmt(u32 width_div, unsigned int i; for (i = 0; i < ARRAY_SIZE(v4l2_fwht_pixfmts); i++) { - if (v4l2_fwht_pixfmts[i].width_div == width_div && - v4l2_fwht_pixfmts[i].height_div == height_div && - (!pixenc || v4l2_fwht_pixfmts[i].pixenc == pixenc) && - v4l2_fwht_pixfmts[i].components_num == components_num) { + bool is_valid = v4l2_fwht_validate_fmt(&v4l2_fwht_pixfmts[i], + width_div, height_div, + components_num, pixenc); + if (is_valid) { if (start_idx == 0) return v4l2_fwht_pixfmts + i; start_idx--; diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.h b/drivers/media/platform/vicodec/codec-v4l2-fwht.h index 53eba97ebc83..b59503d4049a 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.h +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.h @@ -48,7 +48,10 @@ struct v4l2_fwht_state { const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_pixfmt(u32 pixelformat); const struct v4l2_fwht_pixfmt_info *v4l2_fwht_get_pixfmt(u32 idx); -const struct v4l2_fwht_pixfmt_info *v4l2_fwht_default_fmt(u32 width_div, +bool v4l2_fwht_validate_fmt(const struct v4l2_fwht_pixfmt_info *info, + u32 width_div, u32 height_div, u32 components_num, + u32 pixenc); +const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_nth_fmt(u32 width_div, u32 height_div, u32 components_num, u32 pixenc, diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index d051f9901409..15dfdd99be3a 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -402,7 +402,7 @@ info_from_header(const struct fwht_cframe_hdr *p_hdr) FWHT_FL_COMPONENTS_NUM_OFFSET); pixenc = (flags & FWHT_FL_PIXENC_MSK); } - return v4l2_fwht_default_fmt(width_div, height_div, + return v4l2_fwht_find_nth_fmt(width_div, height_div, components_num, pixenc, 0); } @@ -623,7 +623,7 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx, if (!info || ctx->is_enc) info = v4l2_fwht_get_pixfmt(f->index); else - info = v4l2_fwht_default_fmt(info->width_div, + info = v4l2_fwht_find_nth_fmt(info->width_div, info->height_div, info->components_num, info->pixenc, From patchwork Mon Feb 25 22:22:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829231 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 BA34C139A for ; Mon, 25 Feb 2019 22:22:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABC1F2BFCD for ; Mon, 25 Feb 2019 22:22:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA28F2BFD9; Mon, 25 Feb 2019 22:22: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 E356D2BFCD for ; Mon, 25 Feb 2019 22:22:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728385AbfBYWWa (ORCPT ); Mon, 25 Feb 2019 17:22:30 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:39866 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726845AbfBYWW3 (ORCPT ); Mon, 25 Feb 2019 17:22:29 -0500 Received: by mail-wm1-f68.google.com with SMTP id z84so467394wmg.4 for ; Mon, 25 Feb 2019 14:22:27 -0800 (PST) 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=Sf5RC4nU+7DgbikC7U1NfRFqAPc77vKF0D4+Mp2tV5Q=; b=oJ65PRMo8pwpzu1VHshxLSE9TliH/pBgnyX6so+8oA9aElsl3yixgJuEh1FHPgldKB Ss6Eq4qJ0stKs+znvURlqx5KVmI2dAY20DTuAkdvjpJPIIltPwXPO7fyz06TpAiJSTFy fGXt6D3+yaj8/Tj6xxhl9Q0Tos2CLynYixRrHZCqfsAEcMpTFwWFpu+qIlUn/AFNaMjp 4QwhwW4BDjaVKEhYRMGlTF5k2CeXFhZQnDTrOY2h1qnJbk2d6vqqLPmrEA+XOliw25+o GukAbIShqYNPY8MCKmh/RD+6zA6r+cgTE9E0ilQpZnXqf27kWYm/btPgsgDrDzxTpocb ruWQ== 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=Sf5RC4nU+7DgbikC7U1NfRFqAPc77vKF0D4+Mp2tV5Q=; b=GLGfDXrZz0glAnHasXV1xyNxI7jZHu/wV1xVbS4H0OtCBI+zFz2ov3P0DrmJ0kNlpN pruwpN8MgBKaOc+gYeMxkar4Q1K33RxrJQkXTAM+ULkE+/BCSiSGB6Y/nU+w5ev+nbT7 KyJjuQyaHIeH/lMT39SV2BNOZWHwMeMKw3rG9MXCHMqjbcf4i4VuB+egy3pmdneXpCs2 Vf+GORWO1ymehGZb7rgHfl9JzYVi4dP5SnjUeZVJswZIpi/kFGg2w2gLrnXKy+2YvIvp MmEgVbcUyIXMW01+ooNX3AghjL41ZQ5Y7/rzfbExI1jF/QtDzc89BqXAGuWQ7LGvayHa yQ6Q== X-Gm-Message-State: AHQUAuYczhsNgv/HdgatemYd1XFaeypaeXHVwN8leny4+OEHHXjpyGiC jcvP3pzQLqv1KkQrd36b/sFa+5u6EyE= X-Google-Smtp-Source: AHgI3IYkBtytJV83ks+OrISKAXWVl+SL2rLig4kpS+H58OSEGh/BKg+2OJufNjjIzcWjrUII7jmVcQ== X-Received: by 2002:a1c:be09:: with SMTP id o9mr566778wmf.3.1551133346354; Mon, 25 Feb 2019 14:22:26 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id d206sm16981422wmc.11.2019.02.25.14.22.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:22:25 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 15/21] media: vicodec: add struct for encoder/decoder instance Date: Mon, 25 Feb 2019 14:22:06 -0800 Message-Id: <20190225222210.121713-6-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225222210.121713-1-dafna3@gmail.com> References: <20190225222210.121713-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 struct 'vicodec_dev_instance' for the fields in vicodec_dev that have have both decoder and encoder versions. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 194 +++++++++--------- 1 file changed, 92 insertions(+), 102 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 15dfdd99be3a..5998b9e86cda 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -89,21 +89,21 @@ enum { V4L2_M2M_DST = 1, }; +struct vicodec_dev_instance { + struct video_device vfd; + struct mutex mutex; + spinlock_t lock; + struct v4l2_m2m_dev *m2m_dev; +}; + struct vicodec_dev { struct v4l2_device v4l2_dev; - struct video_device enc_vfd; - struct video_device dec_vfd; + struct vicodec_dev_instance stateful_enc; + struct vicodec_dev_instance stateful_dec; #ifdef CONFIG_MEDIA_CONTROLLER struct media_device mdev; #endif - struct mutex enc_mutex; - struct mutex dec_mutex; - spinlock_t enc_lock; - spinlock_t dec_lock; - - struct v4l2_m2m_dev *enc_dev; - struct v4l2_m2m_dev *dec_dev; }; struct vicodec_ctx { @@ -368,9 +368,9 @@ static void device_run(void *priv) spin_unlock(ctx->lock); if (ctx->is_enc) - v4l2_m2m_job_finish(dev->enc_dev, ctx->fh.m2m_ctx); + v4l2_m2m_job_finish(dev->stateful_enc.m2m_dev, ctx->fh.m2m_ctx); else - v4l2_m2m_job_finish(dev->dec_dev, ctx->fh.m2m_ctx); + v4l2_m2m_job_finish(dev->stateful_dec.m2m_dev, ctx->fh.m2m_ctx); } static void job_remove_src_buf(struct vicodec_ctx *ctx, u32 state) @@ -1490,9 +1490,8 @@ 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; - src_vq->lock = ctx->is_enc ? &ctx->dev->enc_mutex : - &ctx->dev->dec_mutex; - + src_vq->lock = ctx->is_enc ? &ctx->dev->stateful_enc.mutex : + &ctx->dev->stateful_dec.mutex; ret = vb2_queue_init(src_vq); if (ret) return ret; @@ -1580,7 +1579,7 @@ static int vicodec_open(struct file *file) goto open_unlock; } - if (vfd == &dev->enc_vfd) + if (vfd == &dev->stateful_enc.vfd) ctx->is_enc = true; v4l2_fh_init(&ctx->fh, video_devdata(file)); @@ -1628,13 +1627,13 @@ 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->enc_dev, ctx, - &queue_init); - ctx->lock = &dev->enc_lock; + ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateful_enc.m2m_dev, + ctx, &queue_init); + ctx->lock = &dev->stateful_enc.lock; } else { - ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->dec_dev, ctx, - &queue_init); - ctx->lock = &dev->dec_lock; + ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateful_dec.m2m_dev, + ctx, &queue_init); + ctx->lock = &dev->stateful_dec.lock; } if (IS_ERR(ctx->fh.m2m_ctx)) { @@ -1693,19 +1692,57 @@ static const struct v4l2_m2m_ops m2m_ops = { .job_ready = job_ready, }; +static int register_instance(struct vicodec_dev *dev, + struct vicodec_dev_instance *dev_instance, + const char *name, bool is_enc) +{ + struct video_device *vfd; + int ret; + + spin_lock_init(&dev_instance->lock); + mutex_init(&dev_instance->mutex); + dev_instance->m2m_dev = v4l2_m2m_init(&m2m_ops); + if (IS_ERR(dev_instance->m2m_dev)) { + v4l2_err(&dev->v4l2_dev, "Failed to init vicodec enc device\n"); + return PTR_ERR(dev_instance->m2m_dev); + } + + dev_instance->vfd = vicodec_videodev; + vfd = &dev_instance->vfd; + vfd->lock = &dev_instance->mutex; + vfd->v4l2_dev = &dev->v4l2_dev; + strscpy(vfd->name, name, sizeof(vfd->name)); + vfd->device_caps = V4L2_CAP_STREAMING | + (multiplanar ? V4L2_CAP_VIDEO_M2M_MPLANE : V4L2_CAP_VIDEO_M2M); + if (is_enc) { + v4l2_disable_ioctl(vfd, VIDIOC_DECODER_CMD); + v4l2_disable_ioctl(vfd, VIDIOC_TRY_DECODER_CMD); + } else { + v4l2_disable_ioctl(vfd, VIDIOC_ENCODER_CMD); + v4l2_disable_ioctl(vfd, VIDIOC_TRY_ENCODER_CMD); + } + video_set_drvdata(vfd, dev); + + ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); + if (ret) { + v4l2_err(&dev->v4l2_dev, "Failed to register video device '%s'\n", name); + v4l2_m2m_release(dev_instance->m2m_dev); + return ret; + } + v4l2_info(&dev->v4l2_dev, "Device '%s' registered as /dev/video%d\n", + name, vfd->num); + return 0; +} + static int vicodec_probe(struct platform_device *pdev) { struct vicodec_dev *dev; - struct video_device *vfd; int ret; dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; - spin_lock_init(&dev->enc_lock); - spin_lock_init(&dev->dec_lock); - ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); if (ret) return ret; @@ -1719,100 +1756,53 @@ static int vicodec_probe(struct platform_device *pdev) dev->v4l2_dev.mdev = &dev->mdev; #endif - mutex_init(&dev->enc_mutex); - mutex_init(&dev->dec_mutex); - platform_set_drvdata(pdev, dev); - dev->enc_dev = v4l2_m2m_init(&m2m_ops); - if (IS_ERR(dev->enc_dev)) { - v4l2_err(&dev->v4l2_dev, "Failed to init vicodec device\n"); - ret = PTR_ERR(dev->enc_dev); + if (register_instance(dev, &dev->stateful_enc, + "stateful-encoder", true)) goto unreg_dev; - } - - dev->dec_dev = v4l2_m2m_init(&m2m_ops); - if (IS_ERR(dev->dec_dev)) { - v4l2_err(&dev->v4l2_dev, "Failed to init vicodec device\n"); - ret = PTR_ERR(dev->dec_dev); - goto err_enc_m2m; - } - dev->enc_vfd = vicodec_videodev; - vfd = &dev->enc_vfd; - vfd->lock = &dev->enc_mutex; - vfd->v4l2_dev = &dev->v4l2_dev; - strscpy(vfd->name, "vicodec-enc", sizeof(vfd->name)); - vfd->device_caps = V4L2_CAP_STREAMING | - (multiplanar ? V4L2_CAP_VIDEO_M2M_MPLANE : V4L2_CAP_VIDEO_M2M); - v4l2_disable_ioctl(vfd, VIDIOC_DECODER_CMD); - v4l2_disable_ioctl(vfd, VIDIOC_TRY_DECODER_CMD); - video_set_drvdata(vfd, dev); - - ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); - if (ret) { - v4l2_err(&dev->v4l2_dev, "Failed to register video device\n"); - goto err_dec_m2m; - } - v4l2_info(&dev->v4l2_dev, - "Device registered as /dev/video%d\n", vfd->num); - - dev->dec_vfd = vicodec_videodev; - vfd = &dev->dec_vfd; - vfd->lock = &dev->dec_mutex; - vfd->v4l2_dev = &dev->v4l2_dev; - vfd->device_caps = V4L2_CAP_STREAMING | - (multiplanar ? V4L2_CAP_VIDEO_M2M_MPLANE : V4L2_CAP_VIDEO_M2M); - strscpy(vfd->name, "vicodec-dec", sizeof(vfd->name)); - v4l2_disable_ioctl(vfd, VIDIOC_ENCODER_CMD); - v4l2_disable_ioctl(vfd, VIDIOC_TRY_ENCODER_CMD); - video_set_drvdata(vfd, dev); - - ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); - if (ret) { - v4l2_err(&dev->v4l2_dev, "Failed to register video device\n"); - goto unreg_enc; - } - v4l2_info(&dev->v4l2_dev, - "Device registered as /dev/video%d\n", vfd->num); + if (register_instance(dev, &dev->stateful_dec, + "stateful-decoder", false)) + goto unreg_sf_enc; #ifdef CONFIG_MEDIA_CONTROLLER - ret = v4l2_m2m_register_media_controller(dev->enc_dev, - &dev->enc_vfd, MEDIA_ENT_F_PROC_VIDEO_ENCODER); + ret = v4l2_m2m_register_media_controller(dev->stateful_enc.m2m_dev, + &dev->stateful_enc.vfd, + MEDIA_ENT_F_PROC_VIDEO_ENCODER); if (ret) { - v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem media controller\n"); + v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem media controller for enc\n"); goto unreg_m2m; } - ret = v4l2_m2m_register_media_controller(dev->dec_dev, - &dev->dec_vfd, MEDIA_ENT_F_PROC_VIDEO_DECODER); + ret = v4l2_m2m_register_media_controller(dev->stateful_dec.m2m_dev, + &dev->stateful_dec.vfd, + MEDIA_ENT_F_PROC_VIDEO_DECODER); if (ret) { - v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem media controller\n"); - goto unreg_m2m_enc_mc; + v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem media controller for dec\n"); + goto unreg_m2m_sf_enc_mc; } ret = media_device_register(&dev->mdev); if (ret) { v4l2_err(&dev->v4l2_dev, "Failed to register mem2mem media device\n"); - goto unreg_m2m_dec_mc; + goto unreg_m2m_sf_dec_mc; } #endif return 0; #ifdef CONFIG_MEDIA_CONTROLLER -unreg_m2m_dec_mc: - v4l2_m2m_unregister_media_controller(dev->dec_dev); -unreg_m2m_enc_mc: - v4l2_m2m_unregister_media_controller(dev->enc_dev); +unreg_m2m_sf_dec_mc: + v4l2_m2m_unregister_media_controller(dev->stateful_dec.m2m_dev); +unreg_m2m_sf_enc_mc: + v4l2_m2m_unregister_media_controller(dev->stateful_enc.m2m_dev); unreg_m2m: - video_unregister_device(&dev->dec_vfd); + video_unregister_device(&dev->stateful_dec.vfd); + v4l2_m2m_release(dev->stateful_dec.m2m_dev); #endif -unreg_enc: - video_unregister_device(&dev->enc_vfd); -err_dec_m2m: - v4l2_m2m_release(dev->dec_dev); -err_enc_m2m: - v4l2_m2m_release(dev->enc_dev); +unreg_sf_enc: + video_unregister_device(&dev->stateful_enc.vfd); + v4l2_m2m_release(dev->stateful_enc.m2m_dev); unreg_dev: v4l2_device_unregister(&dev->v4l2_dev); @@ -1827,15 +1817,15 @@ static int vicodec_remove(struct platform_device *pdev) #ifdef CONFIG_MEDIA_CONTROLLER media_device_unregister(&dev->mdev); - v4l2_m2m_unregister_media_controller(dev->enc_dev); - v4l2_m2m_unregister_media_controller(dev->dec_dev); + v4l2_m2m_unregister_media_controller(dev->stateful_enc.m2m_dev); + v4l2_m2m_unregister_media_controller(dev->stateful_dec.m2m_dev); media_device_cleanup(&dev->mdev); #endif - v4l2_m2m_release(dev->enc_dev); - v4l2_m2m_release(dev->dec_dev); - video_unregister_device(&dev->enc_vfd); - video_unregister_device(&dev->dec_vfd); + v4l2_m2m_release(dev->stateful_enc.m2m_dev); + v4l2_m2m_release(dev->stateful_dec.m2m_dev); + video_unregister_device(&dev->stateful_enc.vfd); + video_unregister_device(&dev->stateful_dec.vfd); v4l2_device_unregister(&dev->v4l2_dev); return 0; From patchwork Mon Feb 25 22:22:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829229 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 071BD139A for ; Mon, 25 Feb 2019 22:22:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E87352BFDB for ; Mon, 25 Feb 2019 22:22:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E39782BFD8; Mon, 25 Feb 2019 22:22: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 799712BFDB for ; Mon, 25 Feb 2019 22:22:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728249AbfBYWW3 (ORCPT ); Mon, 25 Feb 2019 17:22:29 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44495 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727801AbfBYWW3 (ORCPT ); Mon, 25 Feb 2019 17:22:29 -0500 Received: by mail-wr1-f68.google.com with SMTP id w2so11689443wrt.11 for ; Mon, 25 Feb 2019 14:22:28 -0800 (PST) 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=hS2J65e7s6nJaS/wJIm8W7tGBrjvRMsWaonRX9Aa1KY=; b=jveAT8HHi/sGTnH+XM35quYDs0YhK9GbotwpRbsuoCdBJCDILXsW8teL+O1f1NpCiL m2fAzRrHfuaO6Uflrpv/LCBivCbLo2SG1D9DRy6k/olyE01FYLmLpnH1fzeNyxYHVTXq 1YyRbMP++vng/+TPRM7KF5sFmvAR89iuDc4qdYTFmWkgYznPScuhBq4MgiPcQspBW22H 1eyCYY4ZliSTkZIXFDMycYbVKSwsHCkG1zkFO4X6hL9EVuo88yxWSPMhXveLgcucA2+6 563FDVV0hhENN2vFe2lXSy9uNz7nbXE1LfLrwTtGteeKJqHp2EpsxnWfZmYSbNwXisWO vdGA== 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=hS2J65e7s6nJaS/wJIm8W7tGBrjvRMsWaonRX9Aa1KY=; b=r5tYM+imosIwU7E7wF3mdgukasJmrmnAPiwk+IfD1ZmqyauldsbftfU+5SUu9RZbst cGln1YZozwtNLr+D5jaFrwX6daygcsUHAMuxo1JjENZnw99tHS+KhChWU9fqJIuw9YEX 9HraoWvDu89TDe2t2i071tQpADtKdID9h2ecLQ0gpdj6eBIWL8830+FpOUuLXE4y5ZZt QzoCwBJ//cQXEJiJoW0WpXV9Xn32R15cmfpToZ1r/F/sI4H+5xLVEpbwY/ZFnkQUNa5a ygG12DCvIDjl7Ap/GqEbGSCo5hD629kfHlR6yYi2vUV/kpQAcL39zNgB3kaXc5rAf3Ek CArQ== X-Gm-Message-State: AHQUAuZQ6UKSAkoAHDdPnDKMvI8U32tIGXbsZ2RUtTUagKHyXKbelLfJ BkUoBcA0QQzxsqK/1Jy++gR3cIITGA4= X-Google-Smtp-Source: AHgI3IaLbifEnQABkyXBQpfoDPwRH4N5XkjxLYXjRvH2YyJOHgeMfqD+5AIFEpMK3K/eg5nBmkIKdg== X-Received: by 2002:adf:f543:: with SMTP id j3mr13499745wrp.220.1551133347844; Mon, 25 Feb 2019 14:22:27 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id d206sm16981422wmc.11.2019.02.25.14.22.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:22:27 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 16/21] media: vicodec: add documentation to V4L2_CID_FWHT_I/P_FRAME_QP Date: Mon, 25 Feb 2019 14:22:07 -0800 Message-Id: <20190225222210.121713-7-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225222210.121713-1-dafna3@gmail.com> References: <20190225222210.121713-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 documentation to V4L2_CID_FWHT_I/P_FRAME_QP controls in ext-ctrls-codec.rst Signed-off-by: Dafna Hirschfeld --- Documentation/media/uapi/v4l/ext-ctrls-codec.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/media/uapi/v4l/ext-ctrls-codec.rst b/Documentation/media/uapi/v4l/ext-ctrls-codec.rst index 54b3797b67dd..a30ce4fd2ea1 100644 --- a/Documentation/media/uapi/v4l/ext-ctrls-codec.rst +++ b/Documentation/media/uapi/v4l/ext-ctrls-codec.rst @@ -1537,6 +1537,18 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - non-intra-coded frames, in zigzag scanning order. Only relevant for non-4:2:0 YUV formats. + + +.. _v4l2-mpeg-fwht: + +``V4L2_CID_FWHT_I_FRAME_QP (integer)`` + Quantization parameter for an I frame for FWHT. Valid range: from 1 + to 31. + +``V4L2_CID_FWHT_P_FRAME_QP (integer)`` + Quantization parameter for a P frame for FWHT. Valid range: from 1 + to 31. + MFC 5.1 MPEG Controls ===================== From patchwork Mon Feb 25 22:22:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829233 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 D4C131515 for ; Mon, 25 Feb 2019 22:22:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6F1C2BFD8 for ; Mon, 25 Feb 2019 22:22:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C55782BFDA; Mon, 25 Feb 2019 22:22:32 +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 69A2F2BFDD for ; Mon, 25 Feb 2019 22:22:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728434AbfBYWWb (ORCPT ); Mon, 25 Feb 2019 17:22:31 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:38829 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727801AbfBYWWb (ORCPT ); Mon, 25 Feb 2019 17:22:31 -0500 Received: by mail-wm1-f66.google.com with SMTP id v26so475112wmh.3 for ; Mon, 25 Feb 2019 14:22:30 -0800 (PST) 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=4ma+hd6urjZkoOq/+0FVgdXyzPtICpe2mbxq1MjhqI0=; b=n1uNDj+7tlAISKFY6YIKypv5Lh6thT56X4gST6aHrJ9dHlpQu1uQu+mQtZkUzCOuyx 46XsMOlzb31zG84ckSRTgp6prfJJgpD6T9/xJKTooBD3X5MOHHHzZa6Eeali7ImqL3pu l0owb5SsJjIPWm6YAD6UvS7Ie9VvvE9hDj0zl7z2dpqu67sdMoSm6AlzHS1m/lzEfW1U HxTfAljd3rhPy4sFQYGQIzwcwWQKxcmG7EJj2tJfZjrnPKvalRnrShouOwJCRt0p0bJK ln1ni5WeoN2N8yHNrPLhGShhl17nlDAaEhn6qCGPgn0k1SiU/QCh3/XufXdqXF295pc8 N2jQ== 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=4ma+hd6urjZkoOq/+0FVgdXyzPtICpe2mbxq1MjhqI0=; b=cdwae7LcjEBsuCV4PfpSEkYWqR0RekeZISVyoOxUt6RhmPsKIU8w8RjVBziCcQIWtd SPZ/t74nFcpfC/sWDJnzMQ648p3HNV33MLriJ3wcGkOYR6Zi3DdsdRjWhOAf1FFGdK+w giN0RAmuWAOMhChgzW+9pry+9wfZDaQjHdyAexzYJ3pGxbMGHhTwkYZpLZiFSNqVjUcO b4ci0hthWvE5UvJNJ7fQkVQjMzDIpdWWFahmAXOu+ZGP0yFcWwSbPEc42K80ZZgJ5UAT Fq16q27VODVFhzMf3/oU9NIUqA5QLs74algUjsAC+BUiKKEBs8teZQf2E4xf0WPXiQlH uMqg== X-Gm-Message-State: AHQUAubjZxMVQ/HR09CgtTlYQAtFHzYzSjUqtdXAzlw/svWSx49JfIPW xV+6B8b+465HqAFr82qHhZejaNzljN4= X-Google-Smtp-Source: AHgI3IYN5qDfUdA3fDdOH1Kh0UOGJ1i50iz+dTJ+0ePWxJpvDFcVCMZYwRJSNDljfU0dLtW3WryJeg== X-Received: by 2002:a1c:9aca:: with SMTP id c193mr576877wme.2.1551133349147; Mon, 25 Feb 2019 14:22:29 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id d206sm16981422wmc.11.2019.02.25.14.22.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:22:28 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 17/21] media: vicodec: add documentation to V4L2_CID_MPEG_VIDEO_FWHT_PARAMS Date: Mon, 25 Feb 2019 14:22:08 -0800 Message-Id: <20190225222210.121713-8-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225222210.121713-1-dafna3@gmail.com> References: <20190225222210.121713-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 documentation to V4L2_CID_MPEG_VIDEO_FWHT_PARAMS control and it's related 'v4l2_ctrl_fwht_params' struct Signed-off-by: Dafna Hirschfeld --- .../media/uapi/v4l/ext-ctrls-codec.rst | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/Documentation/media/uapi/v4l/ext-ctrls-codec.rst b/Documentation/media/uapi/v4l/ext-ctrls-codec.rst index a30ce4fd2ea1..280f1386d5a9 100644 --- a/Documentation/media/uapi/v4l/ext-ctrls-codec.rst +++ b/Documentation/media/uapi/v4l/ext-ctrls-codec.rst @@ -1541,6 +1541,60 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - .. _v4l2-mpeg-fwht: +``V4L2_CID_MPEG_VIDEO_FWHT_PARAMS (struct)`` + Specifies the fwht parameters (as extracted from the bitstream) for the + associated FWHT data. This includes the necessary parameters for + configuring a stateless hardware decoding pipeline for FWHT. + + .. note:: + + This compound control is not yet part of the public kernel API and + it is expected to change. + +.. c:type:: v4l2_ctrl_fwht_params + +.. cssclass:: longtable + +.. flat-table:: struct v4l2_ctrl_fwht_params + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u64 + - ``backward_ref_ts`` + - Timestamp of the V4L2 capture buffer to use as backward reference, used + with P-coded frames. The timestamp refers to the + ``timestamp`` field in struct :c:type:`v4l2_buffer`. Use the + :c:func:`v4l2_timeval_to_ns()` function to convert the struct + :c:type:`timeval` in struct :c:type:`v4l2_buffer` to a __u64. + * - __u32 + - ``version`` + - The version of the codec + * - __u32 + - ``width`` + - The width of the frame + * - __u32 + - ``height`` + - The height of the frame + * - __u32 + - ``flags`` + - The flags of the frame + * - __u32 + - ``colorspace`` + - The colorspace of the frame, from enum :c:type:`v4l2_colorspace`. + * - __u32 + - ``xfer_func`` + - The transfer function, from enum :c:type:`v4l2_xfer_func`. + * - __u32 + - ``ycbcr_enc`` + - The Y'CbCr encoding, from enum :c:type:`v4l2_ycbcr_encoding`. + * - __u32 + - ``quantization`` + - The quantization range, from enum :c:type:`v4l2_quantization`. + * - __u32 + - ``comp_frame_size`` + - The size of the compressed frame. + ``V4L2_CID_FWHT_I_FRAME_QP (integer)`` Quantization parameter for an I frame for FWHT. Valid range: from 1 to 31. From patchwork Mon Feb 25 22:22:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829235 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 1E2FF1515 for ; Mon, 25 Feb 2019 22:22:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10C872BFC9 for ; Mon, 25 Feb 2019 22:22:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F5D92BFDC; Mon, 25 Feb 2019 22:22:34 +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 B7E9A2BFDD for ; Mon, 25 Feb 2019 22:22:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728483AbfBYWWd (ORCPT ); Mon, 25 Feb 2019 17:22:33 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38832 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726845AbfBYWWc (ORCPT ); Mon, 25 Feb 2019 17:22:32 -0500 Received: by mail-wm1-f68.google.com with SMTP id v26so475145wmh.3 for ; Mon, 25 Feb 2019 14:22:31 -0800 (PST) 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=+8ZihpelRkfn+0gfKMXaEJDJnAScnujS+xKL63fuqQY=; b=IMF+O0iebzP/yfuKyhplwrBvV18GyK3ACFnDeHSIS/mGDmkyUgmOpp4+36sOO2UG5Z 14LIip4PBia/FhQOISzj+j8V6x4/pYAv/oIcNfn3x8LaTl2LuIGYqe5+aL+gs9C9lKIh HNqO1MDdDUWqRCf4ZzxFnpImwS4ccGAirAYm9tX9DDEU3v2Gts5iV/0K6aF8dceEwoHu 7OvULHTy3SypAKC8kITHLri7t50vMuhcz0BIZk5sdmwkvug/Eb9fdSQA0JH83R+8UdXB 47INexw7IxZJFL4Ss7ZZfUuM2u8bQyaZPJBq6MNvbmxhBDnG0b2N+P0pCd6mbcJnOwwG +PSQ== 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=+8ZihpelRkfn+0gfKMXaEJDJnAScnujS+xKL63fuqQY=; b=jvp38grfrSpAqJo+3BxXL9nqCftgfo1w1VRgWf6b15o+GR80Bm24UklGB+VGDQkD8t 8gZuojCjjd8uLp/8qqs0pZ2Ui7VKSVfVrrguGQd6a2ORFTWMAqMBGV5rAPtTG2Zb+/gP b/uYdnMyCnSpSqXpqFRSKi96NAkQ/DZMmjzI3DZYwwj0IkL/2fsSIZ3v0roSt4cQXk+T rI3PjzZiUyIdq/+l0JKHO9KrAJvRNSSR/DkrHsFPDo1hZiINwH5bR+hm3YjId06adtka AI0PJinLw8GS5KhGMa83xB5fkVnP5nM2M4z/GoILcyGdVnaGMUnn/zRpE2KkeTCP/l1i 9kRg== X-Gm-Message-State: AHQUAuYYEVttGIVCOC7PUI6dHxVCF3hm5zs5shTdyni2GEazKuHyUknn SNKuGaIinqCfakaAKeoL6IL7z34QbJE= X-Google-Smtp-Source: AHgI3IbMuxDioXYmPzDMF3pTbTX8jNCiCTDRkKgBLEw2K11ecOyLesOoFKLTByqoiHTc858eBYBpFw== X-Received: by 2002:a1c:47:: with SMTP id 68mr530544wma.89.1551133350441; Mon, 25 Feb 2019 14:22:30 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id d206sm16981422wmc.11.2019.02.25.14.22.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:22:29 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 18/21] media: vicodec: add documentation to V4L2_PIX_FMT_FWHT_STATELESS Date: Mon, 25 Feb 2019 14:22:09 -0800 Message-Id: <20190225222210.121713-9-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225222210.121713-1-dafna3@gmail.com> References: <20190225222210.121713-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 documentation to V4L2_PIX_FMT_FWHT_STATELESS in pixfmt-compressed.rst Signed-off-by: Dafna Hirschfeld --- Documentation/media/uapi/v4l/pixfmt-compressed.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/media/uapi/v4l/pixfmt-compressed.rst b/Documentation/media/uapi/v4l/pixfmt-compressed.rst index 2675bef3eefe..8db54a763d44 100644 --- a/Documentation/media/uapi/v4l/pixfmt-compressed.rst +++ b/Documentation/media/uapi/v4l/pixfmt-compressed.rst @@ -125,3 +125,8 @@ Compressed Formats - Video elementary stream using a codec based on the Fast Walsh Hadamard Transform. This codec is implemented by the vicodec ('Virtual Codec') driver. See the codec-fwht.h header for more details. + * .. _V4L2-PIX-FMT-FWHT-STATELESS: + + - ``V4L2_PIX_FMT_FWHT_STATELESS`` + - 'SFWH' + - Same format as V4L2_PIX_FMT_FWHT but requires stateless codec implementation. From patchwork Mon Feb 25 22:22:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829237 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 DDA5E139A for ; Mon, 25 Feb 2019 22:22:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEB372BFDA for ; Mon, 25 Feb 2019 22:22:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CCB642BFDD; Mon, 25 Feb 2019 22:22:35 +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 240F22BFDC for ; Mon, 25 Feb 2019 22:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728490AbfBYWWe (ORCPT ); Mon, 25 Feb 2019 17:22:34 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36609 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728441AbfBYWWe (ORCPT ); Mon, 25 Feb 2019 17:22:34 -0500 Received: by mail-wr1-f67.google.com with SMTP id o17so11725598wrw.3 for ; Mon, 25 Feb 2019 14:22:32 -0800 (PST) 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=u7nIK9RaLpZeWxvOqwfSMA/esHJD9AYSjfAlKlW+I88=; b=ZyuhJmQzcYXonaGS2uZu9Jhx567rxrlscLkrm5ihXTg8NOuu1AKR//ypX5X/a9iBTz 2sYwfCXd3jHMFV3KngLyeUDfrOfI/RNWlQ3UdNnAhY24WZbXDAVptPZAxqe6+IIPLJBg O75SV1SuL66Vv4GTBS4AT1YWuPjvRSuKC63GSb0qv+TZR1q4GS3PsiXQ9RIPe8piHV+l NwyOZBbKzG4c9xBLwIX1Zcf9k4+RF8PDiJB9qt6b4mvtCCFPmTjaa3qkUnH4NdBFrlp7 8f4j7LHxEkrYz0wNv8LoxVyVzAm3x4h8dGYupEv7KafE9WYCXn9RGC3qoInCzmHwoI9Z zouw== 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=u7nIK9RaLpZeWxvOqwfSMA/esHJD9AYSjfAlKlW+I88=; b=D5ULaxDhe4mni489CYqWtjXuRbtNHvnkaMarfs8vTppnEzpd3QBt+vFI0ArJV30OjJ wUGNOfOasaO2Y6bIAHmEoxcl7RD3GQhA3XvfS+rp6ZwE5oAqpAlrz03wL9F2IH0TgrzF G7rg7DSljzyrdcFxAtnGtC3KYcUHIWkrafokIOpLyxCrGszqxti6AaBWuTrQP9R8SqrN LziLWlavzhRwtcSojnEu4N4WGkm4X7b/Bujh72ShJX4D8jep1WgVpq0Y6J+9T4WThNl8 IM2AVh0wH2nwjbwaArzqQLfP4LC3BoAVOPAmUwHmUs3R6iqq9Vwryl+ZsqbUtRBPHYxO Y2Fg== X-Gm-Message-State: AHQUAuaW92Hd5T5MtNKDXusbs6QKsMdXcCpwq/UGb8Xat1n1tacgqgmP SZvFi0B5W7pP64gfvN9q+pMDuyqKGm0= X-Google-Smtp-Source: AHgI3IZa1+kv26K+iuqF4zLl82CiuyVjZ59a70E9hrjbb/x+xdsUd78/v1/+Ukqqrnc9fgpIU+8+3g== X-Received: by 2002:adf:b687:: with SMTP id j7mr14783972wre.81.1551133351833; Mon, 25 Feb 2019 14:22:31 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id d206sm16981422wmc.11.2019.02.25.14.22.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:22:31 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 19/21] media: vicodec: Introducing stateless fwht defs and structs Date: Mon, 25 Feb 2019 14:22:10 -0800 Message-Id: <20190225222210.121713-10-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225222210.121713-1-dafna3@gmail.com> References: <20190225222210.121713-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 structs and definitions needed to implement stateless decoder for fwht. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 23 ++++++++----- drivers/media/v4l2-core/v4l2-ctrls.c | 10 ++++++ include/media/fwht-ctrls.h | 32 +++++++++++++++++++ include/media/v4l2-ctrls.h | 4 ++- include/uapi/linux/v4l2-controls.h | 3 ++ include/uapi/linux/videodev2.h | 1 + 6 files changed, 64 insertions(+), 9 deletions(-) create mode 100644 include/media/fwht-ctrls.h diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 5998b9e86cda..5d6f0cdc2064 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -64,6 +64,10 @@ static const struct v4l2_fwht_pixfmt_info pixfmt_fwht = { V4L2_PIX_FMT_FWHT, 0, 3, 1, 1, 1, 1, 1, 0, 1 }; +static const struct v4l2_fwht_pixfmt_info pixfmt_stateless_fwht = { + V4L2_PIX_FMT_FWHT_STATELESS, 0, 3, 1, 1, 1, 1, 1, 0, 1 +}; + static void vicodec_dev_release(struct device *dev) { } @@ -1510,10 +1514,6 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, return vb2_queue_init(dst_vq); } -#define VICODEC_CID_CUSTOM_BASE (V4L2_CID_MPEG_BASE | 0xf000) -#define VICODEC_CID_I_FRAME_QP (VICODEC_CID_CUSTOM_BASE + 0) -#define VICODEC_CID_P_FRAME_QP (VICODEC_CID_CUSTOM_BASE + 1) - static int vicodec_s_ctrl(struct v4l2_ctrl *ctrl) { struct vicodec_ctx *ctx = container_of(ctrl->handler, @@ -1523,10 +1523,10 @@ static int vicodec_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_MPEG_VIDEO_GOP_SIZE: ctx->state.gop_size = ctrl->val; return 0; - case VICODEC_CID_I_FRAME_QP: + case V4L2_CID_FWHT_I_FRAME_QP: ctx->state.i_frame_qp = ctrl->val; return 0; - case VICODEC_CID_P_FRAME_QP: + case V4L2_CID_FWHT_P_FRAME_QP: ctx->state.p_frame_qp = ctrl->val; return 0; } @@ -1539,7 +1539,7 @@ static const struct v4l2_ctrl_ops vicodec_ctrl_ops = { static const struct v4l2_ctrl_config vicodec_ctrl_i_frame = { .ops = &vicodec_ctrl_ops, - .id = VICODEC_CID_I_FRAME_QP, + .id = V4L2_CID_FWHT_I_FRAME_QP, .name = "FWHT I-Frame QP Value", .type = V4L2_CTRL_TYPE_INTEGER, .min = 1, @@ -1550,7 +1550,7 @@ static const struct v4l2_ctrl_config vicodec_ctrl_i_frame = { static const struct v4l2_ctrl_config vicodec_ctrl_p_frame = { .ops = &vicodec_ctrl_ops, - .id = VICODEC_CID_P_FRAME_QP, + .id = V4L2_CID_FWHT_I_FRAME_QP, .name = "FWHT P-Frame QP Value", .type = V4L2_CTRL_TYPE_INTEGER, .min = 1, @@ -1559,6 +1559,13 @@ static const struct v4l2_ctrl_config vicodec_ctrl_p_frame = { .step = 1, }; +static const struct v4l2_ctrl_config vicodec_ctrl_stateless_state = { + .id = V4L2_CID_MPEG_VIDEO_FWHT_PARAMS, + .elem_size = sizeof(struct v4l2_ctrl_fwht_params), + .name = "FWHT-Stateless State Params", + .type = V4L2_CTRL_TYPE_FWHT_PARAMS, +}; + /* * File operations */ diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 54d66dbc2a31..d5027775c24a 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -849,6 +849,7 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME: return "Force Key Frame"; case V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS: return "MPEG-2 Slice Parameters"; case V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION: return "MPEG-2 Quantization Matrices"; + case V4L2_CID_MPEG_VIDEO_FWHT_PARAMS: return "FWHT stateless parameters"; /* VPX controls */ case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS: return "VPX Number of Partitions"; @@ -1303,6 +1304,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION: *type = V4L2_CTRL_TYPE_MPEG2_QUANTIZATION; break; + case V4L2_CID_MPEG_VIDEO_FWHT_PARAMS: + *type = V4L2_CTRL_TYPE_FWHT_PARAMS; + break; default: *type = V4L2_CTRL_TYPE_INTEGER; break; @@ -1669,6 +1673,9 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION: return 0; + case V4L2_CTRL_TYPE_FWHT_PARAMS: + return 0; + default: return -EINVAL; } @@ -2249,6 +2256,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION: elem_size = sizeof(struct v4l2_ctrl_mpeg2_quantization); break; + case V4L2_CTRL_TYPE_FWHT_PARAMS: + elem_size = sizeof(struct v4l2_ctrl_fwht_params); + break; default: if (type < V4L2_CTRL_COMPOUND_TYPES) elem_size = sizeof(s32); diff --git a/include/media/fwht-ctrls.h b/include/media/fwht-ctrls.h new file mode 100644 index 000000000000..0aee2782f49c --- /dev/null +++ b/include/media/fwht-ctrls.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * These are the FWHT state controls for use with stateless FWHT + * codec drivers. + * + * It turns out that these structs are not stable yet and will undergo + * more changes. So keep them private until they are stable and ready to + * become part of the official public API. + */ + +#ifndef _FWHT_CTRLS_H_ +#define _FWHT_CTRLS_H_ + +#define V4L2_CTRL_TYPE_FWHT_PARAMS 0x0105 + +#define V4L2_CID_MPEG_VIDEO_FWHT_PARAMS (V4L2_CID_MPEG_BASE + 292) + +struct v4l2_ctrl_fwht_params { + __u64 backward_ref_ts; + __u32 version; + __u32 width; + __u32 height; + __u32 flags; + __u32 colorspace; + __u32 xfer_func; + __u32 ycbcr_enc; + __u32 quantization; + __u32 comp_frame_size; +}; + + +#endif diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index c40dcf79b5b9..4dad20658feb 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -23,10 +23,11 @@ #include /* - * Include the mpeg2 stateless codec compound control definitions. + * Include the mpeg2 and fwht stateless codec compound control definitions. * This will move to the public headers once this API is fully stable. */ #include +#include /* forward references */ struct file; @@ -60,6 +61,7 @@ union v4l2_ctrl_ptr { char *p_char; struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; struct v4l2_ctrl_mpeg2_quantization *p_mpeg2_quantization; + struct v4l2_ctrl_fwht_params *p_fwht_params; void *p; }; diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 06479f2fb3ae..e6c16a79f718 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -404,6 +404,9 @@ enum v4l2_mpeg_video_multi_slice_mode { #define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE (V4L2_CID_MPEG_BASE+228) #define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME (V4L2_CID_MPEG_BASE+229) +#define V4L2_CID_FWHT_I_FRAME_QP (V4L2_CID_MPEG_BASE + 290) +#define V4L2_CID_FWHT_P_FRAME_QP (V4L2_CID_MPEG_BASE + 291) + #define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP (V4L2_CID_MPEG_BASE+300) #define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP (V4L2_CID_MPEG_BASE+301) #define V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP (V4L2_CID_MPEG_BASE+302) diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 97e6a6a968ba..1ac3c22d883a 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -669,6 +669,7 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0') /* VP9 */ #define V4L2_PIX_FMT_HEVC v4l2_fourcc('H', 'E', 'V', 'C') /* HEVC aka H.265 */ #define V4L2_PIX_FMT_FWHT v4l2_fourcc('F', 'W', 'H', 'T') /* Fast Walsh Hadamard Transform (vicodec) */ +#define V4L2_PIX_FMT_FWHT_STATELESS v4l2_fourcc('S', 'F', 'W', 'H') /* Stateless FWHT (vicodec) */ /* Vendor-specific formats */ #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */ From patchwork Mon Feb 25 22:22:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829239 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 E565D1515 for ; Mon, 25 Feb 2019 22:22:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D76DF2BFC6 for ; Mon, 25 Feb 2019 22:22:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5E7F2BFE9; Mon, 25 Feb 2019 22:22:50 +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 5B77E2BFD6 for ; Mon, 25 Feb 2019 22:22:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728514AbfBYWWt (ORCPT ); Mon, 25 Feb 2019 17:22:49 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41714 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726799AbfBYWWt (ORCPT ); Mon, 25 Feb 2019 17:22:49 -0500 Received: by mail-wr1-f66.google.com with SMTP id n2so11705019wrw.8 for ; Mon, 25 Feb 2019 14:22:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=en8ChlNmv1wmkd04/fq3Y7+zdqGQ00qd8lQMY0iOp00=; b=mUZ8V6eNAlmAaGPtBSq4WdLBqxDtx29pqrnaV/Gv80D/DSonW+3+N/JzpWoY7vG5jk lwnnxoh30UWBLCjAmfAbeGaSRrK0HJlOXbFnahV2rtPKtdFIe8mNGewHPbiwoMW943Z4 9ugiS9nYEW/yxAxHyQc9tifta6E/yuwSczNedFrgrffkU6P53HU/XYJkxcCd8DOGdgLL CXw3EVRRctVi5/eXkz0ewlS108FayMqqrFQlHOu+W4IN1bQFzEjS1FROXYz7PDEHs6pL nJM/MjEXmCPeCNtcJla+MqblkYdYrHV0Hnxh4TRyGNUy7KYsysHPTOyMku+qPDaeQ97r 2r8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=en8ChlNmv1wmkd04/fq3Y7+zdqGQ00qd8lQMY0iOp00=; b=a0ZKKHZPc4kKjeBQKbAZAksiVqKgp8GzLrIAjYjCZegaEbNmxwiqd7f/mdoMv03+QK m4boHtJVCVNjr0ajRUzV9IoNu4wCm5Irzx38aMKMXDoWG1pVUOL2smFrmkKNIW4f9g01 WXKOyx7IurzQEcRAiHnAAJfrdigYP+0ibjOIDnV8wTAO0z8ADVjMqUdxNoMHK82Co6Nb PUyVelWpg7oI9HiuG+y0hCx54KmCONBSkFjDo3ggtolEex3Cfj1WrFhC62GZ/rrP/mbk OrmkNY5Bwblr6U8OnLp8a4Ux/b+ApsJeUAurlN5HyHdE9+sW9KVTk+dtfiLSF4bYvrgA VA8w== X-Gm-Message-State: AHQUAuYYglqYXcQFDQnjdzkp6TM81g11xm9Rx+TdWC9eWjsOycYoIbfU SuP7RInRjuTkmLrxhaBPYk7BgKJVTNE= X-Google-Smtp-Source: AHgI3IZU61hgYE1jTCcLGu+ASHMEqM0kOMT7cMRCvdKoPKS38g2vaQg9bjobW0dLbgGFa0zL2MkvoQ== X-Received: by 2002:a5d:4d12:: with SMTP id z18mr14446120wrt.115.1551133367080; Mon, 25 Feb 2019 14:22:47 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id p16sm24061977wro.25.2019.02.25.14.22.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:22:46 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 20/21] media: vicodec: Register another node for stateless decoder Date: Mon, 25 Feb 2019 14:22:38 -0800 Message-Id: <20190225222239.121770-1-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 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 decoder instance field to the dev struct and register another node for the statelsess decoder. The stateless API for the node will be implemented in further patches. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 46 +++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 5d6f0cdc2064..9e67c1fd81a4 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_dec; #ifdef CONFIG_MEDIA_CONTROLLER struct media_device mdev; #endif @@ -114,6 +115,7 @@ struct vicodec_ctx { struct v4l2_fh fh; struct vicodec_dev *dev; bool is_enc; + bool is_stateless; spinlock_t *lock; struct v4l2_ctrl_handler hdl; @@ -373,6 +375,9 @@ static void device_run(void *priv) 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); } @@ -1494,8 +1499,14 @@ 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; - src_vq->lock = ctx->is_enc ? &ctx->dev->stateful_enc.mutex : - &ctx->dev->stateful_dec.mutex; + 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->supports_requests = ctx->is_stateless; + src_vq->requires_requests = ctx->is_stateless; ret = vb2_queue_init(src_vq); if (ret) return ret; @@ -1588,6 +1599,8 @@ static int vicodec_open(struct file *file) if (vfd == &dev->stateful_enc.vfd) ctx->is_enc = true; + else if (vfd == &dev->stateless_dec.vfd) + ctx->is_stateless = true; v4l2_fh_init(&ctx->fh, video_devdata(file)); file->private_data = &ctx->fh; @@ -1598,6 +1611,8 @@ static int vicodec_open(struct file *file) 1, 16, 1, 10); v4l2_ctrl_new_custom(hdl, &vicodec_ctrl_i_frame, NULL); v4l2_ctrl_new_custom(hdl, &vicodec_ctrl_p_frame, NULL); + if (ctx->is_stateless) + v4l2_ctrl_new_custom(hdl, &vicodec_ctrl_stateless_state, NULL); if (hdl->error) { rc = hdl->error; v4l2_ctrl_handler_free(hdl); @@ -1637,6 +1652,10 @@ static int vicodec_open(struct file *file) 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); @@ -1773,6 +1792,10 @@ static int vicodec_probe(struct platform_device *pdev) "stateful-decoder", false)) goto unreg_sf_enc; + if (register_instance(dev, &dev->stateless_dec, + "videdev-stateless-dec", false)) + goto unreg_sf_dec; + #ifdef CONFIG_MEDIA_CONTROLLER ret = v4l2_m2m_register_media_controller(dev->stateful_enc.m2m_dev, &dev->stateful_enc.vfd, @@ -1790,23 +1813,36 @@ static int vicodec_probe(struct platform_device *pdev) goto unreg_m2m_sf_enc_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; + } + ret = media_device_register(&dev->mdev); if (ret) { v4l2_err(&dev->v4l2_dev, "Failed to register mem2mem media device\n"); - goto unreg_m2m_sf_dec_mc; + goto unreg_m2m_sl_dec_mc; } #endif return 0; #ifdef CONFIG_MEDIA_CONTROLLER +unreg_m2m_sl_dec_mc: + v4l2_m2m_unregister_media_controller(dev->stateless_dec.m2m_dev); unreg_m2m_sf_dec_mc: v4l2_m2m_unregister_media_controller(dev->stateful_dec.m2m_dev); unreg_m2m_sf_enc_mc: v4l2_m2m_unregister_media_controller(dev->stateful_enc.m2m_dev); unreg_m2m: + video_unregister_device(&dev->stateless_dec.vfd); + v4l2_m2m_release(dev->stateless_dec.m2m_dev); +#endif +unreg_sf_dec: video_unregister_device(&dev->stateful_dec.vfd); v4l2_m2m_release(dev->stateful_dec.m2m_dev); -#endif unreg_sf_enc: video_unregister_device(&dev->stateful_enc.vfd); v4l2_m2m_release(dev->stateful_enc.m2m_dev); @@ -1826,6 +1862,7 @@ 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_dec.m2m_dev); media_device_cleanup(&dev->mdev); #endif @@ -1833,6 +1870,7 @@ static int vicodec_remove(struct platform_device *pdev) v4l2_m2m_release(dev->stateful_dec.m2m_dev); video_unregister_device(&dev->stateful_enc.vfd); video_unregister_device(&dev->stateful_dec.vfd); + video_unregister_device(&dev->stateless_dec.vfd); v4l2_device_unregister(&dev->v4l2_dev); return 0; From patchwork Mon Feb 25 22:22:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10829241 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 7121C139A for ; Mon, 25 Feb 2019 22:22:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61EE52BF7F for ; Mon, 25 Feb 2019 22:22:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F1712BFEC; Mon, 25 Feb 2019 22:22:54 +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 4D5382BFF4 for ; Mon, 25 Feb 2019 22:22:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727490AbfBYWWw (ORCPT ); Mon, 25 Feb 2019 17:22:52 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:55695 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728441AbfBYWWw (ORCPT ); Mon, 25 Feb 2019 17:22:52 -0500 Received: by mail-wm1-f68.google.com with SMTP id q187so493177wme.5 for ; Mon, 25 Feb 2019 14:22:49 -0800 (PST) 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=0Vmpqqybk0Ly4zuzw4qW4U6M8qZsIaECxOD5uUc5IxY=; b=TZYysUX05119Zce/i+TLNs4AUKYfC18TBDZo0FRBiTigiNLv4qg8HzC1cr1BAglPRZ cPfsuGvOccRTG3ShyssGZYE4jeARXz+VDELG8yGvwXVZ6gMOGOMkAeoidLwbPaZtX5++ viCqA9tn9Umxnigr/fOs6YnS6Ge/XfkWDQTECs263vu6rPhfwOCvisBhDQHeMZU6dbAH QGeCdZWymr+LJ6+PnR/e72HvGtP2EZnKZhB/LTCOqUdHie5cuZvFNFtdp/+NU7OFQWKg d2nuwPyNqKfe+4sbkZW2uusn2QydTvAU8IwJH+2KQfKijui8oFnxdbWjwYtyTDhhg9Ho zU0Q== 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=0Vmpqqybk0Ly4zuzw4qW4U6M8qZsIaECxOD5uUc5IxY=; b=kdHMxLu699KrkNTJMDOJaSv/R2PBTKfZKQT+Uy/SN0UUELfGvirUIVW5t5O2gHhiDP 2r5eBlpFfHfjNp8q6pI171vCfNEapofvUfL+32nS0ms50rf757im+Z8XMgENvJUT5yh8 Coz/wY7G15wOsp7zr5E8YhcII/B9MIwNM8BfSSg4G3A/03NMrRSXYrzeb/hGNeNpBM90 BY/aPeXMzPh8rgXJHtSyAbIgzEajXY4Ywms3s9+3JZRGvFwTYFNuKiO3AbJ0Z7wrEchs BZAY+zhgX/bjaKOD9ZsvfrnEBYljzZEW4+IX0EHSJrZw4jjSU/Q9J9VLXwn8OxEnyXsZ nBSQ== X-Gm-Message-State: AHQUAuagILk1SmgvIHtgdKnX0JrpaFuZCB7HIkNx95rMZee6QuMW7sbz JMTpKnxdGUwO6d2poCXIt7EcOm3vdlo= X-Google-Smtp-Source: AHgI3IaTiJOujXwEtCX4SlPTlRThNXZnFAA9UTyBCDkXkOpd8xHLVb0m0tk0KM5jSnEJ8tE/90HVzQ== X-Received: by 2002:a1c:cb86:: with SMTP id b128mr566494wmg.46.1551133368633; Mon, 25 Feb 2019 14:22:48 -0800 (PST) Received: from ubuntu.home ([77.127.107.32]) by smtp.gmail.com with ESMTPSA id p16sm24061977wro.25.2019.02.25.14.22.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 14:22:48 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v4 21/21] media: vicodec: Add support for stateless decoder. Date: Mon, 25 Feb 2019 14:22:39 -0800 Message-Id: <20190225222239.121770-2-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225222239.121770-1-dafna3@gmail.com> References: <20190225222239.121770-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 Implement a stateless decoder for the new node. Signed-off-by: Dafna Hirschfeld --- .../media/platform/vicodec/codec-v4l2-fwht.h | 1 + drivers/media/platform/vicodec/vicodec-core.c | 285 ++++++++++++++++-- 2 files changed, 262 insertions(+), 24 deletions(-) diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.h b/drivers/media/platform/vicodec/codec-v4l2-fwht.h index b59503d4049a..1a0d2a9f931a 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.h +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.h @@ -44,6 +44,7 @@ struct v4l2_fwht_state { struct fwht_raw_frame ref_frame; struct fwht_cframe_hdr header; u8 *compressed_frame; + u64 ref_frame_ts; }; const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_pixfmt(u32 pixelformat); diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 9e67c1fd81a4..f8d89ed8b9a5 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -214,6 +214,41 @@ static bool validate_by_version(unsigned int flags, unsigned int version) return true; } +static bool validate_stateless_params_flags(const struct v4l2_ctrl_fwht_params *params, + const struct v4l2_fwht_pixfmt_info *cur_info) +{ + unsigned int width_div = + (params->flags & FWHT_FL_CHROMA_FULL_WIDTH) ? 1 : 2; + unsigned int height_div = + (params->flags & FWHT_FL_CHROMA_FULL_HEIGHT) ? 1 : 2; + unsigned int components_num = 3; + unsigned int pixenc = 0; + + if (params->version < 3) + return false; + + components_num = 1 + ((params->flags & FWHT_FL_COMPONENTS_NUM_MSK) >> + FWHT_FL_COMPONENTS_NUM_OFFSET); + pixenc = (params->flags & FWHT_FL_PIXENC_MSK); + if (v4l2_fwht_validate_fmt(cur_info, width_div, height_div, + components_num, pixenc)) + return true; + return false; +} + + +static void update_state_from_header(struct vicodec_ctx *ctx) +{ + const struct fwht_cframe_hdr *p_hdr = &ctx->state.header; + + ctx->state.visible_width = ntohl(p_hdr->width); + ctx->state.visible_height = ntohl(p_hdr->height); + ctx->state.colorspace = ntohl(p_hdr->colorspace); + ctx->state.xfer_func = ntohl(p_hdr->xfer_func); + ctx->state.ycbcr_enc = ntohl(p_hdr->ycbcr_enc); + ctx->state.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) @@ -221,12 +256,44 @@ static int device_process(struct vicodec_ctx *ctx, struct vicodec_dev *dev = ctx->dev; struct v4l2_fwht_state *state = &ctx->state; u8 *p_src, *p_dst; - int ret; + int ret = 0; - if (ctx->is_enc) + if (ctx->is_enc || ctx->is_stateless) p_src = vb2_plane_vaddr(&src_vb->vb2_buf, 0); else p_src = state->compressed_frame; + + if (ctx->is_stateless) { + struct media_request *src_req = src_vb->vb2_buf.req_obj.req; + + ret = v4l2_ctrl_request_setup(src_req, &ctx->hdl); + if (ret) + return ret; + update_state_from_header(ctx); + + /* + * 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); + } + } p_dst = vb2_plane_vaddr(&dst_vb->vb2_buf, 0); if (!p_src || !p_dst) { v4l2_err(&dev->v4l2_dev, @@ -255,11 +322,12 @@ static int device_process(struct vicodec_ctx *ctx, ret = v4l2_fwht_decode(state, p_src, p_dst); if (ret < 0) return ret; - copy_cap_to_ref(p_dst, ctx->state.info, &ctx->state); + if (!ctx->is_stateless) + copy_cap_to_ref(p_dst, ctx->state.info, &ctx->state); vb2_set_plane_payload(&dst_vb->vb2_buf, 0, q_dst->sizeimage); } - return 0; + return ret; } /* @@ -334,9 +402,13 @@ static void device_run(void *priv) struct vb2_v4l2_buffer *src_buf, *dst_buf; struct vicodec_q_data *q_src, *q_dst; 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; + q_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); q_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); @@ -355,7 +427,7 @@ static void device_run(void *priv) dst_buf->flags |= V4L2_BUF_FLAG_LAST; v4l2_event_queue_fh(&ctx->fh, &eos_event); } - if (ctx->is_enc) { + if (ctx->is_enc || ctx->is_stateless) { src_buf->sequence = q_src->sequence++; src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); v4l2_m2m_buf_done(src_buf, state); @@ -367,6 +439,9 @@ 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; @@ -445,6 +520,12 @@ static void update_capture_data_from_header(struct vicodec_ctx *ctx) unsigned int hdr_width_div = (flags & FWHT_FL_CHROMA_FULL_WIDTH) ? 1 : 2; unsigned int hdr_height_div = (flags & FWHT_FL_CHROMA_FULL_HEIGHT) ? 1 : 2; + /* + * This function should not be used by a stateless codec since + * it changes values in q_data that are not request specific + */ + WARN_ON(ctx->is_stateless); + q_dst->info = info; q_dst->visible_width = ntohl(p_hdr->width); q_dst->visible_height = ntohl(p_hdr->height); @@ -497,7 +578,7 @@ static int job_ready(void *priv) if (ctx->source_changed) return 0; - if (ctx->is_enc || ctx->comp_has_frame) + if (ctx->is_stateless || ctx->is_enc || ctx->comp_has_frame) return 1; restart: @@ -1243,6 +1324,14 @@ static int vicodec_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, return 0; } +static int vicodec_buf_out_validate(struct vb2_buffer *vb) +{ + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + + vbuf->field = V4L2_FIELD_NONE; + return 0; +} + static int vicodec_buf_prepare(struct vb2_buffer *vb) { struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); @@ -1306,10 +1395,11 @@ static void vicodec_buf_queue(struct vb2_buffer *vb) } /* - * source change event is relevant only for the decoder + * source change event is relevant only for the stateful decoder * in the compressed stream */ - if (ctx->is_enc || !V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) { + if (ctx->is_stateless || ctx->is_enc || + !V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) { v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); return; } @@ -1357,12 +1447,33 @@ static void vicodec_return_bufs(struct vb2_queue *q, u32 state) vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); if (vbuf == NULL) return; + v4l2_ctrl_request_complete(vbuf->vb2_buf.req_obj.req, + &ctx->hdl); spin_lock(ctx->lock); v4l2_m2m_buf_done(vbuf, state); spin_unlock(ctx->lock); } } +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; + + if (q_data->info->components_num == 4) + return 2 * size + 2 * (size / chroma_div); + else if (q_data->info->components_num == 3) + return size + 2 * (size / chroma_div); + return size; +} + static int vicodec_start_streaming(struct vb2_queue *q, unsigned int count) { @@ -1373,7 +1484,7 @@ static int vicodec_start_streaming(struct vb2_queue *q, unsigned int size = q_data->coded_width * q_data->coded_height; unsigned int chroma_div; unsigned int total_planes_size; - u8 *new_comp_frame; + u8 *new_comp_frame = NULL; if (!info) return -EINVAL; @@ -1393,12 +1504,8 @@ static int vicodec_start_streaming(struct vb2_queue *q, vicodec_return_bufs(q, VB2_BUF_STATE_QUEUED); return -EINVAL; } - if (info->components_num == 4) - total_planes_size = 2 * size + 2 * (size / chroma_div); - else if (info->components_num == 3) - total_planes_size = size + 2 * (size / chroma_div); - else - total_planes_size = size; + total_planes_size = total_frame_size(q_data); + ctx->comp_max_size = total_planes_size; state->visible_width = q_data->visible_width; state->visible_height = q_data->visible_height; @@ -1407,10 +1514,14 @@ static int vicodec_start_streaming(struct vb2_queue *q, state->stride = q_data->coded_width * info->bytesperline_mult; + if (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; - ctx->comp_max_size = total_planes_size; new_comp_frame = kvmalloc(ctx->comp_max_size, GFP_KERNEL); if (!state->ref_frame.luma || !new_comp_frame) { @@ -1458,7 +1569,8 @@ 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)) { - kvfree(ctx->state.ref_frame.buf); + if (!ctx->is_stateless) + kvfree(ctx->state.ref_frame.buf); ctx->state.ref_frame.buf = NULL; ctx->state.ref_frame.luma = NULL; ctx->comp_max_size = 0; @@ -1474,14 +1586,24 @@ static void vicodec_stop_streaming(struct vb2_queue *q) } } +static void vicodec_buf_request_complete(struct vb2_buffer *vb) +{ + struct vicodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); + + v4l2_ctrl_request_complete(vb->req_obj.req, &ctx->hdl); +} + + static const struct vb2_ops vicodec_qops = { - .queue_setup = vicodec_queue_setup, - .buf_prepare = vicodec_buf_prepare, - .buf_queue = vicodec_buf_queue, - .start_streaming = vicodec_start_streaming, - .stop_streaming = vicodec_stop_streaming, - .wait_prepare = vb2_ops_wait_prepare, - .wait_finish = vb2_ops_wait_finish, + .queue_setup = vicodec_queue_setup, + .buf_out_validate = vicodec_buf_out_validate, + .buf_prepare = vicodec_buf_prepare, + .buf_queue = vicodec_buf_queue, + .buf_request_complete = vicodec_buf_request_complete, + .start_streaming = vicodec_start_streaming, + .stop_streaming = vicodec_stop_streaming, + .wait_prepare = vb2_ops_wait_prepare, + .wait_finish = vb2_ops_wait_finish, }; static int queue_init(void *priv, struct vb2_queue *src_vq, @@ -1525,10 +1647,59 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, return vb2_queue_init(dst_vq); } +static int vicodec_try_ctrl(struct v4l2_ctrl *ctrl) +{ + struct vicodec_ctx *ctx = container_of(ctrl->handler, + struct vicodec_ctx, hdl); + const struct v4l2_ctrl_fwht_params *params; + struct vicodec_q_data *q_dst = get_q_data(ctx, + V4L2_BUF_TYPE_VIDEO_CAPTURE); + + 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 || + params->height > q_dst->coded_height || + params->height < MIN_HEIGHT) + return -EINVAL; + if (!validate_by_version(params->flags, params->version)) + return -EINVAL; + if (!validate_stateless_params_flags(params, q_dst->info)) + return -EINVAL; + if (params->comp_frame_size > total_frame_size(q_dst)) + return -EINVAL; + default: + return 0; + } + return 0; +} + +static void update_header_from_stateless_params(struct vicodec_ctx *ctx, + const struct v4l2_ctrl_fwht_params *params) +{ + struct fwht_cframe_hdr *p_hdr = &ctx->state.header; + + p_hdr->magic1 = FWHT_MAGIC1; + p_hdr->magic2 = FWHT_MAGIC2; + p_hdr->version = htonl(params->version); + p_hdr->width = htonl(params->width); + p_hdr->height = htonl(params->height); + p_hdr->flags = htonl(params->flags); + p_hdr->colorspace = htonl(params->colorspace); + p_hdr->xfer_func = htonl(params->xfer_func); + p_hdr->ycbcr_enc = htonl(params->ycbcr_enc); + p_hdr->quantization = htonl(params->quantization); + p_hdr->size = htonl(params->comp_frame_size); +} + static int vicodec_s_ctrl(struct v4l2_ctrl *ctrl) { struct vicodec_ctx *ctx = container_of(ctrl->handler, struct vicodec_ctx, hdl); + const struct v4l2_ctrl_fwht_params *params; switch (ctrl->id) { case V4L2_CID_MPEG_VIDEO_GOP_SIZE: @@ -1540,12 +1711,18 @@ static int vicodec_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_FWHT_P_FRAME_QP: ctx->state.p_frame_qp = ctrl->val; return 0; + case V4L2_CID_MPEG_VIDEO_FWHT_PARAMS: + params = ctrl->p_new.p_fwht_params; + update_header_from_stateless_params(ctx, params); + ctx->state.ref_frame_ts = params->backward_ref_ts; + return 0; } return -EINVAL; } static const struct v4l2_ctrl_ops vicodec_ctrl_ops = { .s_ctrl = vicodec_s_ctrl, + .try_ctrl = vicodec_try_ctrl, }; static const struct v4l2_ctrl_config vicodec_ctrl_i_frame = { @@ -1571,6 +1748,7 @@ static const struct v4l2_ctrl_config vicodec_ctrl_p_frame = { }; static const struct v4l2_ctrl_config vicodec_ctrl_stateless_state = { + .ops = &vicodec_ctrl_ops, .id = V4L2_CID_MPEG_VIDEO_FWHT_PARAMS, .elem_size = sizeof(struct v4l2_ctrl_fwht_params), .name = "FWHT-Stateless State Params", @@ -1695,6 +1873,59 @@ static int vicodec_release(struct file *file) return 0; } +static int vicodec_request_validate(struct media_request *req) +{ + struct media_request_object *obj; + struct v4l2_ctrl_handler *parent_hdl, *hdl; + struct vicodec_ctx *ctx = NULL; + struct v4l2_ctrl *ctrl; + unsigned int count; + + list_for_each_entry(obj, &req->objects, list) { + struct vb2_buffer *vb; + + if (vb2_request_object_is_buffer(obj)) { + vb = container_of(obj, struct vb2_buffer, req_obj); + ctx = vb2_get_drv_priv(vb->vb2_queue); + + break; + } + } + + if (!ctx) { + pr_err("No buffer was provided with the request\n"); + return -ENOENT; + } + + count = vb2_request_buffer_cnt(req); + if (!count) { + v4l2_info(&ctx->dev->v4l2_dev, + "No buffer was provided with the request\n"); + return -ENOENT; + } else if (count > 1) { + v4l2_info(&ctx->dev->v4l2_dev, + "More than one buffer was provided with the request\n"); + return -EINVAL; + } + + parent_hdl = &ctx->hdl; + + hdl = v4l2_ctrl_request_hdl_find(req, parent_hdl); + if (!hdl) { + v4l2_info(&ctx->dev->v4l2_dev, "Missing codec control\n"); + return -ENOENT; + } + ctrl = v4l2_ctrl_request_hdl_ctrl_find(hdl, + vicodec_ctrl_stateless_state.id); + if (!ctrl) { + v4l2_info(&ctx->dev->v4l2_dev, + "Missing required codec control\n"); + return -ENOENT; + } + + return vb2_request_validate(req); +} + static const struct v4l2_file_operations vicodec_fops = { .owner = THIS_MODULE, .open = vicodec_open, @@ -1713,6 +1944,11 @@ static const struct video_device vicodec_videodev = { .release = video_device_release_empty, }; +static const struct media_device_ops vicodec_m2m_media_ops = { + .req_validate = vicodec_request_validate, + .req_queue = v4l2_m2m_request_queue, +}; + static const struct v4l2_m2m_ops m2m_ops = { .device_run = device_run, .job_ready = job_ready, @@ -1779,6 +2015,7 @@ static int vicodec_probe(struct platform_device *pdev) strscpy(dev->mdev.bus_info, "platform:vicodec", sizeof(dev->mdev.bus_info)); media_device_init(&dev->mdev); + dev->mdev.ops = &vicodec_m2m_media_ops; dev->v4l2_dev.mdev = &dev->mdev; #endif