From patchwork Fri Feb 15 13:05: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: 10814933 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 A086F6C2 for ; Fri, 15 Feb 2019 13:06:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FDD12F1F0 for ; Fri, 15 Feb 2019 13:06:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83E542F20F; Fri, 15 Feb 2019 13:06:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2ABD02F1F0 for ; Fri, 15 Feb 2019 13:06:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394893AbfBONGS (ORCPT ); Fri, 15 Feb 2019 08:06:18 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:55915 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394890AbfBONGS (ORCPT ); Fri, 15 Feb 2019 08:06:18 -0500 Received: by mail-wm1-f67.google.com with SMTP id r17so9784806wmh.5 for ; Fri, 15 Feb 2019 05:06:17 -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=uvmy35hFkjzQOS1mgFxZVeKidzlnTbqbeCkhrfz7Mw4=; b=dSBqh6f6Vw0arEvqPzDXXNQJ9YQgCIL65L4/LNzogYwVV1Uyq2u6JJpzZ0abl1+eRo 17Bb8gtwKTjO3zQjvug3byA0jvVd/okQTNKReo2JyrSyWaGg0iSr3OfEpJTg0gmjiBtL rC2q5GzgKbXnz5qMSHiZzoQ975b1Z9BO7Er5kiuAtWzTatOePhWHiHxVzVkqksjQ0VdH 45o8vWt0kmmKhjZzA7AmEJPszI0iNeIRhdJtC+bX9uYXRXRF0DHb2iEpabunmgDc77zu 2RWUiqpcIrY9CKxUhsisP53yIOABb5COhdnBaRNqDkJnWUeIuj254SkZdFVAmuOWaGCr HlaQ== 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=uvmy35hFkjzQOS1mgFxZVeKidzlnTbqbeCkhrfz7Mw4=; b=nXk+rphWf+/mtVRjc1ywzatV8z6+lIjQASzXPKnLK4aUycJ9kYLWz82VDnVq09tfQ6 karlRgc43u0GBSykZ+Y2pZBDHU9GZd3X7iOugFEruIw49Tj+m9kiywcfpE1+yReMNwOJ caTZhzvLrttnQq7TaU6aKRNagx6262rwCb5CXdSk51dMdWRBrH21g+XBumcT5zuC6pvc 41RPy6rk6xeNjfkfAXuyOA9dK89VJugjelOyVQWtXzrO3XJhgKynOEbw7/+Tt/o2jX0j r9NpoGrTO4m1r3UElWwc3Zk7OP29ui65EBLFkdn9oMUYVkzExKuMTihI9eKSR+lcMkFk ibvw== X-Gm-Message-State: AHQUAuac1S3Wm2xe4mw5kt/OwcpoLj3cLVWmc7TFSxaz/+18403vSYmh PPl/uRZnmDSAIWMmXHzlJ0dRiagaP1c= X-Google-Smtp-Source: AHgI3IaTLP0FK/vxbdh5BIRhOK7dYzFnnndQMw+zTanstOjJ/r2uIOqoIZbv69IWS7nAXGm/3++X9w== X-Received: by 2002:a1c:f916:: with SMTP id x22mr6851400wmh.87.1550235976267; Fri, 15 Feb 2019 05:06:16 -0800 (PST) Received: from localhost.localdomain ([37.26.146.189]) by smtp.gmail.com with ESMTPSA id n6sm2091065wrt.23.2019.02.15.05.06.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 05:06:15 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v2 01/10] media: v4l2-ctrl: v4l2_ctrl_request_setup returns with error upon failure Date: Fri, 15 Feb 2019 05:05:01 -0800 Message-Id: <20190215130509.86290-2-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190215130509.86290-1-dafna3@gmail.com> References: <20190215130509.86290-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 7825c8d66498..ff75f84011f8 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -3904,18 +3904,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 @@ -3924,10 +3925,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); @@ -3995,12 +3996,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 Fri Feb 15 13:05: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: 10814935 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 922246C2 for ; Fri, 15 Feb 2019 13:06:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F8092F1F0 for ; Fri, 15 Feb 2019 13:06:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73C4F2F20F; Fri, 15 Feb 2019 13:06:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3C162F1F0 for ; Fri, 15 Feb 2019 13:06:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394895AbfBONGV (ORCPT ); Fri, 15 Feb 2019 08:06:21 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34586 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394890AbfBONGV (ORCPT ); Fri, 15 Feb 2019 08:06:21 -0500 Received: by mail-wr1-f68.google.com with SMTP id f14so10324188wrg.1 for ; Fri, 15 Feb 2019 05:06: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:in-reply-to:references; bh=8HNEFm09fHJw68jRxGOgD6bYNXu9KdFAMQNqM5i/EcM=; b=ZDqig7fSGYmlsIk3x2LBxvPnMLBQfp8jBDgLs3qmb9FzYFHCLtmPjK3H8pSkmQe+Ti gjApdQB2tG44YKSvFfHSAlx1atrRGBzd//Ye92Cdi23mL56yk8CMi+m1l7p/4w1xts6e tWAoVDWbwQjnHM6BwZ10pHVVLvN/Hmv3IERzFpPU6ZsXCdbHOkypBxB/bcxPFC6ta0vp TOr/8rGXyK7yngJ8EOYHXaaBErsgdEblN+LVO5vXelhCD+nz8o994qpAi4ps3xG9TA9g U1DP4zXTWQ7+KUB4Zud0ApgYu0Xd+/MTZXhduIFmdLbveBH2Bqpp5ISrzK9JuC/oYzny dT5w== 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=8HNEFm09fHJw68jRxGOgD6bYNXu9KdFAMQNqM5i/EcM=; b=H9Vxb8UGsdm76/5cuu8EgLFLC3DaQq3jCz98HDaZ35YdBRYKGAybCAVQrbFRtBNawY MpZ/dZAR76C4qCf5MJT0q3JeokE/SAoW/DIWU1P/RMMkrn8mSz2MlPxtHNMCEgAQ+U5Y uA9r6fBuFbhoPO12IIt/j1sS6xFiAwOyrUEA6rsudoioZosC8D3H9Z37pRhgynNCkpWf W6/7+ZFgR8l156/4NVA+9qIeZFxwD7WpgC2M3U+SrZCb1xIL+7cyfk5DLxMjeMc7JdyO XuiJvv4DgL3+wmUwdDgPDwoWaR3tMVZqF//ecEA78dWwWsOowu9jJV13XA5L1teqqn/l vGlg== X-Gm-Message-State: AHQUAub9p7pNxgTzk+M9cZj9zZ9gBOAM09y7eS9ZyEqDzxrASfWZiItL PP1yFVblEUBhwMsHe7uZmPxbtuTjFTA= X-Google-Smtp-Source: AHgI3IZN2AnykDcJliPqEJr4PtfZ59WLEzAfiUqq21RY/QPgeACONmxl+IRApqkZZe+9LyJrMW8jkw== X-Received: by 2002:adf:e342:: with SMTP id n2mr6625293wrj.60.1550235978324; Fri, 15 Feb 2019 05:06:18 -0800 (PST) Received: from localhost.localdomain ([37.26.146.189]) by smtp.gmail.com with ESMTPSA id n6sm2091065wrt.23.2019.02.15.05.06.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 05:06:17 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v2 02/10] media: vicodec: Move raw frame preparation code to a function Date: Fri, 15 Feb 2019 05:05:02 -0800 Message-Id: <20190215130509.86290-3-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190215130509.86290-1-dafna3@gmail.com> References: <20190215130509.86290-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 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 | 140 ++++++++++-------- 1 file changed, 75 insertions(+), 65 deletions(-) diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.c b/drivers/media/platform/vicodec/codec-v4l2-fwht.c index c15034849133..728ed5012aed 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.c +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.c @@ -75,117 +75,127 @@ 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->id == V4L2_PIX_FMT_YUV420 || + info->id == V4L2_PIX_FMT_YVU420 || + info->id == V4L2_PIX_FMT_YUV422P) + chroma_stride /= 2; cf.i_frame_qp = state->i_frame_qp; cf.p_frame_qp = state->p_frame_qp; From patchwork Fri Feb 15 13:05: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: 10814937 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 C3DA5922 for ; Fri, 15 Feb 2019 13:06:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1C1D2F1F6 for ; Fri, 15 Feb 2019 13:06:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A62062F20F; Fri, 15 Feb 2019 13:06: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 536DF2F231 for ; Fri, 15 Feb 2019 13:06:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394897AbfBONGW (ORCPT ); Fri, 15 Feb 2019 08:06:22 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45073 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394896AbfBONGW (ORCPT ); Fri, 15 Feb 2019 08:06:22 -0500 Received: by mail-wr1-f67.google.com with SMTP id w17so10237533wrn.12 for ; Fri, 15 Feb 2019 05:06: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=7bC/P9l8kovwO03XgdMHc6Ed9Tt0+DuapeIPpqcOpJU=; b=ovff6fDMdf2MZ1SXypWQKxXpZPjbGHoRhXJPOIIX7jkXWTXS1qAWlYDhIZ+N4skrZ3 3DwPNSRZTy5sMrtscSuqTCXV6SC9Z1PrPr/V3EHhEhax2pYtOTPHTocJLvoUXaUkBqO1 ig8hoj6AI5TP+09VX1tBAb5brTMxKti15tfM/1i3zl0Ljk9uP1hL6goQ2/wV5yz/rKdD jqLeQjEHwKTjRopqcmHtYs3dszL8I47trcYbbPj+6kJ9lVYLueMomiegzCo5Y1vnG43/ y2HSbonnOghJKiiZ3v5mfx/rT5/9HyG+Jz0Gyw1otgBk0vn8T0kukMy8pEuA4NDMydp0 ZMuA== 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=7bC/P9l8kovwO03XgdMHc6Ed9Tt0+DuapeIPpqcOpJU=; b=rOB697T3bXgHsUKKwRTcPyygX9vynmyF4dqQ83zBz8++UQb2c69j+HJQIz7rtbECeh jbunbNN9UMkFLhc/fwJIs0gCIuhSwpcsFlszIcvvFH3as6GFjtp+lU4F4cpMNSNtAuyd dmnZNeNpXMLPuVg5SMyyOpHXa+rTiLAVFShv2PG8bnQDBOsctgtHatZ3Wdb6XShFDOvf 0XRlS/z3hV6SBK/nQEirKHoz2sqLPt2bN613ZOhm0rYBEW8XKY48RFN5zpJOpLC2mJgi TR4855mZYmuDzDiCZpCMh+7ZhN6JOIuH5DcSbAca4u1NPhVrDFnTNkLkfsVs4hbxEmnK xfPQ== X-Gm-Message-State: AHQUAuZJ9hI4izMPpnlxKiOcwi6z8Fln1DKP8glD4CSiewnqoTNyoEpF 1g3XbZw1YddcXBajZujsjL30yXk6AuQ= X-Google-Smtp-Source: AHgI3IbPuSLjSJrL0pwyt0N6t+YPPLXvfr5QJ6aUd9MWZNHv26z7M7oDllDHwyrXGEV1rbJqddYQUQ== X-Received: by 2002:adf:dc10:: with SMTP id t16mr7068704wri.40.1550235980329; Fri, 15 Feb 2019 05:06:20 -0800 (PST) Received: from localhost.localdomain ([37.26.146.189]) by smtp.gmail.com with ESMTPSA id n6sm2091065wrt.23.2019.02.15.05.06.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 05:06:19 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v2 03/10] media: vicodec: add field 'buf' to fwht_raw_frame Date: Fri, 15 Feb 2019 05:05:03 -0800 Message-Id: <20190215130509.86290-4-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190215130509.86290-1-dafna3@gmail.com> References: <20190215130509.86290-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 60d71d9dacb3..8a4f07d466cb 100644 --- a/drivers/media/platform/vicodec/codec-fwht.h +++ b/drivers/media/platform/vicodec/codec-fwht.h @@ -123,6 +123,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 9d739ea5542d..8d38bc1ef079 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -1364,7 +1364,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); @@ -1413,7 +1414,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 Fri Feb 15 13:05: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: 10814939 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 04C25922 for ; Fri, 15 Feb 2019 13:06:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3A692F1F6 for ; Fri, 15 Feb 2019 13:06:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D50802F1F0; Fri, 15 Feb 2019 13:06: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 ABE2B2F1F0 for ; Fri, 15 Feb 2019 13:06:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394901AbfBONG1 (ORCPT ); Fri, 15 Feb 2019 08:06:27 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34592 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394896AbfBONG0 (ORCPT ); Fri, 15 Feb 2019 08:06:26 -0500 Received: by mail-wr1-f66.google.com with SMTP id f14so10324441wrg.1 for ; Fri, 15 Feb 2019 05:06: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=t9DtCa/jneni1GFxM+LgEl0O9EaStX34/7bNPmtLriY=; b=atRvggRltKyhegW/uOC5a/J9ZRvKRI4JZEYtMb4uS0eDinuoI/hcHDqeeX20dYFIwB 6GlStrtEPlpkkw4fDjTLXLV9wL0gi8JxlzAreOd+mIHMGgmVlttybLcZyhjFRM6k2nXv ydrpBhkXMTDcG1CjlLtLaNCA58KV5H3i0Wh7tu5tll4+u/d2Bb1piZSSfd0TT/vFyP+7 q3wfUJ2NGrjVJTR+P9N97C2b/ohg5Cv2cvugBdbe3n8jlL7di/KA4fNPtsNENl64PIs3 XJSadztH67lT29+YWj43qC/5kYZgjFkWNJ4gf2yEassPLo2M73Wv2+bdwZ5Yt85AVh4+ KfUA== 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=t9DtCa/jneni1GFxM+LgEl0O9EaStX34/7bNPmtLriY=; b=XohP1cnqyZ7NSsfyY2roZNkCPv46SKJmTFfl2UpsbZuHVrY5W6rhJArhZPnWXHWuf4 kcdbdndjy8NTpcbrTjwGmO9TW0mfLtr9M+QhCS94/9l19nop5GvOELHoD9S93SUBE3jo JHm3z55PSBgon7cQ0JXeyigkFpkySc6/1JwbXbo9TokNlk6UNpCo3cTcXbipX3r1ja2s wn4Y1QJYaIQOrZ+H4oO62MIPtqsCdxMsTwn0co8N6KV/aa9N0nsSK8fF4k5tTRQiV+mV aCBSDGqHjFexw6CFzNLYCMXvmk/UOBK9J2cSfwfK+04VasLIQKZQWLKbv97KLHq85BIe 5H3A== X-Gm-Message-State: AHQUAub/+T1Fy0afyX0KfgatmeUOfBoo4rx1BwXCjGZ3LJGF2A4O755n NBnvDbkDATxT2wcXBtT7en0Dj+oM8rY= X-Google-Smtp-Source: AHgI3IYTZxATfSaV6hqq0U1CkO/EsX397oD8lCrpSUcBU1HKk1EGT4O7Zyt/qz1wxKmAxdS59PYxtQ== X-Received: by 2002:adf:9d85:: with SMTP id p5mr6759266wre.215.1550235982722; Fri, 15 Feb 2019 05:06:22 -0800 (PST) Received: from localhost.localdomain ([37.26.146.189]) by smtp.gmail.com with ESMTPSA id n6sm2091065wrt.23.2019.02.15.05.06.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 05:06:22 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v2 04/10] media: vicodec: keep the ref frame according to the format in decoder Date: Fri, 15 Feb 2019 05:05:04 -0800 Message-Id: <20190215130509.86290-5-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190215130509.86290-1-dafna3@gmail.com> References: <20190215130509.86290-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 | 68 +++-- drivers/media/platform/vicodec/codec-fwht.h | 10 +- .../media/platform/vicodec/codec-v4l2-fwht.c | 280 +++--------------- .../media/platform/vicodec/codec-v4l2-fwht.h | 3 + drivers/media/platform/vicodec/vicodec-core.c | 2 + 5 files changed, 103 insertions(+), 260 deletions(-) diff --git a/drivers/media/platform/vicodec/codec-fwht.c b/drivers/media/platform/vicodec/codec-fwht.c index d1d6085da9f1..42849476069b 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, + const u8 *ref, u32 height, u32 width, u32 coded_width, + u8 *dst, unsigned int dst_stride, + unsigned int dst_step, unsigned int ref_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,18 @@ 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_step * coded_width + + 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); + coded_width * ref_step, + ref_step); + fill_decoder_block(dstp, cf->de_fwht, + dst_stride, dst_step); copies--; continue; } @@ -877,23 +890,28 @@ 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, + coded_width * ref_step, 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, +bool fwht_decode_frame(struct fwht_cframe *cf, const struct fwht_raw_frame *ref, u32 hdr_flags, unsigned int components_num, unsigned int width, unsigned int height, - unsigned int coded_width) + unsigned int coded_width, 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, + dst->luma, dst_stride, dst->luma_alpha_step, + ref->luma_alpha_step, hdr_flags & FWHT_FL_LUMA_IS_UNCOMPRESSED, end_of_rlco_buf)) return false; @@ -909,11 +927,15 @@ bool fwht_decode_frame(struct fwht_cframe *cf, struct fwht_raw_frame *ref, w /= 2; c /= 2; } - if (!decode_plane(cf, &rlco, ref->cb, h, w, c, + if (!decode_plane(cf, &rlco, ref->cb, h, w, c, dst->cb, + dst_chroma_stride, dst->chroma_step, + ref->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, ref->cr, h, w, c, dst->cr, + dst_chroma_stride, dst->chroma_step, + ref->chroma_step, hdr_flags & FWHT_FL_CR_IS_UNCOMPRESSED, end_of_rlco_buf)) return false; @@ -922,6 +944,8 @@ bool fwht_decode_frame(struct fwht_cframe *cf, struct fwht_raw_frame *ref, if (components_num == 4) if (!decode_plane(cf, &rlco, ref->alpha, height, width, coded_width, + dst->alpha, dst_stride, dst->luma_alpha_step, + ref->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 8a4f07d466cb..eab4a97aa132 100644 --- a/drivers/media/platform/vicodec/codec-fwht.h +++ b/drivers/media/platform/vicodec/codec-fwht.h @@ -140,9 +140,9 @@ 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, const struct fwht_raw_frame *ref, + u32 hdr_flags, unsigned int components_num, + unsigned int width, unsigned int height, + unsigned int coded_width, 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 728ed5012aed..40b1f4901fd3 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.c +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.c @@ -75,6 +75,35 @@ const struct v4l2_fwht_pixfmt_info *v4l2_fwht_get_pixfmt(u32 idx) return v4l2_fwht_pixfmts + idx; } +void copy_cap_to_ref(u8 *cap, const struct v4l2_fwht_pixfmt_info *info, + struct v4l2_fwht_state *state) +{ + int plane_idx; + u8 *p_ref = state->ref_frame.buf; + + for (plane_idx = 0; plane_idx < info->planes_num; plane_idx++) { + int i; + bool is_chroma_plane = plane_idx == 1 || plane_idx == 2; + unsigned int h_div = is_chroma_plane ? info->height_div : 1; + unsigned int w_div = is_chroma_plane ? info->width_div : 1; + unsigned int step = is_chroma_plane ? info->chroma_step : + info->luma_alpha_step; + unsigned int stride_div = + (info->planes_num == 3 && plane_idx > 0) ? 2 : 1; + + u8 *row_dst = cap; + u8 *row_ref = p_ref; + + for (i = 0; i < state->visible_height / h_div; i++) { + memcpy(row_ref, row_dst, step * state->visible_width / w_div); + row_ref += step * state->coded_width / w_div; + row_dst += state->stride / stride_div; + } + cap += (state->stride / stride_div) * (state->coded_height / h_div); + p_ref += (step * state->coded_width / w_div) * (state->coded_height / h_div); + } +} + static int prepare_raw_frame(struct fwht_raw_frame *rf, const struct v4l2_fwht_pixfmt_info *info, u8 *buf, unsigned int size) @@ -243,14 +272,16 @@ 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 dst_size = state->stride * state->coded_height; + unsigned int ref_size; if (!state->info) return -EINVAL; @@ -298,241 +329,24 @@ 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->id == V4L2_PIX_FMT_YUV420 || + info->id == V4L2_PIX_FMT_YVU420 || + info->id == V4L2_PIX_FMT_YUV422P) + dst_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->coded_width * state->coded_height * + info->luma_alpha_step; - 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, &state->ref_frame, flags, components_num, + state->visible_width, state->visible_height, + state->coded_width, &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..75343cdf45e2 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.h +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.h @@ -53,6 +53,9 @@ const struct v4l2_fwht_pixfmt_info *v4l2_fwht_default_fmt(u32 width_div, u32 pixenc, unsigned int start_idx); +void copy_cap_to_ref(u8 *cap, const struct v4l2_fwht_pixfmt_info *info, + struct v4l2_fwht_state *state); + 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); diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 8d38bc1ef079..335a931fdf02 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -194,6 +194,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); } From patchwork Fri Feb 15 13:05: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: 10814941 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 1E18D6C2 for ; Fri, 15 Feb 2019 13:06:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C7DF2F1F0 for ; Fri, 15 Feb 2019 13:06:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0072D2F20F; Fri, 15 Feb 2019 13:06:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40A042F1F0 for ; Fri, 15 Feb 2019 13:06:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728142AbfBONG2 (ORCPT ); Fri, 15 Feb 2019 08:06:28 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:55102 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394900AbfBONG1 (ORCPT ); Fri, 15 Feb 2019 08:06:27 -0500 Received: by mail-wm1-f67.google.com with SMTP id a62so9879060wmh.4 for ; Fri, 15 Feb 2019 05:06: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=7t7Gm5iEJ922h4wEXLYNVp+muCoZ6OGsj/7z7XYJMC0=; b=CnlLtQXs5VLeNGo0gQ8oSMGx+TSC7dAKvQbDbi3y9FblZzrLnM9lVt9e5Z2J+dUMMp ZPTH0nMV4Eu8xNIlxt5aKXeVj3RaZ/hNQ7aP/a9e3+Hn4Mp2UYhplZygwb1KmBnkBkxd pYYw4yqXylaPGNmuvmJBRj1wXFJ6CdyvsRJdqZnEyyyC62bCKoLmXn18ontlG9yl7lhl bD5VxiihflTrbBIpY933Py1to0i4XnAjijfUsKKPyM2k8qJ6nStgCG4Q/OLTAxZ7iKtg KVM11VbAzd1k8xChoa/5HAd+bf+/hV4GA62hak1auEguFR6sl5MhNkknxy4u3wnrwOV8 YDkw== 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=7t7Gm5iEJ922h4wEXLYNVp+muCoZ6OGsj/7z7XYJMC0=; b=UE345sIwEoLxB8hmGZ1lv5GaxTDPISFBhzAB+SBG4KmGBCdN1AbQ33H70g7a8/INTk giPgq773NCYwOjvUoj+/ZWqZoMks9ZnqwAs+fMXXTPIb+klMNo4t9OgT+dQaZaHe7k9w pZw+KqLBXwRsKrQHfvocUasGXxZYrOcHLVv1OMihLKSpvnYMSR1d+aB/4EqsOz7Se3j0 NcU+jJ7SzAQbeyzLCbtCFUrctclTw2juzUi4P+on6knrZs1dPW9OdD9gRMih5ZN+Ahx4 v7r31qflOt5glh0qET4+W3XYJrX0i9Ke0h6s5xQYRoa26yjlC3FAB5FbjQvLMmGJRCfo y/8A== X-Gm-Message-State: AHQUAubTTosSHfB1BFVRPRvPnvaN24w+NzsS+m2G7DnM5SiMsFIuMkU9 mptbNxZ1ZndygwIT86b96dSBxjLV7sg= X-Google-Smtp-Source: AHgI3IaXZP8xbeDlDoplkYWGBZT4RnM9BsecsdtqHdu+1Pfm58uvma8pCfUsvfHXc4Z0762s+nBPeQ== X-Received: by 2002:a1c:a8d7:: with SMTP id r206mr6686953wme.115.1550235984844; Fri, 15 Feb 2019 05:06:24 -0800 (PST) Received: from localhost.localdomain ([37.26.146.189]) by smtp.gmail.com with ESMTPSA id n6sm2091065wrt.23.2019.02.15.05.06.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 05:06:24 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v2 05/10] media: vicodec: add struct for encoder/decoder instance Date: Fri, 15 Feb 2019 05:05:05 -0800 Message-Id: <20190215130509.86290-6-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190215130509.86290-1-dafna3@gmail.com> References: <20190215130509.86290-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 335a931fdf02..5e5bbc99a8bb 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 { @@ -312,9 +312,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) @@ -1457,9 +1457,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; @@ -1547,7 +1546,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)); @@ -1595,13 +1594,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)) { @@ -1659,19 +1658,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; @@ -1685,100 +1722,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); @@ -1793,15 +1783,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 Fri Feb 15 13:05: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: 10814943 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 9FB326C2 for ; Fri, 15 Feb 2019 13:06:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DA672F1F0 for ; Fri, 15 Feb 2019 13:06:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81BBC2F20F; Fri, 15 Feb 2019 13:06: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 164492F1F0 for ; Fri, 15 Feb 2019 13:06:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728490AbfBONGa (ORCPT ); Fri, 15 Feb 2019 08:06:30 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:34909 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728041AbfBONGa (ORCPT ); Fri, 15 Feb 2019 08:06:30 -0500 Received: by mail-wm1-f65.google.com with SMTP id t200so9578231wmt.0 for ; Fri, 15 Feb 2019 05:06: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=KeknfBqFeBZyNAP9gPLysjYNHEjiYF8WepJ/U7CN7mU=; b=OyRink0rrrU+101Tq1oc5QMuoEL4M/zN2mjqfK/RwGuTQuz97nL1JbVSnBT+NbEXkC Bqn3qwscE8x+wrYWsWNppGHRReefWSpYCECVE20a4wMmi6l3nig3HlcjLPrtvPcpyaac QNJg4LqV/j4wYEeO7LD0ouyChe9F0JfmEAqIVMQLdv09K0xvKEOn+z9BwLXs8tFY8XAw G5w3a8Ho0yA4trUx5vzoW585/9von3tNP+ObVPnAnE3KJH+VJc0lhLWo5+jrMSjlp3Mv JlfMyo4J9CiRM4FPcTjQc1Og/Wri/GS/QONDUgWAQtvEqnqZckTEBRGAgZYTkllefGah easg== 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=KeknfBqFeBZyNAP9gPLysjYNHEjiYF8WepJ/U7CN7mU=; b=Kzku1Is4+5vuLHbVF8XY+V/Jri9rtp3AnaiPitzlh/AQQMzJ0hY0Lq3PV+E98m4n/K Z5gUwx+ITth5Xp24NsAqjd/3wWOvNS/c5Uv2yeCg86YQTBA5Y/TKu+gT5js0ZpyspI43 dMcceCTarCWIRB97Cz5qascefPsM6N0FoQeEQeY9zVOIQD/URJvDxt/lCUcLDiIm6Xms 9EtNQCmskXtHAth6GfnDuyDM1BMDv/wGwxCiKnYnvhl+9SZAeffXSHJNQVSZtUZimE/y 5R38SC/FgVMiTAzXC/DSRVAH+D/9PnyWodLRyzGq8+8vV2EW3iOLfXO8SPMSQ7OcIVpT 9Upg== X-Gm-Message-State: AHQUAuZoZbziiYTtc0Moro2kkjFlbkhHMsmseCGMIxtBm5Yi4t8/yxc6 5lSdlWs9ZdbKnTQLfvyutgnBtmP1sxQ= X-Google-Smtp-Source: AHgI3Ibx4Vy3IrvnvxOnSHisqebOv5GjtLlS4LSiYyz04GhtpJA8OV8AEnDHyXaJi6Bs3BP0G20drA== X-Received: by 2002:a7b:cf3a:: with SMTP id m26mr4513919wmg.144.1550235986995; Fri, 15 Feb 2019 05:06:26 -0800 (PST) Received: from localhost.localdomain ([37.26.146.189]) by smtp.gmail.com with ESMTPSA id n6sm2091065wrt.23.2019.02.15.05.06.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 05:06:26 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v2 06/10] media: vicodec: Introducing stateless fwht defs and structs Date: Fri, 15 Feb 2019 05:05:06 -0800 Message-Id: <20190215130509.86290-7-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190215130509.86290-1-dafna3@gmail.com> References: <20190215130509.86290-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 | 12 ++++++++++++ drivers/media/v4l2-core/v4l2-ctrls.c | 6 ++++++ include/uapi/linux/v4l2-controls.h | 13 +++++++++++++ include/uapi/linux/videodev2.h | 1 + 4 files changed, 32 insertions(+) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 5e5bbc99a8bb..79b69faf3983 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) { } @@ -1480,6 +1484,7 @@ static int queue_init(void *priv, struct vb2_queue *src_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) +#define VICODEC_CID_STATELESS_FWHT (VICODEC_CID_CUSTOM_BASE + 2) static int vicodec_s_ctrl(struct v4l2_ctrl *ctrl) { @@ -1526,6 +1531,13 @@ static const struct v4l2_ctrl_config vicodec_ctrl_p_frame = { .step = 1, }; +static const struct v4l2_ctrl_config vicodec_ctrl_stateless_state = { + .id = VICODEC_CID_STATELESS_FWHT, + .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 ff75f84011f8..5f2382f3a1a2 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -1671,6 +1671,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; } @@ -2251,6 +2254,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/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 06479f2fb3ae..0358a3b22391 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -52,6 +52,7 @@ #include +#define V4L2_CTRL_TYPE_FWHT_PARAMS 0x0105 /* Control classes */ #define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */ #define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */ @@ -1096,4 +1097,16 @@ enum v4l2_detect_md_mode { #define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_CLASS_BASE + 3) #define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETECT_CLASS_BASE + 4) +struct v4l2_ctrl_fwht_params { + __u64 backward_ref_ts; + __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/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index a78bfdc1df97..6a692114e989 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -665,6 +665,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 Fri Feb 15 13:05: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: 10814945 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 08F0E922 for ; Fri, 15 Feb 2019 13:06:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA6512F1F0 for ; Fri, 15 Feb 2019 13:06:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEB502F20F; Fri, 15 Feb 2019 13:06: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 671B22F1F0 for ; Fri, 15 Feb 2019 13:06:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728678AbfBONGb (ORCPT ); Fri, 15 Feb 2019 08:06:31 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:52026 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728184AbfBONGb (ORCPT ); Fri, 15 Feb 2019 08:06:31 -0500 Received: by mail-wm1-f66.google.com with SMTP id b11so9899409wmj.1 for ; Fri, 15 Feb 2019 05:06:29 -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=5hefY/mFjuvYXjS6gdFgHro5JseBVKXjSlOEkpUBcWQ=; b=LFKaBSoJN9KEYw5BSoNc1NuAxWsKfDDFW6+xn4ycNpwLSnmt993noG3w79NLiyYbCM FzihQEJ/xzjXlBqz5s/nfywoG1CY2B3jge30/2grVxpPSvNu1ef/ayzkE/gmMQzxvDPZ 7i0OeHoLEEWCN+CVwC4d0hAKjenvhqRFuwes5dOOTbwQ/U9Y10E7SlTHoNVdFEiWQnvZ vyGrhVZxjPi7QDcHev2Y5D5hL2gnuBh4LuJ/YwvOaQWQIW5BA8fq3RWj338F4vJGU28S yRXU34+WUyFa3FZljebR/mUhKILBS+zSltLe3FmFUt59iLweYwghZ51Ycr/NqwOGrpPH B3ow== 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=5hefY/mFjuvYXjS6gdFgHro5JseBVKXjSlOEkpUBcWQ=; b=pRsWcNMz7dTRBxbm8RTHjBmP/wN0cBfnSiwBE4rjfmUYvRpItNx0lNFABr2SRZnT3Q tk6moegMq8O1W0DVg7f5LtpEMyywz5UMRUT0OmYRxeER1vHFcGJ0FZFnBMWOQyg7hnFK dWOJhf5E5KnxFXaOc3f5zr6IVPTf3Sb6vZZFzEH/A7HgSb/9wcmX4YkEuUQ5mTRTCQo2 eX+EZ0Hyg8AeBf8WqLXA38y4r6mA+fXtI42fg6Na3agI+aHbx2UPE1AWMF4jHThGXEWM xvqkSmekc44KLkmT0wt6fUkaH+vlBNykCuo4LMCMUrsBE3Lotg2RxkMZr4/1bDSXMc7a l82A== X-Gm-Message-State: AHQUAua8dr/I43ie/0x7wJVmrKYsc7wDMLXzCshTe6K4QtBXigWQVzC+ 1L+C8zZ+fgJAclpPuAyety6SAQxybzE= X-Google-Smtp-Source: AHgI3IYNtJYOeFm0Jjd8DiFmcrXhZJADeewY9gUH1+oTcBqqZUS+ROOfTNVh5N5xiGJBSi3Jh9BsAQ== X-Received: by 2002:a1c:a185:: with SMTP id k127mr6465592wme.134.1550235988738; Fri, 15 Feb 2019 05:06:28 -0800 (PST) Received: from localhost.localdomain ([37.26.146.189]) by smtp.gmail.com with ESMTPSA id n6sm2091065wrt.23.2019.02.15.05.06.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 05:06:28 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v2 07/10] media: vicodec: Register another node for stateless decoder Date: Fri, 15 Feb 2019 05:05:07 -0800 Message-Id: <20190215130509.86290-8-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190215130509.86290-1-dafna3@gmail.com> References: <20190215130509.86290-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add stateless 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 79b69faf3983..e4139f6b0348 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; @@ -317,6 +319,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); } @@ -1461,8 +1466,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 ? true : false; + src_vq->requires_requests = ctx->is_stateless ? true : false; ret = vb2_queue_init(src_vq); if (ret) return ret; @@ -1560,6 +1571,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; @@ -1570,6 +1583,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); @@ -1609,6 +1624,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); @@ -1744,6 +1763,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, @@ -1761,23 +1784,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); @@ -1797,6 +1833,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 @@ -1804,6 +1841,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 Fri Feb 15 13:05: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: 10814947 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 C55D5922 for ; Fri, 15 Feb 2019 13:06:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B103B2F1F0 for ; Fri, 15 Feb 2019 13:06:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A512E2F20F; Fri, 15 Feb 2019 13:06: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 4CF7C2F1F0 for ; Fri, 15 Feb 2019 13:06:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728752AbfBONGd (ORCPT ); Fri, 15 Feb 2019 08:06:33 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:45088 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728184AbfBONGd (ORCPT ); Fri, 15 Feb 2019 08:06:33 -0500 Received: by mail-wr1-f68.google.com with SMTP id w17so10238046wrn.12 for ; Fri, 15 Feb 2019 05:06: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=rJdQVJLZIdSyqNEEd1x5Ny5bSOsQu+PKSeW1MMGhEbs=; b=Gany/PNr0lr4mHkAf5d2GoC1sxzfmyBUCieGKgWQpVaEB6b172k68P+2HkSAr63xPH u6IEseMfqDGMvZadhR1pQnaggVW7shsCfVsOa4Fe/JQgmQtTD2CdVeYe/fkSAui6x93V U6cmzNateLCg1jzuYptmXxiIZow2Lzhullf1fTzuAZ9QqV+dyGZ50eJ/JGLBSFiIrql+ XHkSCBxRoRDuq+bllVs90ofcYQSiVTY4wM25gW4SeCOPd6y+k7BEmNkMbyf+gUaOzXpd sRagBVne6RYWXIl9IT/mCIZN8bEBiHNcuwy4YBAMm+zpyfGiKQzxlWsEjjSBgYIhcB0b DnWQ== 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=rJdQVJLZIdSyqNEEd1x5Ny5bSOsQu+PKSeW1MMGhEbs=; b=FPVohTgcid4PeIvYHiCe76eHYE1aJ1DP7ZE1G3Y59ShEMyEo6CWGfjY0MvMXUVzdov GpiD89WD7geJTQKqcLzck5QTzN3OjWsIk69/gnqJ/UcEaBlUG6g9l30nkbP6pfAIBmHp j7vEVLZrBsUM3h3ai+WgnR/LcFMhQx4bJMcJQso8zmToDL4qP9sBC15fxNJFIYpzpDST OV7PWL4GAJSuzU1afw+SK8GqLhULk7GKMKulc8PMOU1SgMc1eNZ8WKRb2FtZWJeNZ7HV 5IlYlUld6hBP7SBBfZlckX+tC7nDeq+Ax6xFHMTatRXUDeYKZ1dQ1IYc3ez+1EetGMa9 lB+w== X-Gm-Message-State: AHQUAubo1kgphiqtZJpN4HWWQp8GKgsHRTxROIALtkfqvO9q+QQIAtxf LaKpK00UBOOQvsP7Ny3faVsS7DLNXRM= X-Google-Smtp-Source: AHgI3IYUiCVWva8glBpO2RcoUI4gBz1vR7kL7J4jzqScAEXVfkao3b5dZva2FrQv4qhqZK2kWsxwJQ== X-Received: by 2002:adf:f9c4:: with SMTP id w4mr7019472wrr.218.1550235991050; Fri, 15 Feb 2019 05:06:31 -0800 (PST) Received: from localhost.localdomain ([37.26.146.189]) by smtp.gmail.com with ESMTPSA id n6sm2091065wrt.23.2019.02.15.05.06.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 05:06:30 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v2 08/10] media: vicodec: call v4l2_m2m_buf_copy_metadata also upon error Date: Fri, 15 Feb 2019 05:05:08 -0800 Message-Id: <20190215130509.86290-9-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190215130509.86290-1-dafna3@gmail.com> References: <20190215130509.86290-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 call v4l2_m2m_buf_copy_metadata also if decoding/encoding ends with status VB2_BUF_STATE_ERROR. 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 e4139f6b0348..031aaf83839c 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -165,12 +165,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 @@ -192,8 +190,10 @@ static int device_process(struct vicodec_ctx *ctx, return ret; vb2_set_plane_payload(&dst_vb->vb2_buf, 0, ret); } 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; @@ -204,11 +204,6 @@ static int device_process(struct vicodec_ctx *ctx, 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; } @@ -282,16 +277,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 Fri Feb 15 13:05: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: 10814949 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 4B2776C2 for ; Fri, 15 Feb 2019 13:06:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A1A52F1F6 for ; Fri, 15 Feb 2019 13:06:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E6C62F23D; Fri, 15 Feb 2019 13:06:36 +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 CA9862F1F6 for ; Fri, 15 Feb 2019 13:06:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387479AbfBONGf (ORCPT ); Fri, 15 Feb 2019 08:06:35 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45091 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728184AbfBONGe (ORCPT ); Fri, 15 Feb 2019 08:06:34 -0500 Received: by mail-wr1-f67.google.com with SMTP id w17so10238124wrn.12 for ; Fri, 15 Feb 2019 05:06:33 -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=a4j6PQw1rq/Yi1h59JxaKOfx1J7PmiOubaFunImkWsk=; b=ZFCMs1NioShWzfqcoX4bzbicF/OzRkg8UzRHD/oAGrBhRoVNipGaPBXVOEOFPiJ4id Bz4u95qrMr3ogc75y6uyRulq3BAYhLQJqNv9zZkqYHsxxX1d/NagNmPkRc2oL1TTo1js ixlbH5g0XC3gAfje0ROq0WFm3CHV5WlCqCtFn865DEJWUbTsYLM7a9pQcGxoraCE+BNo +N1/oEepslI3niJcZ3AthI8aQWIv6erJn+J6vDikjqRQZwQoqKWcypp44Sf7jNa2Sczr 65ZAYbg8jNKbvXejml09C6PgR7sFljiHfztL959kewwOQ/bjlZrCQjfqMq+QijyW2+PX 5pqA== 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=a4j6PQw1rq/Yi1h59JxaKOfx1J7PmiOubaFunImkWsk=; b=F1byceU3gzdqkSK1u25r+XF5WifAAbJszuYGnMJKCdMjVaR1A/NJsj3VF8gSYBld/h 6qDsjaD5qlsBh9l23x7UpFj26FN6e+LCl7mj+x++fo/uZWyvmy3g0VCpLYVbS0TgDSk3 OPmTD/fU3NrlOrYafRX2i4eHD9zJmEApNTdQrJ2Fow6e1BKUVz9MQRbru4gXczOdurBg bPU/YYMPHYvjr+Dq9eSalNc9PPwyuD7OlxgT79+7OWHn/NTrwpA+kMZr+0s60F4Szh2X hDtBktL7a7A6rHXrKQNtlh/eyKWnbt3pygBHDPLCidG67ygTTECiKoNtC1rLVGl/x10f KPFw== X-Gm-Message-State: AHQUAubLQ9LG1DL9HtULnIwTe/cDvKWaq/MvnbFGu1wIu+z04wUal1S1 scldmB+1gVFrzo7ytweTBTGWLaipo4U= X-Google-Smtp-Source: AHgI3IY+9B9Ye5Xk0nXJY51nnpl8l7+g78QQrvclOKzly4bbiOG3Zog7CDgMUvcqjm5DErhtksA7NQ== X-Received: by 2002:a5d:5544:: with SMTP id g4mr6682530wrw.269.1550235992965; Fri, 15 Feb 2019 05:06:32 -0800 (PST) Received: from localhost.localdomain ([37.26.146.189]) by smtp.gmail.com with ESMTPSA id n6sm2091065wrt.23.2019.02.15.05.06.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 05:06:32 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v2 09/10] media: vicodec: add a flag FWHT_FL_P_FRAME to fwht header Date: Fri, 15 Feb 2019 05:05:09 -0800 Message-Id: <20190215130509.86290-10-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190215130509.86290-1-dafna3@gmail.com> References: <20190215130509.86290-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 flag 'FWHT_FL_P_FRAME' to indicate that the frame is a p-frame so it needs the previous buffer as a reference frame. This is needed for the stateless codecs. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/codec-fwht.h | 1 + drivers/media/platform/vicodec/codec-v4l2-fwht.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/drivers/media/platform/vicodec/codec-fwht.h b/drivers/media/platform/vicodec/codec-fwht.h index eab4a97aa132..c2b1f3cc9fed 100644 --- a/drivers/media/platform/vicodec/codec-fwht.h +++ b/drivers/media/platform/vicodec/codec-fwht.h @@ -76,6 +76,7 @@ #define FWHT_FL_CHROMA_FULL_HEIGHT BIT(7) #define FWHT_FL_CHROMA_FULL_WIDTH BIT(8) #define FWHT_FL_ALPHA_IS_UNCOMPRESSED BIT(9) +#define FWHT_FL_P_FRAME BIT(10) /* A 4-values flag - the number of components - 1 */ #define FWHT_FL_COMPONENTS_NUM_MSK GENMASK(18, 16) diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.c b/drivers/media/platform/vicodec/codec-v4l2-fwht.c index 40b1f4901fd3..1c20b5685201 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.c +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.c @@ -257,6 +257,8 @@ int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) flags |= FWHT_FL_CR_IS_UNCOMPRESSED; if (encoding & FWHT_ALPHA_UNENCODED) flags |= FWHT_FL_ALPHA_IS_UNCOMPRESSED; + if (encoding & FWHT_FRAME_PCODED) + flags |= FWHT_FL_P_FRAME; if (rf.height_div == 1) flags |= FWHT_FL_CHROMA_FULL_HEIGHT; if (rf.width_div == 1) From patchwork Fri Feb 15 13:09:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10814953 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 52E3E6C2 for ; Fri, 15 Feb 2019 13:09:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C7A82D5D9 for ; Fri, 15 Feb 2019 13:09:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30EDB2D61F; Fri, 15 Feb 2019 13:09:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06C632D5D9 for ; Fri, 15 Feb 2019 13:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728462AbfBONJP (ORCPT ); Fri, 15 Feb 2019 08:09:15 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:40163 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727524AbfBONJP (ORCPT ); Fri, 15 Feb 2019 08:09:15 -0500 Received: by mail-wm1-f66.google.com with SMTP id t15so1498998wmi.5 for ; Fri, 15 Feb 2019 05:09:12 -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=WUKNxBUE8wvHV/4T3l2rYGn4jtimPpwn1AIORyWBra8=; b=R+Tb5amBsvJHCE8fgZFeezS92nd2lt4NPvY4N23DT/fPlqBnnmNHJyQiFBr5d7GbE0 li6xJ3Oa+mFgElPnZR7G5cw6XzOVM8ShE9Lpc+wkrMmKcQ9BqN5KIqH3lYODivWAhrX8 PDqL6+un9G2bR/bdj+7OlyWzfQzmhCpl448YquRgqeVTD7jF4zG7xW3aWYJmvgDB3W9M 4CV4Xusl8V/Ebmt4Nh3z95Pk8xxGoyymSpbgVAGoy71RG052J+Vj/SpJzJbMYzVdnkEb d7iVHex9tresfTg2mDLsa1TnpnThD2XCUq8EJf9yVsmJvDJS/CfhaRWyUiSEEBBhN6Da YRXg== 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=WUKNxBUE8wvHV/4T3l2rYGn4jtimPpwn1AIORyWBra8=; b=Sr83aKNV717dzH0NmoFNqyQnv3iJea0+mSp2B+6104RDEqzhxd5G6kliO5yLHYocp/ rWQ1eWB2DXV7K1B7rD7cN2zk2YBXZtIB9p+tzVURnPokGwPTLHQqb2uJpNFxmXWrXg03 dGxdrMYTZUb5bLAdtVlH08asVAgzP0j2tKjhxhk0FNauOcos1ySaBK5PxSXgP4lqwLUT 47XqIq54mBpv6c4iaqg95894PXLmQB5DS4QmbMUfbomE2D1XwIQswyaVvE7dslXSYYpM EU3CfIgVhkye6Lxhfr5pE5DUiTzFV/hhJj01GG4ctdkwCpkA9DQSzgKUwkGeU+Ihcjrn gjZQ== X-Gm-Message-State: AHQUAub5Fnp/ZRMrxVIHBLSXS1K4jMmy2fPSPPHXQhnGhdVh/A/cIkVn mj4afOnsEkBhbLLrVKp0fe+L7QyR9vo= X-Google-Smtp-Source: AHgI3IamLZTwV6e/uAqzFaKu7Ft1+18ZLt7DtOkJeBNCPqChimqZQWeTTj8Cil5qbVpTnEldrqFIEQ== X-Received: by 2002:a1c:c205:: with SMTP id s5mr6185628wmf.116.1550236151179; Fri, 15 Feb 2019 05:09:11 -0800 (PST) Received: from localhost.localdomain ([37.26.146.189]) by smtp.gmail.com with ESMTPSA id y1sm6362874wrh.65.2019.02.15.05.09.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 05:09:10 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH v2 10/10] media: vicodec: Add support for stateless decoder. Date: Fri, 15 Feb 2019 05:09:00 -0800 Message-Id: <20190215130900.86351-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 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 | 325 ++++++++++++++++-- include/uapi/linux/v4l2-controls.h | 1 + 3 files changed, 291 insertions(+), 36 deletions(-) diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.h b/drivers/media/platform/vicodec/codec-v4l2-fwht.h index 75343cdf45e2..b58a81b35661 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.h +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.h @@ -43,6 +43,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 031aaf83839c..b2607e9772c4 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -160,6 +160,60 @@ static struct vicodec_q_data *get_q_data(struct vicodec_ctx *ctx, return NULL; } +static bool validate_by_version(unsigned int flags, unsigned int version) +{ + if (!version || version > FWHT_VERSION) + return false; + + if (version == FWHT_VERSION) { + 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; +} + +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; + int i = 0; + const struct v4l2_fwht_pixfmt_info *info = NULL; + + if (params->version == FWHT_VERSION) { + components_num = 1 + ((params->flags & FWHT_FL_COMPONENTS_NUM_MSK) >> + FWHT_FL_COMPONENTS_NUM_OFFSET); + pixenc = (params->flags & FWHT_FL_PIXENC_MSK); + } + do { + info = v4l2_fwht_default_fmt(width_div, height_div, + components_num, pixenc, i++); + if (info && info->id == cur_info->id) + return true; + } while (info); + 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) @@ -167,12 +221,55 @@ 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) 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; + unsigned int comp_frame_size; + u8 *p_out = vb2_plane_vaddr(&src_vb->vb2_buf, 0); + + if (!src_req) { + v4l2_err(&dev->v4l2_dev, "%s: request is NULL\n", + __func__); + return -EFAULT; + } + ret = v4l2_ctrl_request_setup(src_req, &ctx->hdl); + if (ret) + return ret; + update_state_from_header(ctx); + + comp_frame_size = ntohl(ctx->state.header.size); + memcpy(state->compressed_frame, p_out, comp_frame_size); + + /* + * set the reference buffer from the reference timestamp + * only if this is a P-frame + */ + if (ntohl(ctx->state.header.flags) & FWHT_FL_P_FRAME) { + struct vb2_buffer *ref_vb2_buf; + u8 *ref_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; + ref_buf = vb2_plane_vaddr(ref_vb2_buf, 0); + copy_cap_to_ref(ref_buf, ctx->state.info, &ctx->state); + } + } p_dst = vb2_plane_vaddr(&dst_vb->vb2_buf, 0); if (!p_src || !p_dst) { v4l2_err(&dev->v4l2_dev, @@ -182,13 +279,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 { struct vicodec_q_data *q_dst; unsigned int comp_frame_size = ntohl(ctx->state.header.size); @@ -200,11 +298,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; } /* @@ -279,9 +378,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); @@ -300,7 +403,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); @@ -312,6 +415,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; @@ -368,21 +474,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 == FWHT_VERSION) { - 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) @@ -400,6 +496,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 statless 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); @@ -452,7 +554,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: @@ -1212,6 +1314,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); @@ -1275,10 +1385,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; } @@ -1326,12 +1437,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) { @@ -1362,12 +1494,7 @@ 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); state->visible_width = q_data->visible_width; state->visible_height = q_data->visible_height; @@ -1442,14 +1569,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, @@ -1498,10 +1635,60 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, #define VICODEC_CID_P_FRAME_QP (VICODEC_CID_CUSTOM_BASE + 1) #define VICODEC_CID_STATELESS_FWHT (VICODEC_CID_CUSTOM_BASE + 2) +static int vicodec_try_ctrl(struct v4l2_ctrl *ctrl) +{ + struct vicodec_ctx *ctx = container_of(ctrl->handler, + struct vicodec_ctx, hdl); + 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 VICODEC_CID_STATELESS_FWHT: + if (!q_dst->info) + return -EINVAL; + params = (struct v4l2_ctrl_fwht_params *) ctrl->p_new.p; + 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, + 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); + struct v4l2_ctrl_fwht_params *params; switch (ctrl->id) { case V4L2_CID_MPEG_VIDEO_GOP_SIZE: @@ -1513,12 +1700,18 @@ static int vicodec_s_ctrl(struct v4l2_ctrl *ctrl) case VICODEC_CID_P_FRAME_QP: ctx->state.p_frame_qp = ctrl->val; return 0; + case VICODEC_CID_STATELESS_FWHT: + params = (struct v4l2_ctrl_fwht_params *) ctrl->p_new.p; + 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 = { @@ -1544,6 +1737,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 = VICODEC_CID_STATELESS_FWHT, .elem_size = sizeof(struct v4l2_ctrl_fwht_params), .name = "FWHT-Stateless State Params", @@ -1667,6 +1861,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, @@ -1685,6 +1932,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, @@ -1751,6 +2003,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 diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 0358a3b22391..ce6ee8af466e 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -1099,6 +1099,7 @@ enum v4l2_detect_md_mode { struct v4l2_ctrl_fwht_params { __u64 backward_ref_ts; + __u32 version; __u32 width; __u32 height; __u32 flags;