From patchwork Sat Mar 30 20:42:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10878569 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 7B7CE1874 for ; Sat, 30 Mar 2019 20:45:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 650762880D for ; Sat, 30 Mar 2019 20:45:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 594C428918; Sat, 30 Mar 2019 20:45:49 +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 6180528812 for ; Sat, 30 Mar 2019 20:45:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730642AbfC3Upq (ORCPT ); Sat, 30 Mar 2019 16:45:46 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:35672 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730582AbfC3Upq (ORCPT ); Sat, 30 Mar 2019 16:45:46 -0400 Received: by mail-wm1-f68.google.com with SMTP id y197so6716081wmd.0 for ; Sat, 30 Mar 2019 13:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=b0ei57Cu/k21r8C1uotyOlCHunhnCRiBKL/Y9ZizMM0=; b=ISJn5jJZgCi3GqZ5qTNHcNeSXfmRrmU3o0bTO6sNN8Cx8jdGeU/zDP8u8c+GJIbKB6 bThdLDx7p1Hs8D2h8nJRDh5U97H6h7DzUTR9BR9f90uofthliQzewMRvY3pjI4fLPg6M X+L4C2MBnVKdo4XtnRUM43WRbUuPc6RFK3AQPtZof+Zh4yspY54YrSDloVEaxGm/ZEro hTExfbLaB2eGDvkbqToTonQ9jgsO0uKSu3UhxG9TfaVyFRu/5fF+MWAIKpLYIfCW3hMr GxGOd2QzWgtggAUrA/kzvp5Q9Ipa9yG9TuqVg65e6z5yCeJLacFbOaIm3GMSQJpybSl8 A/xA== 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=b0ei57Cu/k21r8C1uotyOlCHunhnCRiBKL/Y9ZizMM0=; b=pBlilg4zXMMz1qYK8m2Z52msEZ/2utySACEksOHUrSi+LaR3uOksrRQjvvYUj44gg6 Vzbyi+dc8HlRi1WUmtWFb8iWYglc1WWcC7ESe88KyV4dHX1SBOlDQTD45FncbikULmkI CDdSbeMXf2nOrgAtCLQAkm6JCE78W2fXKMDakhUfWVl9Ip8Ol3JNNCK0AfYuGrP9p70b AIGL25blIhWfAQ+gRj76hmhWxTegv2rzuBhoMqPntzHMMv9DfU5fBFBXMPTCDPccX0yA qPxmufJ1kqKFrMC2znvVL7UVfIJ8MB2RCv4CEILrh8727R7TszxOD5obDNJdgM1v1GMS 2/NA== X-Gm-Message-State: APjAAAWuMbmpLhYF+VhY7TA5HVcx3h4Lbb8kX/TDE3PgxvG+xqJKs/uK 2vdqRppxLXVHNzg+waqR9Se0XPMkHpo= X-Google-Smtp-Source: APXvYqwc4P3HvJX6eDou/iF2NhOu+UYG6lsFQU64rrsZ1j6Fb2VCILe4UGjNZZlvvj2aaY3Ch2aUBQ== X-Received: by 2002:a05:600c:2055:: with SMTP id p21mr6980546wmg.118.1553978744202; Sat, 30 Mar 2019 13:45:44 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id a9sm5903671wmb.30.2019.03.30.13.45.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 13:45:43 -0700 (PDT) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH 01/14] kernel/sysctl.c: bug fix Date: Sat, 30 Mar 2019 13:42:59 -0700 Message-Id: <20190330204311.107417-2-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190330204311.107417-1-dafna3@gmail.com> References: <20190330204311.107417-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Signed-off-by: Hans Verkuil --- kernel/sysctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index e5da394d1ca3..3e959d67d619 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -124,7 +124,7 @@ static int sixty = 60; static int __maybe_unused neg_one = -1; -static int zero; +static long zero; static int __maybe_unused one = 1; static int __maybe_unused two = 2; static int __maybe_unused four = 4; From patchwork Sat Mar 30 20:43: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: 10878571 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 007991669 for ; Sat, 30 Mar 2019 20:45:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFA8E2880D for ; Sat, 30 Mar 2019 20:45:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3C8228812; Sat, 30 Mar 2019 20:45:49 +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 8BC9A2891A for ; Sat, 30 Mar 2019 20:45:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730657AbfC3Upr (ORCPT ); Sat, 30 Mar 2019 16:45:47 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:35801 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730638AbfC3Upr (ORCPT ); Sat, 30 Mar 2019 16:45:47 -0400 Received: by mail-wr1-f65.google.com with SMTP id w1so6869537wrp.2 for ; Sat, 30 Mar 2019 13:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kh4BeWbL0XXVBjuQMhrIp5mV5ORgkdRe+08rKr1QdK8=; b=oWNlZJXXTLjnQzBDrt9BQDMFGB/Zwehs3EP90PHpvc8lyzp3hm1ffU4l7s10O1PvJQ h84ISpQiSJQBrPp+tDPJ/0RMwlvT6e6jpUK/BD6b5z4Z9lPC0HnSm27g0Ez3mwiCnOc7 sPiQn3JrP+H4kvHUSH8brHUgPtRV+aczVfCVDUvGvgv31cQiMPOjVyzWZDeOGkPWKK6Z ffCndxrT8VaIgjxyGZDQb4E7sjOfsqyoCKuwGGrqm49gngKGNWsrrekZH7dX3g2+5SrE q/1JM37OatMsBWRZGgA6bh2NTFEBnsNHBwD2tS9LJ0RRLK8+2hhxMlbQzT1BlmRY0lye KoQg== 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=kh4BeWbL0XXVBjuQMhrIp5mV5ORgkdRe+08rKr1QdK8=; b=sLLRTPFOlRWe1Kev+y000PtYsTQkdZx0FvMzKUv8oHGuVbbaZUAet81EdQ5qf+cbnb YxZOHBsC1O0QRPC5xVEOVfsNwczc8RacPzObJ8oOFm1RhM2HYhZ17xOZVk4tCCa2Ux5p v9388mkcras/IG7mcl124xH/ySKi68CTC+D1ef27z1d8oq6+Utvk5HCz+ak+tTqjEed/ i6JXHuqxrzT3sRffIIX5m/G2tKsGik32nmH+XkQBf82IF4ZyNxCNI0EZK1vHoPKZmBLy MqN2ZL4atmPtsjbWSeq/lR0WjtFGtXYIXAmilWj6SFOvI8zir8pACBWISXWuootxtgZG qKUA== X-Gm-Message-State: APjAAAUH2f5b0xEuABAXNU02fq7JFUIKmVTTA2rPdDL++Ym6GKB/+E2j jmDvrJPMnIz1FR9/OkeZxAArH5fyrpU= X-Google-Smtp-Source: APXvYqzwD9d51YikQDYTROt9kisIB0yaZnLb+C+stn1U9D+zr8d1dIdY3JKgvVmBMy2ks9tj3+xCHw== X-Received: by 2002:adf:e443:: with SMTP id t3mr4553706wrm.257.1553978745460; Sat, 30 Mar 2019 13:45:45 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id a9sm5903671wmb.30.2019.03.30.13.45.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 13:45:44 -0700 (PDT) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH 02/14] vicodec: always return a valid format. Date: Sat, 30 Mar 2019 13:43:00 -0700 Message-Id: <20190330204311.107417-3-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190330204311.107417-1-dafna3@gmail.com> References: <20190330204311.107417-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Rather than returning width/height values of 0, just default to a format. Formats in V4L2 are always supposed to be valid, there is no concept of an invalid format. Signed-off-by: Hans Verkuil --- drivers/media/platform/vicodec/vicodec-core.c | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index bd01a9206aa6..a6b35db7203a 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -1771,11 +1771,13 @@ static const struct v4l2_ctrl_config vicodec_ctrl_stateless_state = { */ static int vicodec_open(struct file *file) { + const struct v4l2_fwht_pixfmt_info *info = v4l2_fwht_get_pixfmt(0); struct video_device *vfd = video_devdata(file); struct vicodec_dev *dev = video_drvdata(file); struct vicodec_ctx *ctx = NULL; struct v4l2_ctrl_handler *hdl; - unsigned int size; + unsigned int raw_size; + unsigned int comp_size; int rc = 0; if (mutex_lock_interruptible(vfd->lock)) @@ -1814,7 +1816,7 @@ static int vicodec_open(struct file *file) v4l2_ctrl_handler_setup(hdl); if (ctx->is_enc) - ctx->q_data[V4L2_M2M_SRC].info = v4l2_fwht_get_pixfmt(0); + ctx->q_data[V4L2_M2M_SRC].info = info; else if (ctx->is_stateless) ctx->q_data[V4L2_M2M_SRC].info = &pixfmt_stateless_fwht; else @@ -1823,22 +1825,22 @@ static int vicodec_open(struct file *file) ctx->q_data[V4L2_M2M_SRC].coded_height = 720; ctx->q_data[V4L2_M2M_SRC].visible_width = 1280; ctx->q_data[V4L2_M2M_SRC].visible_height = 720; - size = 1280 * 720 * ctx->q_data[V4L2_M2M_SRC].info->sizeimage_mult / - ctx->q_data[V4L2_M2M_SRC].info->sizeimage_div; + raw_size = 1280 * 720 * info->sizeimage_mult / info->sizeimage_div; + comp_size = 1280 * 720 * pixfmt_fwht.sizeimage_mult / + pixfmt_fwht.sizeimage_div; if (ctx->is_enc || ctx->is_stateless) - ctx->q_data[V4L2_M2M_SRC].sizeimage = size; + ctx->q_data[V4L2_M2M_SRC].sizeimage = raw_size; else ctx->q_data[V4L2_M2M_SRC].sizeimage = - size + sizeof(struct fwht_cframe_hdr); + comp_size + sizeof(struct fwht_cframe_hdr); + ctx->q_data[V4L2_M2M_DST] = ctx->q_data[V4L2_M2M_SRC]; if (ctx->is_enc) { - ctx->q_data[V4L2_M2M_DST] = ctx->q_data[V4L2_M2M_SRC]; ctx->q_data[V4L2_M2M_DST].info = &pixfmt_fwht; - ctx->q_data[V4L2_M2M_DST].sizeimage = 1280 * 720 * - ctx->q_data[V4L2_M2M_DST].info->sizeimage_mult / - ctx->q_data[V4L2_M2M_DST].info->sizeimage_div + - sizeof(struct fwht_cframe_hdr); + ctx->q_data[V4L2_M2M_DST].sizeimage = + comp_size + sizeof(struct fwht_cframe_hdr); } else { - ctx->q_data[V4L2_M2M_DST].info = NULL; + ctx->q_data[V4L2_M2M_DST].info = info; + ctx->q_data[V4L2_M2M_DST].sizeimage = raw_size; } ctx->state.colorspace = V4L2_COLORSPACE_REC709; From patchwork Sat Mar 30 20:43: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: 10878573 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 38A3E139A for ; Sat, 30 Mar 2019 20:45:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 237042880D for ; Sat, 30 Mar 2019 20:45:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17AFE28918; Sat, 30 Mar 2019 20:45:51 +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 9A0B62880D for ; Sat, 30 Mar 2019 20:45:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730663AbfC3Upt (ORCPT ); Sat, 30 Mar 2019 16:45:49 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51226 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730582AbfC3Upt (ORCPT ); Sat, 30 Mar 2019 16:45:49 -0400 Received: by mail-wm1-f66.google.com with SMTP id 4so6042525wmf.1 for ; Sat, 30 Mar 2019 13:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9f90xLY6+DqHwHHOVozYVA09oMmI/32qgl0gBE7ssGs=; b=jKTGoJ2aQde/8ezexkMWjITUcpD48pzYXFY+gDjGrCIP46K256elUcRAMtqYEWGqfC qVvsiBNAjGFYlkIkwLCgVgeYMReaTlrL0BwTwn6k72a4tn4uslJtNzf3ULSlPzs3YWVz ZmFqT/zsAPGihY4zjCSfi5RmrX5TWl352KXV6fBuTbVBrQRwzPHEYjZjhPI952kytwLI Mmda12D/vYj1EZSQdm+S6f/8Ko+cIMqLFslA1yfZaxwF9aYnW/ynbmgsGyPXBErld25q cnDTuflPdk85XkeEE/KoliWJDLZ+4AHbkTeAEceS81bUeow9fATHbfN40rmu8y5gpCps yftA== 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=9f90xLY6+DqHwHHOVozYVA09oMmI/32qgl0gBE7ssGs=; b=GVuEldPbvwHGno1h834a/3sxKlpkUN7hgEacwKfbLDTruhjyf3dsAcCy+kh6X3N/jE QeAx2htd6hY34ztd4mMhdhdvhgpxPQ9YAERGh+paIAS+7zdo5G7bU/cZ6OxtgbITukTV v+bXzBtXGxwxBqV9r3Smar0PlXyJ8U/2+7C9twQ8tsBjg7hMLg1vJqoo9XW936/fU6ca 6qi8OqYissSqpO1njElO/IEeMaH06iCq1BdSgFITAfXakB9pJ5d485xtK5s3qB/w1UQ9 vz7RqCWH88Ru4oTY667g/8IiA0kpe0BRomFEcUSG0X7bM6sRSPVlq8XCDrGwvjxTGldc XBbQ== X-Gm-Message-State: APjAAAVREoG9sxLjdqw5i/YFd+yKo3V7o0L3Adcq9RRHH1LmTr8pFLqd OqZyeshVTG81gicW4bPC1Oq5KdEzhxQ= X-Google-Smtp-Source: APXvYqwgfSdbAxHAUNt0AwerZTT9yrzIjrm9DIsOyTCgTibpc3IgRzaPo2xZOY6BWNr+Bl3A2GuJew== X-Received: by 2002:a1c:ce42:: with SMTP id e63mr7861241wmg.118.1553978746614; Sat, 30 Mar 2019 13:45:46 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id a9sm5903671wmb.30.2019.03.30.13.45.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 13:45:46 -0700 (PDT) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH 03/14] vicodec: pass on enc output format to capture side Date: Sat, 30 Mar 2019 13:43:01 -0700 Message-Id: <20190330204311.107417-4-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190330204311.107417-1-dafna3@gmail.com> References: <20190330204311.107417-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Setting the encoder output format to e.g. 1920x1080 will set the crop rectangle to 1920x1080, the coded resolution to 1920x1088 and the capture coded resolution and sizeimage to 1920x1088 as well. Signed-off-by: Hans Verkuil --- drivers/media/platform/vicodec/vicodec-core.c | 64 ++++++++++++++++--- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index a6b35db7203a..3b5124838f15 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -1032,16 +1032,10 @@ static int vidioc_s_fmt(struct vicodec_ctx *ctx, struct v4l2_format *f) default: return -EINVAL; } - if (q_data->visible_width > q_data->coded_width) - q_data->visible_width = q_data->coded_width; - if (q_data->visible_height > q_data->coded_height) - q_data->visible_height = q_data->coded_height; - dprintk(ctx->dev, - "Setting format for type %d, coded wxh: %dx%d, visible wxh: %dx%d, fourcc: %08x\n", + "Setting format for type %d, coded wxh: %dx%d, fourcc: 0x%08x\n", f->type, q_data->coded_width, q_data->coded_height, - q_data->visible_width, q_data->visible_height, q_data->info->id); return 0; @@ -1063,18 +1057,69 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *priv, struct v4l2_format *f) { struct vicodec_ctx *ctx = file2ctx(file); - struct v4l2_pix_format_mplane *pix_mp; + struct vicodec_q_data *q_data; + struct vicodec_q_data *q_data_cap; struct v4l2_pix_format *pix; + struct v4l2_pix_format_mplane *pix_mp; + u32 coded_w = 0, coded_h = 0; + unsigned int size = 0; + u32 w, h; int ret; + if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { + w = f->fmt.pix.width; + h = f->fmt.pix.height; + } else { + w = f->fmt.pix_mp.width; + h = f->fmt.pix_mp.height; + } + q_data = get_q_data(ctx, f->type); + q_data_cap = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); + ret = vidioc_try_fmt_vid_out(file, priv, f); if (ret) return ret; + if (ctx->is_enc) { + struct vb2_queue *vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); + struct vb2_queue *vq_cap = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, + V4L2_BUF_TYPE_VIDEO_CAPTURE); + const struct v4l2_fwht_pixfmt_info *info = ctx->is_stateless ? + &pixfmt_stateless_fwht : &pixfmt_fwht; + + if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { + coded_w = f->fmt.pix.width; + coded_h = f->fmt.pix.height; + } else { + coded_w = f->fmt.pix_mp.width; + coded_h = f->fmt.pix_mp.height; + } + if (vb2_is_busy(vq) && (coded_w != q_data->coded_width || + coded_h != q_data->coded_height)) + return -EBUSY; + size = coded_w * coded_h * + info->sizeimage_mult / info->sizeimage_div; + if (!ctx->is_stateless) + size += sizeof(struct fwht_cframe_hdr); + + if (vb2_is_busy(vq_cap) && size > q_data_cap->sizeimage) + return -EBUSY; + } + ret = vidioc_s_fmt(file2ctx(file), f); if (!ret) { + if (ctx->is_enc) { + q_data->visible_width = w; + q_data->visible_height = h; + q_data_cap->coded_width = coded_w; + q_data_cap->coded_height = coded_h; + if (q_data_cap->sizeimage < size) + q_data_cap->sizeimage = size; + dprintk(ctx->dev, + "Setting output crop to %dx%d\n", w, h); + } + switch (f->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_OUTPUT: pix = &f->fmt.pix; ctx->state.colorspace = pix->colorspace; @@ -1082,7 +1127,6 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *priv, ctx->state.ycbcr_enc = pix->ycbcr_enc; ctx->state.quantization = pix->quantization; break; - case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: pix_mp = &f->fmt.pix_mp; ctx->state.colorspace = pix_mp->colorspace; From patchwork Sat Mar 30 20:43: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: 10878575 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 12820139A for ; Sat, 30 Mar 2019 20:45:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F081F284C4 for ; Sat, 30 Mar 2019 20:45:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4D0E28812; Sat, 30 Mar 2019 20:45:51 +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 9294E2880D for ; Sat, 30 Mar 2019 20:45:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730675AbfC3Upu (ORCPT ); Sat, 30 Mar 2019 16:45:50 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33763 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730638AbfC3Upt (ORCPT ); Sat, 30 Mar 2019 16:45:49 -0400 Received: by mail-wr1-f66.google.com with SMTP id q1so6863703wrp.0 for ; Sat, 30 Mar 2019 13:45:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bayHuOHVijRq9U7RUSlwkjRfnmoMGM8I+vgGhlExcdo=; b=T7ZhUAF6VETuK9EeG3ChAUeTQS0pvkxo+ulOJ9W5jrJYb7CW6bWtKYwBpNbjf6vQ3o 5iePV4gBkV7n49k3tm5OhLmwe+JNPzBInDohkIzz+ii6wytG5t2b8o3UDfuxNsBXfIfb pTaFSwSfSFMZZRGlkB06N4G13LlGuACuvVBnEr31ODgp5Qb1WjgzZEpiV5FSPogxAEPZ 7rJP2M4mC3u52wpoJXTbgJqdzC0jSSeyO51UPiMEasOkeEwbi4xgcYJw6IdP++m4FD/c q+idnm+lJOC/PRoLIN7g2YA1kqcfdCuXQMHUuOqq37098mEuGAFUEyxBfFiSQG+IPhme iriw== 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=bayHuOHVijRq9U7RUSlwkjRfnmoMGM8I+vgGhlExcdo=; b=SCtdBSKgCA175rWPaCKLAHVMB930Lk8T5AkmFSO73ov8xKZt3quVgIYn5l8XNdqSxS Ct4Oqj4rzxcivN9AUiOsg4+f/4fgCpfcuvzxbDJCNktMjXBPXufU65N6cquh2uxcXGsE vx/CXSA8v9G0RvCjkO/enwq+qsULrO6zOhTj6oTEu+Z6Ap9ukzu5x4HERNOqy8xumZw4 pmyofufUTAITLacg5oXNxUjpzdY+wUMPU55rvR0gRG4PB+Z4yGgSheV9fXIea1nUNKlM cGNBzbKT6wwUD61hUZ6dD5eSi4EObLqkUwV3QZqcqYb/jenNj/xYUcCoU+zIbgkIMKiG uQHw== X-Gm-Message-State: APjAAAU3EdyqqryjoiNDGHsZbP0M7dg2+R+gkfJKVE5LCAL3x/+8L9GU Mohsh+x9BGfxRMiMGYT5qpguHFT/HA0= X-Google-Smtp-Source: APXvYqzJ3UQ8rWxn5uQTcc5eFxXczBSUGhaj7X3iS5DjWqH33h3Q6ffp1SHFgRYuPUSo2WkTgpKCIQ== X-Received: by 2002:adf:ea43:: with SMTP id j3mr33921317wrn.210.1553978747702; Sat, 30 Mar 2019 13:45:47 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id a9sm5903671wmb.30.2019.03.30.13.45.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 13:45:47 -0700 (PDT) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH 04/14] vicodec: add V4L2_CID_MIN_BUFFERS_FOR_OUTPUT Date: Sat, 30 Mar 2019 13:43:02 -0700 Message-Id: <20190330204311.107417-5-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190330204311.107417-1-dafna3@gmail.com> References: <20190330204311.107417-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil The stateful encoder requires the presence of this control. Since a single buffer is sufficient for vicodec, we just set this control to 1. Signed-off-by: Hans Verkuil --- drivers/media/platform/vicodec/vicodec-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 3b5124838f15..b0c1d7cd1db6 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -1841,13 +1841,16 @@ static int vicodec_open(struct file *file) file->private_data = &ctx->fh; ctx->dev = dev; hdl = &ctx->hdl; - v4l2_ctrl_handler_init(hdl, 4); + v4l2_ctrl_handler_init(hdl, 5); v4l2_ctrl_new_std(hdl, &vicodec_ctrl_ops, V4L2_CID_MPEG_VIDEO_GOP_SIZE, 1, 16, 1, 10); v4l2_ctrl_new_std(hdl, &vicodec_ctrl_ops, V4L2_CID_FWHT_I_FRAME_QP, 1, 31, 1, 20); v4l2_ctrl_new_std(hdl, &vicodec_ctrl_ops, V4L2_CID_FWHT_P_FRAME_QP, 1, 31, 1, 20); + if (ctx->is_enc) + v4l2_ctrl_new_std(hdl, &vicodec_ctrl_ops, + V4L2_CID_MIN_BUFFERS_FOR_OUTPUT, 1, 1, 1, 1); if (ctx->is_stateless) v4l2_ctrl_new_custom(hdl, &vicodec_ctrl_stateless_state, NULL); if (hdl->error) { From patchwork Sat Mar 30 20:43: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: 10878577 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 CA58D139A for ; Sat, 30 Mar 2019 20:45:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B56A9284C4 for ; Sat, 30 Mar 2019 20:45:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9DFC28812; Sat, 30 Mar 2019 20:45:53 +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 560E0284C4 for ; Sat, 30 Mar 2019 20:45:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730740AbfC3Upw (ORCPT ); Sat, 30 Mar 2019 16:45:52 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42871 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730582AbfC3Upu (ORCPT ); Sat, 30 Mar 2019 16:45:50 -0400 Received: by mail-wr1-f65.google.com with SMTP id g3so6823378wrx.9 for ; Sat, 30 Mar 2019 13:45:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SQGF3TuNF5KQ0AO+rkzzO1v78UFk3o3QLb/PiuS736c=; b=jxfJocJMqPX1mzHtguNTQxeul156g22WVeAXg7DP7Ib5aLQ6HVGG5OX/0Y0KsTReX5 yZuldt3BN7RhYpWB8Ko4ICIS4QbNuGwx1J2DL774W4COVU34/urstzHiF2LGsRrLQ82n RNOusI7AAKNeHOIH2EcCHDiVQedWcv47RizLNZpWMoezDzXO9r2cjZA423Lv5YyPvWwL EQyubqT2vyoxki7xMUiDO08EXdCcHZu8e29eGHoC3ki4FvzpTKb6QckQRWkJjppN5c8/ ZWdX/ubXGxtcnPWbzXIvDTdXp/HXZUvuuOAAmVTaEcLjZBWCGbOpOkD4StXLESsaAwPJ QInw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SQGF3TuNF5KQ0AO+rkzzO1v78UFk3o3QLb/PiuS736c=; b=kq0hWWyQrkcIUqQu+trpLssxzsT2NGWATM5AcTkl7VcFKMEMD4rAG8BO7T8nAL9eub JExx4mJyO2GyvURtuN2HI7nXbilbE3GdgWrD5pLoXjCqE03OgXZzbECkerO5OsWSLAyq KNSbmYPHq34mY3nR9CyxTFXUl31NqTc8/vnE/FSAOS5uuO65oqxpuruk1q2Yv33/HImH YopIMLaFc8dwhcsixdXSLEAbtkbjFGiOTjN22nHQ94vCYbHCaX2iFVOQPGGEaDzJr1Ai zvLmWL7CNdCdvXGqZhDYgVSsKsSAIjABJLb/KdF0e9M5RwNBk3CRcAMXXyJ+wZ59Wo/K D1XQ== X-Gm-Message-State: APjAAAVs9voAucF39ZbaCl10iDQ4BpcIXF211gEmn1RqlYYM0/YjPjSc 9iJ52CZozCR9tsMdxH6IkaNUZ3OtL4E= X-Google-Smtp-Source: APXvYqzb+okw8sadgN3FWZMPo1DoaP/5OH1++0p/7RqrMp2xrMVe8O1wc94KbGoGemZLs4mSTEILEQ== X-Received: by 2002:a5d:54c4:: with SMTP id x4mr34409813wrv.296.1553978748771; Sat, 30 Mar 2019 13:45:48 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id a9sm5903671wmb.30.2019.03.30.13.45.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 13:45:48 -0700 (PDT) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH 05/14] videobuf2-v4l2: set last_buffer_dequeued in dqbuf Date: Sat, 30 Mar 2019 13:43:03 -0700 Message-Id: <20190330204311.107417-6-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190330204311.107417-1-dafna3@gmail.com> References: <20190330204311.107417-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil last_buffer_dequeued was set to true in __fill_v4l2_buffer, but this is called for qbuf as well. Move it to vb2_dqbuf. Signed-off-by: Hans Verkuil --- drivers/media/common/videobuf2/videobuf2-v4l2.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index b11a779e97b0..379738372651 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -562,11 +562,6 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, void *pb) b->flags |= V4L2_BUF_FLAG_REQUEST_FD; b->request_fd = vbuf->request_fd; } - - if (!q->is_output && - b->flags & V4L2_BUF_FLAG_DONE && - b->flags & V4L2_BUF_FLAG_LAST) - q->last_buffer_dequeued = true; } /* @@ -785,6 +780,11 @@ int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking) ret = vb2_core_dqbuf(q, NULL, b, nonblocking); + if (!q->is_output && + b->flags & V4L2_BUF_FLAG_DONE && + b->flags & V4L2_BUF_FLAG_LAST) + q->last_buffer_dequeued = true; + /* * After calling the VIDIOC_DQBUF V4L2_BUF_FLAG_DONE must be * cleared. From patchwork Sat Mar 30 20:43: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: 10878579 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 E47D01669 for ; Sat, 30 Mar 2019 20:45:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE12E284C4 for ; Sat, 30 Mar 2019 20:45:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C264E28812; Sat, 30 Mar 2019 20:45:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EA8D284C4 for ; Sat, 30 Mar 2019 20:45:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730765AbfC3Upx (ORCPT ); Sat, 30 Mar 2019 16:45:53 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:54167 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730638AbfC3Upw (ORCPT ); Sat, 30 Mar 2019 16:45:52 -0400 Received: by mail-wm1-f67.google.com with SMTP id q16so6025142wmj.3 for ; Sat, 30 Mar 2019 13:45:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=x5vP80ugd2qMflGQR7sjBeKwGbrJjrWeYr/xS0c2cjI=; b=e6AcQgCZ5wz3VbDp3pMIoMfWa4c7QkCHrNLLlsqrEzzfSRnuZjTUz+c3ouWuPDKNsq lBRyg4+BCOIqxwbE+T1xd6hpXO8LhyqsSBF2XEX0cslTbiCo4ygZkRrEZsjbT5Fkps5O BBq0qBVNUSsBEaOJ3xkcpgsDThB9MyMlZBlWPVSLQjTj5vIV/Pbu1r2ucX8Xq9XpmNvN 4SvgH03Vbwy8ZsV/EnX0TbO9fRe2PQzjxPReKFWrUApYVVBDKISoNtAazD1Y0SLf+rfs rC64wTcE8C2AXTd+UsdduowLrk2VOVfC3WWKj23WRerNfUsWn8M2Q2IK8JwrNuw5n/AH JNAA== 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=x5vP80ugd2qMflGQR7sjBeKwGbrJjrWeYr/xS0c2cjI=; b=HvQx4LNfxM62tgdWYJjVUMfG3m+NlaW2fg4UiT28GgUc1YTydkymkerT++4cobNgOs 1acRlxFKVmBviqreuVx89SSEt7c/2Qj3i2CpSy44xdmvbu4FZvLRBwF1V7gloi/gtELC IVubvu9Ovo0x5wBCEK16K4R+X2lgEbtxgRuBnsqJwtq3be38ueQrABiMOwviHeGf7McF kW2TVGnHMEgEXnj8zO/J0FuSr34u85xPvHocNDuJCyg4nGz3IdGTnH8WA7D1QaiLzu+0 669ANpiqHUa99NsZIrRIcn/JzbVuDWxNqV3/qmPpFh77Kp6cdl2sRVuqpG2jdFh4MhpN rkHA== X-Gm-Message-State: APjAAAWB1Nvn+0wLhWlLyQdnPJFIaLFjnmExVcbFiAfFN53DlWCO2eX2 T/CSvTXIXvHlrD2EKpbQiRGVZHHEIZ8= X-Google-Smtp-Source: APXvYqz7ziNICtS27KUOINs5z7i7pDTOBaXzXEDS9UOVN9pNAVhCrgiJW58DO3bIbJWyeV2Rf32pXw== X-Received: by 2002:a1c:6a0d:: with SMTP id f13mr7503808wmc.76.1553978749828; Sat, 30 Mar 2019 13:45:49 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id a9sm5903671wmb.30.2019.03.30.13.45.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 13:45:49 -0700 (PDT) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH 06/14] vicodec: improve handling of ENC_CMD_STOP/START Date: Sat, 30 Mar 2019 13:43:04 -0700 Message-Id: <20190330204311.107417-7-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190330204311.107417-1-dafna3@gmail.com> References: <20190330204311.107417-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Correctly handle stopping and restarting the encoder, keeping track of the stop and drain states. Signed-off-by: Hans Verkuil --- drivers/media/platform/vicodec/vicodec-core.c | 121 +++++++++++++++--- 1 file changed, 100 insertions(+), 21 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index b0c1d7cd1db6..980c30cc9d48 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -116,12 +116,14 @@ struct vicodec_ctx { struct vicodec_dev *dev; bool is_enc; bool is_stateless; + bool is_draining; + bool next_is_last; + bool has_stopped; spinlock_t *lock; struct v4l2_ctrl_handler hdl; struct vb2_v4l2_buffer *last_src_buf; - struct vb2_v4l2_buffer *last_dst_buf; /* Source and destination queue data */ struct vicodec_q_data q_data[2]; @@ -138,6 +140,10 @@ struct vicodec_ctx { bool source_changed; }; +static const struct v4l2_event vicodec_eos_event = { + .type = V4L2_EVENT_EOS +}; + static inline struct vicodec_ctx *file2ctx(struct file *file) { return container_of(file->private_data, struct vicodec_ctx, fh); @@ -397,9 +403,6 @@ static enum vb2_buffer_state get_next_header(struct vicodec_ctx *ctx, /* device_run() - prepares and starts the device */ static void device_run(void *priv) { - static const struct v4l2_event eos_event = { - .type = V4L2_EVENT_EOS - }; struct vicodec_ctx *ctx = priv; struct vicodec_dev *dev = ctx->dev; struct vb2_v4l2_buffer *src_buf, *dst_buf; @@ -423,12 +426,12 @@ static void device_run(void *priv) dst_buf->flags &= ~V4L2_BUF_FLAG_LAST; v4l2_m2m_buf_copy_metadata(src_buf, dst_buf, !ctx->is_enc); - ctx->last_dst_buf = dst_buf; - spin_lock(ctx->lock); if (!ctx->comp_has_next_frame && src_buf == ctx->last_src_buf) { dst_buf->flags |= V4L2_BUF_FLAG_LAST; - v4l2_event_queue_fh(&ctx->fh, &eos_event); + v4l2_event_queue_fh(&ctx->fh, &vicodec_eos_event); + ctx->is_draining = false; + ctx->has_stopped = true; } if (ctx->is_enc || ctx->is_stateless) { src_buf->sequence = q_src->sequence++; @@ -579,6 +582,8 @@ static int job_ready(void *priv) unsigned int max_to_copy; unsigned int comp_frame_size; + if (ctx->has_stopped) + return 0; if (ctx->source_changed) return 0; if (ctx->is_stateless || ctx->is_enc || ctx->comp_has_frame) @@ -1217,25 +1222,45 @@ static int vidioc_s_selection(struct file *file, void *priv, return 0; } -static void vicodec_mark_last_buf(struct vicodec_ctx *ctx) +static int vicodec_mark_last_buf(struct vicodec_ctx *ctx) { - static const struct v4l2_event eos_event = { - .type = V4L2_EVENT_EOS - }; + struct vb2_v4l2_buffer *next_dst_buf; + int ret = 0; spin_lock(ctx->lock); + if (ctx->is_draining) { + ret = -EBUSY; + goto unlock; + } + if (ctx->has_stopped) + goto unlock; + ctx->last_src_buf = v4l2_m2m_last_src_buf(ctx->fh.m2m_ctx); - if (!ctx->last_src_buf && ctx->last_dst_buf) { - ctx->last_dst_buf->flags |= V4L2_BUF_FLAG_LAST; - v4l2_event_queue_fh(&ctx->fh, &eos_event); + ctx->is_draining = true; + if (ctx->last_src_buf) + goto unlock; + + next_dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); + if (!next_dst_buf) { + ctx->next_is_last = true; + goto unlock; } + + next_dst_buf->flags |= V4L2_BUF_FLAG_LAST; + vb2_buffer_done(&next_dst_buf->vb2_buf, VB2_BUF_STATE_DONE); + ctx->is_draining = false; + ctx->has_stopped = true; + v4l2_event_queue_fh(&ctx->fh, &vicodec_eos_event); + +unlock: spin_unlock(ctx->lock); + return ret; } static int vicodec_try_encoder_cmd(struct file *file, void *fh, struct v4l2_encoder_cmd *ec) { - if (ec->cmd != V4L2_ENC_CMD_STOP) + if (ec->cmd != V4L2_ENC_CMD_STOP && ec->cmd != V4L2_ENC_CMD_START) return -EINVAL; if (ec->flags & V4L2_ENC_CMD_STOP_AT_GOP_END) @@ -1254,8 +1279,22 @@ static int vicodec_encoder_cmd(struct file *file, void *fh, if (ret < 0) return ret; - vicodec_mark_last_buf(ctx); - return 0; + if (!vb2_is_streaming(&ctx->fh.m2m_ctx->cap_q_ctx.q) || + !vb2_is_streaming(&ctx->fh.m2m_ctx->out_q_ctx.q)) + return 0; + + if (ec->cmd == V4L2_ENC_CMD_STOP) + return vicodec_mark_last_buf(ctx); + ret = 0; + spin_lock(ctx->lock); + if (ctx->is_draining) { + ret = -EBUSY; + } else if (ctx->has_stopped) { + ctx->has_stopped = false; + vb2_clear_last_buffer_dequeued(&ctx->fh.m2m_ctx->cap_q_ctx.q); + } + spin_unlock(ctx->lock); + return ret; } static int vicodec_try_decoder_cmd(struct file *file, void *fh, @@ -1283,8 +1322,7 @@ static int vicodec_decoder_cmd(struct file *file, void *fh, if (ret < 0) return ret; - vicodec_mark_last_buf(ctx); - return 0; + return vicodec_mark_last_buf(ctx); } static int vicodec_enum_framesizes(struct file *file, void *fh, @@ -1462,6 +1500,23 @@ static void vicodec_buf_queue(struct vb2_buffer *vb) return; } + if (vb2_is_streaming(vq_cap)) { + if (!V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type) && + ctx->next_is_last) { + unsigned int i; + + for (i = 0; i < vb->num_planes; i++) + vb->planes[i].bytesused = 0; + vbuf->flags |= V4L2_BUF_FLAG_LAST; + vb2_buffer_done(vb, VB2_BUF_STATE_DONE); + ctx->is_draining = false; + ctx->has_stopped = true; + ctx->next_is_last = false; + v4l2_event_queue_fh(&ctx->fh, &vicodec_eos_event); + return; + } + } + /* * if both queues are streaming, the source change event is * handled in job_ready @@ -1571,8 +1626,6 @@ static int vicodec_start_streaming(struct vb2_queue *q, if (V4L2_TYPE_IS_OUTPUT(q->type)) ctx->last_src_buf = NULL; - else - ctx->last_dst_buf = NULL; state->gop_cnt = 0; @@ -1648,6 +1701,32 @@ static void vicodec_stop_streaming(struct vb2_queue *q) vicodec_return_bufs(q, VB2_BUF_STATE_ERROR); + if (ctx->is_enc) { + if (V4L2_TYPE_IS_OUTPUT(q->type)) { + if (ctx->is_draining) { + struct vb2_v4l2_buffer *next_dst_buf; + + spin_lock(ctx->lock); + ctx->last_src_buf = NULL; + next_dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); + if (!next_dst_buf) { + ctx->next_is_last = true; + } else { + next_dst_buf->flags |= V4L2_BUF_FLAG_LAST; + vb2_buffer_done(&next_dst_buf->vb2_buf, VB2_BUF_STATE_DONE); + ctx->is_draining = false; + ctx->has_stopped = true; + v4l2_event_queue_fh(&ctx->fh, &vicodec_eos_event); + } + spin_unlock(ctx->lock); + } + } else { + ctx->is_draining = false; + ctx->has_stopped = false; + ctx->next_is_last = false; + } + } + if ((!V4L2_TYPE_IS_OUTPUT(q->type) && !ctx->is_enc) || (V4L2_TYPE_IS_OUTPUT(q->type) && ctx->is_enc)) { if (!ctx->is_stateless) From patchwork Sat Mar 30 20:43: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: 10878581 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 B23851669 for ; Sat, 30 Mar 2019 20:45:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CC04284C4 for ; Sat, 30 Mar 2019 20:45:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9161128812; Sat, 30 Mar 2019 20:45:55 +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 3AF01284C4 for ; Sat, 30 Mar 2019 20:45:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730768AbfC3Upx (ORCPT ); Sat, 30 Mar 2019 16:45:53 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:33467 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730692AbfC3Upw (ORCPT ); Sat, 30 Mar 2019 16:45:52 -0400 Received: by mail-wm1-f65.google.com with SMTP id z6so12323718wmi.0 for ; Sat, 30 Mar 2019 13:45:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=d9NLSDmkZZ7ohnDdnY71XZb9bbAruqYljXTdhP+xu6E=; b=T/Rz6qIWs86LDVBPfIThYJAKN4c8k9HRb28yLR0AA/nzay6ZSg/MftYDu9K0sAKQTD xB5JemHqIVHTaudV9VZD3f6787T3ukU729bKecB1JCWfkHbOLjYVoNk/TRZWqDZUFF/Q lpws6beV6/KyIjmonRJSRkNxzvZjSE5oJ56h58yi9NhU7wompwDE2Ehxt/6UsDqN+BZd CX/ANkVjBntpcYQVIAtFZyJmmry4yFhh3VSUxbN4q0XxPJNXiAJ6pLuRD0QuYOO80Oio c26Kzw7wbTp2IAyN3wmdpqSxFYGS/dZCM9bbWPfZhIApzgrm4+VpibrHOLtCg2Jzgrh7 8kgw== 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=d9NLSDmkZZ7ohnDdnY71XZb9bbAruqYljXTdhP+xu6E=; b=NzqIF4mrtQPfWq0S33GYXiVxqxUGtMd+zgqeVSGPxopGstneagNUiz/pvPvo/k7gkz cxYfXwjx2N5/DPS0klU/BxIQgE34zxsUI3ccp0CJ9YU/JTeWtBuqCYVTglJ4Dtle6WT4 4ov0QQYknud5v+a/fM+oNUBwPXrI1noinrgzvdGXNQ/i2Pn7NPpuI7349oP62stQmgHJ +06HwEq/JWbG9sFXXxiqY1NeNAhGq90wRg07banuRLBsdPpYN6urjiiePzPitkNNKHZW jwjbVELNZ0OcefniAEm2VSQrvhJBf13OY4dSGYMg1govjNmIu5AOjDmsdwHEDVHW/kSC JjBw== X-Gm-Message-State: APjAAAUnTI33G3dzydW/BMy/p9ueg2ewGAk9vGfMvM0B8B/UGYGz9ivi UuWwOANgmEW1uyrfdj760uvnz/LK4r0= X-Google-Smtp-Source: APXvYqxK+0n9byFm94n+XvO1RjrAMFeeNiJhLwZ46a4UPZNj8KBAzYwmRO3b3jNLeKLGyOYMAnvfNA== X-Received: by 2002:a7b:c4d2:: with SMTP id g18mr7547549wmk.108.1553978750945; Sat, 30 Mar 2019 13:45:50 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id a9sm5903671wmb.30.2019.03.30.13.45.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 13:45:50 -0700 (PDT) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH 07/14] vicodec: restrict decoder format list when src fmt is known Date: Sat, 30 Mar 2019 13:43:05 -0700 Message-Id: <20190330204311.107417-8-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190330204311.107417-1-dafna3@gmail.com> References: <20190330204311.107417-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Report the full list of supported decoder formats until the format encoded in the bitstream is known. After that only report the formats compatible with that initial format. Signed-off-by: Hans Verkuil --- drivers/media/platform/vicodec/vicodec-core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 980c30cc9d48..7e4ac412cc38 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -671,7 +671,6 @@ static int job_ready(void *priv) v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); update_capture_data_from_header(ctx); - ctx->first_source_change_sent = true; v4l2_event_queue_fh(&ctx->fh, &rs_event); set_last_buffer(dst_buf, src_buf, ctx); ctx->source_changed = true; @@ -718,7 +717,7 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx, const struct v4l2_fwht_pixfmt_info *info = get_q_data(ctx, f->type)->info; - if (!info || ctx->is_enc) + if (!ctx->first_source_change_sent || ctx->is_enc) info = v4l2_fwht_get_pixfmt(f->index); else info = v4l2_fwht_find_nth_fmt(info->width_div, @@ -1522,6 +1521,7 @@ static void vicodec_buf_queue(struct vb2_buffer *vb) * handled in job_ready */ if (vb2_is_streaming(vq_cap) && vb2_is_streaming(vq_out)) { + ctx->first_source_change_sent = true; v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); return; } @@ -1726,6 +1726,8 @@ static void vicodec_stop_streaming(struct vb2_queue *q) ctx->next_is_last = false; } } + if (!ctx->is_enc && V4L2_TYPE_IS_OUTPUT(q->type)) + ctx->first_source_change_sent = false; if ((!V4L2_TYPE_IS_OUTPUT(q->type) && !ctx->is_enc) || (V4L2_TYPE_IS_OUTPUT(q->type) && ctx->is_enc)) { From patchwork Sat Mar 30 20:43: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: 10878583 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 AB973139A for ; Sat, 30 Mar 2019 20:45:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97CFD28918 for ; Sat, 30 Mar 2019 20:45:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C6BB2891A; Sat, 30 Mar 2019 20:45:56 +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 43C802880D for ; Sat, 30 Mar 2019 20:45:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730851AbfC3Upz (ORCPT ); Sat, 30 Mar 2019 16:45:55 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:33469 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730582AbfC3Upy (ORCPT ); Sat, 30 Mar 2019 16:45:54 -0400 Received: by mail-wm1-f66.google.com with SMTP id z6so12323759wmi.0 for ; Sat, 30 Mar 2019 13:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ipl0X4aaYv/pXuihFjKw94Dv3xhE72Uxyvxo+HMZb9k=; b=T6fKQ4T+GmEtgbtqCPbYWE+bS0qX4qP0+UZ7tPmNAKslp4ZMAABDUZCHiGvfoTdNdE +CBI3/ebdgZpFeLXu3fCOguxK1x0m+OINjgCCCONS95JVyVfMxdwuyn9q9B2bVcX3baj HWqBSJV7l2nO5R6Vd1bt7Ug/0WK19RhjjErW7tdLpP+yTG0EkPWvyMU/utPOf+gWuip5 LUj/Ey+seX5mw3ZOTLiFQx2UR5HpaTh6mVZAbHKoeDBA6WJC35jrSVV1KZ6oY5VO+HzE ugjMDmRG77OKrhscqNEWNsD/NTrEa/cYyfgW31Cp58OkGQgE0zF/iBHC63fhil0lh4rO hmRA== 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=Ipl0X4aaYv/pXuihFjKw94Dv3xhE72Uxyvxo+HMZb9k=; b=MwY1GYJkHC3S1eyCTOsKQO2xZi5fYRgaG4lTrgT7+tHSjbpPbW1FtDOsjA0FcuwTUz bIo2mMK5k2hD0FhCM+EKwuui6o3p7sZX+4xY/yFYyDenHkSPrkE56AxlMlDAk05xzS9J FrL00dU70vVMYZPxgjeDOaPZbVchiN51JdEIASyBSw47tD8XnwXOCDSK5GH88d1STqkc QGdCaXfzj0KBOfkG/UnYeq90+Ytzk602Jw0sQw0wWm768L9dO4mHHzQvixZh7rUB5w+6 LwrJkNlUwSWKQIDXm8RzLy/GgVuEyWg/NpQ0cBdhhtYxzTTrkqadt5g+8IhlEADrLG2y GUog== X-Gm-Message-State: APjAAAXJVkqvsXCBO1tnhE1roCDGvouw2LyIzD0O5oIZZTgi/Wb9W7dX Bo8ldD3yfTXQ/zaZt1ZR975+aq0Xi3g= X-Google-Smtp-Source: APXvYqzDzQfiTuB1s2sC9e3XR829vvmU4UWIipOdpApplp09tussVqgKtdQdX7X+hCvg2lo0NFr33A== X-Received: by 2002:a1c:9c14:: with SMTP id f20mr7690284wme.16.1553978751934; Sat, 30 Mar 2019 13:45:51 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id a9sm5903671wmb.30.2019.03.30.13.45.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 13:45:51 -0700 (PDT) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Hans Verkuil Subject: [PATCH 08/14] vicodec: fix vicodec_buf_queue() Date: Sat, 30 Mar 2019 13:43:06 -0700 Message-Id: <20190330204311.107417-9-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190330204311.107417-1-dafna3@gmail.com> References: <20190330204311.107417-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Only set first_source_change_sent for decoders. Signed-off-by: Hans Verkuil --- drivers/media/platform/vicodec/vicodec-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 7e4ac412cc38..ba327512e085 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -1521,7 +1521,8 @@ static void vicodec_buf_queue(struct vb2_buffer *vb) * handled in job_ready */ if (vb2_is_streaming(vq_cap) && vb2_is_streaming(vq_out)) { - ctx->first_source_change_sent = true; + if (!ctx->is_enc) + ctx->first_source_change_sent = true; v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); return; } From patchwork Sat Mar 30 20:43: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: 10878585 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 F22841874 for ; Sat, 30 Mar 2019 20:45:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCBED2880D for ; Sat, 30 Mar 2019 20:45:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D11A328918; Sat, 30 Mar 2019 20:45:56 +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 6695628812 for ; Sat, 30 Mar 2019 20:45:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730857AbfC3Upz (ORCPT ); Sat, 30 Mar 2019 16:45:55 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41779 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730769AbfC3Upy (ORCPT ); Sat, 30 Mar 2019 16:45:54 -0400 Received: by mail-wr1-f68.google.com with SMTP id r4so6834663wrq.8 for ; Sat, 30 Mar 2019 13:45:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J8Qwf9YZDIIhE+Gk4+r2yhkT7DL0FcWTxX1YaphqNJM=; b=PpKrThwmh48VrRrfsf5iC3T+pi9emTgxg9R0JieBD5HPHAUKwBuTfEANe08ADsZgEW t9qBYDRMjEOKHv5LJ/AvWaBjaVl8oc/AlAq8ubb2r32SC7Htq5zIz/QmT7bFazRp0BfI aB7doD6TiFPUNwikZkfWManZCxS52mTPE7gXYzFx5S9CXcOGny0pltHRYxdRo9NXq1fD O5+OIhCGkJEVwJ/JdOnlkMsnx9kLOUzvYP/vEdzzSn8RZK0hpETS12mBkWoNu7dCW4zl voJTkV1NYbIup/7A8AlzQ5Nv+PWodqbE6zbUzA4DvOyvMz7gRexq/BXekWAVB1Yapvkj 0oIQ== 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=J8Qwf9YZDIIhE+Gk4+r2yhkT7DL0FcWTxX1YaphqNJM=; b=WRGHOv3ne5R4tgvM/c9NG4tccz8J9+472pA34S0DZoU139hNHG232jiOn9N4EXwIl+ 31PCJgz96S49jnC4FgIbTgChAtVltdVkUJRp5nGOb5TXzAJTOH6VKNxf2DmYs91Er92W 9nkCCJwVy6DaurvNUEhqy3zh3ZEFvmu64WZ+DW7vqQxYYPdjAxgQv/SuJMz+tvsUO/y3 RszVCZriMK98q2XoyGfjYmTiaDyRg/vQ2uBR7PNCdbeFi8VZqgTiMtzxn8jj3LRo7cl3 1mb7yDf2esah/XWx0RwJm/PAEDP3sEm1hd1w4VXVhwz2VUzhmnW4BRwBfYQZEhyytWuo aF3A== X-Gm-Message-State: APjAAAUxwayM3j/eNTTB8WMlxsGD3DFz9kOelcwTzVlsjykTR7IUl3CO KPezlEuwNiKqWDqnJrYFE6rYh8v0lP4= X-Google-Smtp-Source: APXvYqw/mbZ71dilT7LYBAT0tFJGdhRbAEPJScKmuw+2f/5h+hn+CXkM1FuagA6wc7C4uwMZ3spoAw== X-Received: by 2002:a5d:4a8d:: with SMTP id o13mr34127776wrq.209.1553978752944; Sat, 30 Mar 2019 13:45:52 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id a9sm5903671wmb.30.2019.03.30.13.45.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 13:45:52 -0700 (PDT) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH 09/14] media: vicodec: don't test if info is NULL Date: Sat, 30 Mar 2019 13:43:07 -0700 Message-Id: <20190330204311.107417-10-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190330204311.107417-1-dafna3@gmail.com> References: <20190330204311.107417-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP pixel info of q_data is never set to NULL so there is no need to test if it is. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index ba327512e085..6276a803cc4d 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -659,7 +659,6 @@ static int job_ready(void *priv) if (ntohl(ctx->state.header.width) != q_dst->visible_width || ntohl(ctx->state.header.height) != q_dst->visible_height || - !q_dst->info || hdr_width_div != q_dst->info->width_div || hdr_height_div != q_dst->info->height_div) { static const struct v4l2_event rs_event = { @@ -768,9 +767,6 @@ static int vidioc_g_fmt(struct vicodec_ctx *ctx, struct v4l2_format *f) q_data = get_q_data(ctx, f->type); info = q_data->info; - if (!info) - info = v4l2_fwht_get_pixfmt(0); - switch (f->type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_OUTPUT: @@ -992,7 +988,6 @@ static int vidioc_s_fmt(struct vicodec_ctx *ctx, struct v4l2_format *f) pix = &f->fmt.pix; if (ctx->is_enc && V4L2_TYPE_IS_OUTPUT(f->type)) fmt_changed = - !q_data->info || q_data->info->id != pix->pixelformat || q_data->coded_width != pix->width || q_data->coded_height != pix->height; @@ -1015,7 +1010,6 @@ static int vidioc_s_fmt(struct vicodec_ctx *ctx, struct v4l2_format *f) pix_mp = &f->fmt.pix_mp; if (ctx->is_enc && V4L2_TYPE_IS_OUTPUT(f->type)) fmt_changed = - !q_data->info || q_data->info->id != pix_mp->pixelformat || q_data->coded_width != pix_mp->width || q_data->coded_height != pix_mp->height; @@ -1593,10 +1587,6 @@ static unsigned int total_frame_size(struct vicodec_q_data *q_data) unsigned int size; unsigned int chroma_div; - if (!q_data->info) { - WARN_ON(1); - return 0; - } size = q_data->coded_width * q_data->coded_height; chroma_div = q_data->info->width_div * q_data->info->height_div; @@ -1619,9 +1609,6 @@ static int vicodec_start_streaming(struct vb2_queue *q, unsigned int total_planes_size; u8 *new_comp_frame = NULL; - if (!info) - return -EINVAL; - chroma_div = info->width_div * info->height_div; q_data->sequence = 0; @@ -1820,8 +1807,6 @@ static int vicodec_try_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_MPEG_VIDEO_FWHT_PARAMS: - if (!q_dst->info) - return -EINVAL; params = ctrl->p_new.p_fwht_params; if (params->width > q_dst->coded_width || params->width < MIN_WIDTH || From patchwork Sat Mar 30 20:43: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: 10878587 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 ACA471669 for ; Sat, 30 Mar 2019 20:45:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9577B284C4 for ; Sat, 30 Mar 2019 20:45:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85D0228812; Sat, 30 Mar 2019 20:45:58 +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 1181F284C4 for ; Sat, 30 Mar 2019 20:45:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730887AbfC3Up5 (ORCPT ); Sat, 30 Mar 2019 16:45:57 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45941 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730692AbfC3Up4 (ORCPT ); Sat, 30 Mar 2019 16:45:56 -0400 Received: by mail-wr1-f65.google.com with SMTP id s15so6821746wra.12 for ; Sat, 30 Mar 2019 13:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aymg/ZymsAqHb3+yj5jowOK+nJ0BpAR2xNjEHjFq82E=; b=UIEhecC2CiU5znBacto5rV9LFhAxOeYkEXTNzptSt77Fq4cNvIsG0vvZ5vthAaQzsu rbYiiTIeAA0TZlChytUBZPHo5WczGEgyYxfnYhjsooNJMd6z8JStAsA0VVir7NCyEG4V OeG5KAu6dl1yTQLkg15ukPp7zgYz8r67SJnbPnmBxmLGs4/zPanUHlAa4l0UF2dVI+oE prlSLjKZVmQc6pMl9pZNUS50ihE9BMtgw2l8LHCasfn4NcrttfSaYWazWa0zq9EtLsRI h0JJruMallKrqPFTwMZ33samMXblq00GYvZDfg24HTDHyO4fDwTCLxIuhT71aDjkHPNy GybQ== 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=aymg/ZymsAqHb3+yj5jowOK+nJ0BpAR2xNjEHjFq82E=; b=WZbzhIB7h5npdmOSqHGcsQuqoycd3/2T+Gf1v6ghIhH5+aHScMoGcCsPLLXz3CQZfD HdYttJMU1MyjJU0JwaU76yiQylDyi6MmApan6OXiV35dVa/jfaBtlg6re8M57EMqq7Or SbTAsCZEg1PLKwEet38T3YEfmCGYRsrO41c76NVN/0pyyyHxn3BjSXfd4KqGXJP519G/ cb7vsK6zhGZxHyyUJeFGKGVpjLwS9Qrl3yRhbudnHFAbZbLPhWLrUw//vpFQTJecS/uT SSe5T8By7vUmTW+L3JL7Rf+pMaZ7HjPLH55VMsqtQgAykcwa6oNsAN3Qjg92lEanUozJ W/Cg== X-Gm-Message-State: APjAAAV0yuoJy3PHXIp44nT30PngUnRaqTzhHdLuBvnvdEUXrvPmqS8B H9kIFSVUbPqwJargOIu3GvH3rb+JkEE= X-Google-Smtp-Source: APXvYqzqhv3PcnnhG/2Nfpr95rMv/SrQkICQN8zrs3ihZtDOy1Yjz4urQGw3hL//jSoTVcSeWpcpqw== X-Received: by 2002:a5d:68cf:: with SMTP id p15mr32190120wrw.301.1553978753923; Sat, 30 Mar 2019 13:45:53 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id a9sm5903671wmb.30.2019.03.30.13.45.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 13:45:53 -0700 (PDT) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH 10/14] media: vicodec: add field 'dev_inst' to vicodec_ctx Date: Sat, 30 Mar 2019 13:43:08 -0700 Message-Id: <20190330204311.107417-11-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190330204311.107417-1-dafna3@gmail.com> References: <20190330204311.107417-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add the field 'dev_inst' to vicodec_ctx that points to the 'vicodec_dev_instance'. This saves many if-elses Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 42 ++++++------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 6276a803cc4d..a701afd7cecb 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -121,6 +121,7 @@ struct vicodec_ctx { bool has_stopped; spinlock_t *lock; + struct vicodec_dev_instance *dev_inst; struct v4l2_ctrl_handler hdl; struct vb2_v4l2_buffer *last_src_buf; @@ -404,7 +405,6 @@ static enum vb2_buffer_state get_next_header(struct vicodec_ctx *ctx, static void device_run(void *priv) { struct vicodec_ctx *ctx = priv; - struct vicodec_dev *dev = ctx->dev; struct vb2_v4l2_buffer *src_buf, *dst_buf; struct vicodec_q_data *q_src, *q_dst; u32 state; @@ -454,13 +454,7 @@ static void device_run(void *priv) ctx->comp_has_frame = false; spin_unlock(ctx->lock); - if (ctx->is_enc) - v4l2_m2m_job_finish(dev->stateful_enc.m2m_dev, ctx->fh.m2m_ctx); - else if (ctx->is_stateless) - v4l2_m2m_job_finish(dev->stateless_dec.m2m_dev, - ctx->fh.m2m_ctx); - else - v4l2_m2m_job_finish(dev->stateful_dec.m2m_dev, ctx->fh.m2m_ctx); + v4l2_m2m_job_finish(ctx->dev_inst->m2m_dev, ctx->fh.m2m_ctx); } static void job_remove_src_buf(struct vicodec_ctx *ctx, u32 state) @@ -1771,12 +1765,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, src_vq->ops = &vicodec_qops; src_vq->mem_ops = &vb2_vmalloc_memops; src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; - if (ctx->is_enc) - src_vq->lock = &ctx->dev->stateful_enc.mutex; - else if (ctx->is_stateless) - src_vq->lock = &ctx->dev->stateless_dec.mutex; - else - src_vq->lock = &ctx->dev->stateful_dec.mutex; + src_vq->lock = &ctx->dev_inst->mutex; src_vq->supports_requests = ctx->is_stateless; src_vq->requires_requests = ctx->is_stateless; ret = vb2_queue_init(src_vq); @@ -1899,10 +1888,15 @@ static int vicodec_open(struct file *file) goto open_unlock; } - if (vfd == &dev->stateful_enc.vfd) + if (vfd == &dev->stateful_enc.vfd) { ctx->is_enc = true; - else if (vfd == &dev->stateless_dec.vfd) + ctx->dev_inst = &dev->stateful_enc; + } else if (vfd == &dev->stateless_dec.vfd) { ctx->is_stateless = true; + ctx->dev_inst = &dev->stateless_dec; + } else { + ctx->dev_inst = &dev->stateful_dec; + } v4l2_fh_init(&ctx->fh, video_devdata(file)); file->private_data = &ctx->fh; @@ -1959,19 +1953,9 @@ static int vicodec_open(struct file *file) ctx->state.colorspace = V4L2_COLORSPACE_REC709; - if (ctx->is_enc) { - ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateful_enc.m2m_dev, - ctx, &queue_init); - ctx->lock = &dev->stateful_enc.lock; - } else if (ctx->is_stateless) { - ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateless_dec.m2m_dev, - ctx, &queue_init); - ctx->lock = &dev->stateless_dec.lock; - } else { - ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateful_dec.m2m_dev, - ctx, &queue_init); - ctx->lock = &dev->stateful_dec.lock; - } + ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(ctx->dev_inst->m2m_dev, + ctx, &queue_init); + ctx->lock = &ctx->dev_inst->lock; if (IS_ERR(ctx->fh.m2m_ctx)) { rc = PTR_ERR(ctx->fh.m2m_ctx); From patchwork Sat Mar 30 20:43: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: 10878589 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 02B631669 for ; Sat, 30 Mar 2019 20:46:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E120B284C4 for ; Sat, 30 Mar 2019 20:45:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D542F28812; Sat, 30 Mar 2019 20:45:59 +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 65712284C4 for ; Sat, 30 Mar 2019 20:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730902AbfC3Up6 (ORCPT ); Sat, 30 Mar 2019 16:45:58 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:36280 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730769AbfC3Up5 (ORCPT ); Sat, 30 Mar 2019 16:45:57 -0400 Received: by mail-wm1-f68.google.com with SMTP id h18so6731298wml.1 for ; Sat, 30 Mar 2019 13:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SRlv6fJfa9LOuhNVcyUe0Pf1m/Kl+Xr6Y/BT1TLitbk=; b=Fg53jHjex8BQykzb3QKrPMW2nab61C0Zf6dVBDNPA33kkjbZDXFbUCGAlRvsfBv94V l0CLU9DLPIYL+rlCXnfaSGe4F0RNMPQfHjY+DEPXfKIfM9VP5cavbiI7zUqKwZm+NXPC 23mjNqHbKANDsQYPCGr2/l19DLTsFy1FgAxhcHz9lKH28RH0nB8onmSsmKLnq+06/lIS nhg7n9xD3cpv5A7mLRiPEyg/yVdWph5T5ejTtUC6OQ6rEFCe5uq6GJW02oJlJxbZQ/aE enIfo24+oBdD0mrazSg+Zw7wzGZA7ZDLYxMEhutA9aQctfo5PFslI2zshpgk8IOnng8T 7FIw== 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=SRlv6fJfa9LOuhNVcyUe0Pf1m/Kl+Xr6Y/BT1TLitbk=; b=dg2tqrKqFglIevaBikebxrUxf4h36qiX+bb1/c4Cc7XYkD9AHkgyTKlCL58WqqeXLc U/nfNhK7sQ+gJHW+VJvJUZPOfpmId7akiDEufNFRUOpUudWHZ4GZ75EyGZxlnxKCkT4v uL3BYuZ5bVQIp1CkX/TsILup/byAJaswg5vQHDzEGl9vgZ3hPbIGrGdnivyypsmZsA5x IwrkavsM5e1SmFv/uSZB9j9QQAi9mgrEYLGJQJGJLCTDTKiNxED8IAV3zhg5I2bsdpz9 MRTe9WL5E+CQzYo+Ye2NEGMhZy0Ic5ky42Bv5UdON8JRoV7bNP1XGRDZRHfn8jLSICo4 Xt0w== X-Gm-Message-State: APjAAAX2bK4Ew/B8C37uoeHULhCVx71rW010ezbMIuOgfwe734vfwauP WR6LC7O80lkh1CCzIvRCgb5gthFTxqM= X-Google-Smtp-Source: APXvYqxSAcJIMmrtrWOUH7ABHzSfdbasYogNEJsmIwYXEbmszBj+BsspkQQaB8Byb74O+RF+UGfcVg== X-Received: by 2002:a1c:c910:: with SMTP id f16mr7320855wmb.47.1553978754982; Sat, 30 Mar 2019 13:45:54 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id a9sm5903671wmb.30.2019.03.30.13.45.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 13:45:54 -0700 (PDT) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH 11/14] media: vicodec: Register another node for stateless encoder Date: Sat, 30 Mar 2019 13:43:09 -0700 Message-Id: <20190330204311.107417-12-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190330204311.107417-1-dafna3@gmail.com> References: <20190330204311.107417-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add stateless encoder instance field to the dev struct and register another node for the stateless encoder. The stateless API for the node will be implemented in further patches. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index a701afd7cecb..6bfcd266ffc4 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -105,6 +105,7 @@ struct vicodec_dev { struct vicodec_dev_instance stateful_enc; struct vicodec_dev_instance stateful_dec; struct vicodec_dev_instance stateless_dec; + struct vicodec_dev_instance stateless_enc; #ifdef CONFIG_MEDIA_CONTROLLER struct media_device mdev; #endif @@ -1887,16 +1888,20 @@ static int vicodec_open(struct file *file) rc = -ENOMEM; goto open_unlock; } + ctx->is_enc = (vfd == &dev->stateful_enc.vfd || + vfd == &dev->stateless_enc.vfd); - if (vfd == &dev->stateful_enc.vfd) { - ctx->is_enc = true; + ctx->is_stateless = (vfd == &dev->stateless_dec.vfd || + vfd == &dev->stateless_enc.vfd); + + if (vfd == &dev->stateful_enc.vfd) ctx->dev_inst = &dev->stateful_enc; - } else if (vfd == &dev->stateless_dec.vfd) { - ctx->is_stateless = true; - ctx->dev_inst = &dev->stateless_dec; - } else { + else if (vfd == &dev->stateful_dec.vfd) ctx->dev_inst = &dev->stateful_dec; - } + else if (vfd == &dev->stateless_enc.vfd) + ctx->dev_inst = &dev->stateless_enc; + else + ctx->dev_inst = &dev->stateless_dec; v4l2_fh_init(&ctx->fh, video_devdata(file)); file->private_data = &ctx->fh; @@ -2150,6 +2155,9 @@ static int vicodec_probe(struct platform_device *pdev) "stateless-decoder", false)) goto unreg_sf_dec; + if (register_instance(dev, &dev->stateless_enc, + "stateless-encoder", false)) + goto unreg_sl_dec; #ifdef CONFIG_MEDIA_CONTROLLER ret = v4l2_m2m_register_media_controller(dev->stateful_enc.m2m_dev, &dev->stateful_enc.vfd, @@ -2175,15 +2183,26 @@ static int vicodec_probe(struct platform_device *pdev) goto unreg_m2m_sf_dec_mc; } + ret = v4l2_m2m_register_media_controller(dev->stateless_enc.m2m_dev, + &dev->stateless_enc.vfd, + MEDIA_ENT_F_PROC_VIDEO_ENCODER); + if (ret) { + v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem media controller for stateless enc\n"); + goto unreg_m2m_sl_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_sl_dec_mc; + goto unreg_m2m_sl_enc_mc; } #endif return 0; #ifdef CONFIG_MEDIA_CONTROLLER +unreg_m2m_sl_enc_mc: + v4l2_m2m_unregister_media_controller(dev->stateless_enc.m2m_dev); unreg_m2m_sl_dec_mc: v4l2_m2m_unregister_media_controller(dev->stateless_dec.m2m_dev); unreg_m2m_sf_dec_mc: @@ -2191,9 +2210,12 @@ static int vicodec_probe(struct platform_device *pdev) unreg_m2m_sf_enc_mc: v4l2_m2m_unregister_media_controller(dev->stateful_enc.m2m_dev); unreg_m2m: + video_unregister_device(&dev->stateless_enc.vfd); + v4l2_m2m_release(dev->stateless_enc.m2m_dev); +#endif +unreg_sl_dec: 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); @@ -2217,6 +2239,7 @@ static int vicodec_remove(struct platform_device *pdev) 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); + v4l2_m2m_unregister_media_controller(dev->stateless_enc.m2m_dev); media_device_cleanup(&dev->mdev); #endif @@ -2225,6 +2248,7 @@ static int vicodec_remove(struct platform_device *pdev) video_unregister_device(&dev->stateful_enc.vfd); video_unregister_device(&dev->stateful_dec.vfd); video_unregister_device(&dev->stateless_dec.vfd); + video_unregister_device(&dev->stateless_enc.vfd); v4l2_device_unregister(&dev->v4l2_dev); return 0; From patchwork Sat Mar 30 20:43:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10878591 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 A7733139A for ; Sat, 30 Mar 2019 20:46:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 933F6284C4 for ; Sat, 30 Mar 2019 20:46:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87D0E28812; Sat, 30 Mar 2019 20:46:00 +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 230EC284C4 for ; Sat, 30 Mar 2019 20:46:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730917AbfC3Up7 (ORCPT ); Sat, 30 Mar 2019 16:45:59 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42881 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730885AbfC3Up6 (ORCPT ); Sat, 30 Mar 2019 16:45:58 -0400 Received: by mail-wr1-f67.google.com with SMTP id g3so6823636wrx.9 for ; Sat, 30 Mar 2019 13:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IcGGoCBGp8cgu8kIadgArHwCTJTAxAhiQo+nKORdetY=; b=d4HCy85DyHdh+YRJgj5xo22AwkaBEpfqkWaDKymm2pNi1ozhBfbNnkmrBpQSvVFy0H +sWXATx3Hsn/r1qRpLxoVoCbhMrUCKkurskLwLSbKK0t0HEl8nj2NUNUSiEJIybEg2y3 MlG7GLu7KVCqknrqvV5NrUWJqsrylXeIFqB+X2Linz0wjjMhbbhfRLkq9lTmnGrtXMAu 5jI0kKbboNF+CTYFfqmD3Tau/HGNTzjPTZajdeEfws9SXlrhBcQWh4MvO/yl/iTzQkd8 ocYa5Ali73hJwlK7P+chebgbJZAb+VLOS2PDlYNUi6SiNwuAAThEhhOkQk09LS+/4YKx xl5A== 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=IcGGoCBGp8cgu8kIadgArHwCTJTAxAhiQo+nKORdetY=; b=Ua42KeZMzooUNxr1lFzsKUO5nsXWr1/+FWQvnYfN2G/bngEz7iA0VKv6+gAUweVLT3 P9POp8d3oROSUjDUJEZiAuSVzd+Kj+dx5DCAO3hcKcovbJiDAlaz7rPewFB/CzHB6N4U yLvbsRDD9r99qQQKgeFeftmitOWSvxd3tS250iVrWfjsbKW+StIDHJpPj36CQFsK4cyM S5J8a9UcGuC7AFaVdW4+Wk8dwFD+rhoMcZM0PCFp1mOjTBHr40r1dYNWzEZzkd00GieV G/varvEPEvDaAd86/4od/TNR7oNX6hMlgy0iCll7pxzaQl195dTAAuxGrl+R6pYhXfpD arog== X-Gm-Message-State: APjAAAXHdHEjOBaoVJ+Dz394h+dx5jaPHEVYB4SJzVCpOw1K97r0ViDd 4Vj/WSh4ply8iYxzkd7JqvKWN2jfYgc= X-Google-Smtp-Source: APXvYqwn9AdO3crYERD3abWL2ZbnrscXjGtKAJ5cGCGoR9yWi4DBbSvV/vPbOzW59iwxWpZdWTztrw== X-Received: by 2002:adf:dcce:: with SMTP id x14mr24963489wrm.315.1553978755999; Sat, 30 Mar 2019 13:45:55 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id a9sm5903671wmb.30.2019.03.30.13.45.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 13:45:55 -0700 (PDT) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH 12/14] media: vicodec: set pixelformat V4L2_PIX_FMT_FWHT_STATELESS for stateless encoder Date: Sat, 30 Mar 2019 13:43:10 -0700 Message-Id: <20190330204311.107417-13-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190330204311.107417-1-dafna3@gmail.com> References: <20190330204311.107417-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP for stateless encoder, set the capture pixelformat to V4L2_PIX_FMT_FWHT_STATELESS and the pix info to pixfmt_stateless_fwht Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 6bfcd266ffc4..f042c4b618ba 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -895,8 +895,12 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, if (multiplanar) return -EINVAL; pix = &f->fmt.pix; - pix->pixelformat = ctx->is_enc ? V4L2_PIX_FMT_FWHT : - find_fmt(f->fmt.pix.pixelformat)->id; + if (!ctx->is_enc) + pix->pixelformat = find_fmt(f->fmt.pix.pixelformat)->id; + else if (ctx->is_stateless) + pix->pixelformat = V4L2_PIX_FMT_FWHT_STATELESS; + else + pix->pixelformat = V4L2_PIX_FMT_FWHT; pix->colorspace = ctx->state.colorspace; pix->xfer_func = ctx->state.xfer_func; pix->ycbcr_enc = ctx->state.ycbcr_enc; @@ -906,8 +910,12 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, if (!multiplanar) return -EINVAL; pix_mp = &f->fmt.pix_mp; - pix_mp->pixelformat = ctx->is_enc ? V4L2_PIX_FMT_FWHT : - find_fmt(pix_mp->pixelformat)->id; + if (!ctx->is_enc) + pix_mp->pixelformat = find_fmt(f->fmt.pix_mp.pixelformat)->id; + else if (ctx->is_stateless) + pix_mp->pixelformat = V4L2_PIX_FMT_FWHT_STATELESS; + else + pix_mp->pixelformat = V4L2_PIX_FMT_FWHT; pix_mp->colorspace = ctx->state.colorspace; pix_mp->xfer_func = ctx->state.xfer_func; pix_mp->ycbcr_enc = ctx->state.ycbcr_enc; @@ -1631,22 +1639,22 @@ static int vicodec_start_streaming(struct vb2_queue *q, state->stride = q_data->coded_width * info->bytesperline_mult; - if (ctx->is_stateless) { + if (!ctx->is_enc && ctx->is_stateless) { state->ref_stride = state->stride; return 0; } state->ref_stride = q_data->coded_width * info->luma_alpha_step; state->ref_frame.buf = kvmalloc(total_planes_size, GFP_KERNEL); - state->ref_frame.luma = state->ref_frame.buf; new_comp_frame = kvmalloc(ctx->comp_max_size, GFP_KERNEL); - if (!state->ref_frame.luma || !new_comp_frame) { - kvfree(state->ref_frame.luma); + if (!state->ref_frame.buf || !new_comp_frame) { + kvfree(state->ref_frame.buf); kvfree(new_comp_frame); vicodec_return_bufs(q, VB2_BUF_STATE_QUEUED); return -ENOMEM; } + state->ref_frame.luma = state->ref_frame.buf; /* * if state->compressed_frame was already allocated then * it contain data of the first frame of the new resolution @@ -1948,9 +1956,10 @@ static int vicodec_open(struct file *file) comp_size + sizeof(struct fwht_cframe_hdr); ctx->q_data[V4L2_M2M_DST] = ctx->q_data[V4L2_M2M_SRC]; if (ctx->is_enc) { - ctx->q_data[V4L2_M2M_DST].info = &pixfmt_fwht; - ctx->q_data[V4L2_M2M_DST].sizeimage = - comp_size + sizeof(struct fwht_cframe_hdr); + ctx->q_data[V4L2_M2M_DST].info = ctx->is_stateless ? + &pixfmt_stateless_fwht : &pixfmt_fwht; + ctx->q_data[V4L2_M2M_DST].sizeimage = comp_size + + sizeof(struct fwht_cframe_hdr); } else { ctx->q_data[V4L2_M2M_DST].info = info; ctx->q_data[V4L2_M2M_DST].sizeimage = raw_size; From patchwork Sat Mar 30 20:43:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10878593 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 0D72E1669 for ; Sat, 30 Mar 2019 20:46:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED5292880D for ; Sat, 30 Mar 2019 20:46:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1E5528918; Sat, 30 Mar 2019 20:46:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DC2B2880D for ; Sat, 30 Mar 2019 20:46:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730918AbfC3UqA (ORCPT ); Sat, 30 Mar 2019 16:46:00 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33771 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730571AbfC3Up7 (ORCPT ); Sat, 30 Mar 2019 16:45:59 -0400 Received: by mail-wr1-f66.google.com with SMTP id q1so6864028wrp.0 for ; Sat, 30 Mar 2019 13:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MwCbYlPB7RmKx965GxAhkkGCVi8TVyMw8A/MDOhQhs4=; b=L8/x54B/D8yiHY9koLQKsvrR/4Ky36bfQWDAoWb+pz/jlgy39Sq1IDvgAAFYQT8J02 Dbue74cHuceHXrnlX41xKeKDlt/6wIkAYFy9wpIs2rXCKMagYuhrJCTMT/0xBwxY6Q9J HwG1h7EMqstcOW9xz72tpHthznsNAFIkz9g4lSOnXgMtgEO9kE2d3DBksuylRWWHmUzQ 7oo4WaHxjPMNBVnHrr+jv4KPsAF52zFSVvWlpcFLrIPuU7lvtUxHTM8SB4SLVpCYhUy6 22Psn2nib0g5gwH/gvwSzVStWAclBx+nnhpuE+G5DUSbjCQTvgz9DmxHk19uKUJb3mlN hZoQ== 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=MwCbYlPB7RmKx965GxAhkkGCVi8TVyMw8A/MDOhQhs4=; b=qOPsBtDwzU/XnKU0FZjVYmP5disp4772syN8Ecq0SJAeXvtjd0GpwEv4FjaGJxjySS Ky6ceI68tYaTiYx75iNMexcWFz/x2KbR/jJVgDIYPAU7bs+xjHomhRnkjnwoEP0tvm+p XmCGbp1QdycyaoCmHgSiKvSkKuMv1U0JkMBE7yzsFml5zcTMpdTZSX/E9b/R/2KiJtz0 fWVM6fOi5J842JFZ03YLEyd3KINZsWOzRIKO03apsj+IQcMcYLBYbp5fyaWvbzfx8pu4 Wov1RVGnKGQ/7Bcbx4p0X3+4OemM+sBKJ+7SNoi1YnYiznS164PJ7OyMCOm7BI3r+y8q od9Q== X-Gm-Message-State: APjAAAVsEToUaTzN9RodkR/kA4ifSs4+VvvCIMDmJmOV62moVhxKBi7a W4hFjJHF7rzl0x1xwGx5nBJVx3oPy4Q= X-Google-Smtp-Source: APXvYqxRJ2/F8gYn0sFIf069rNQJ/JIn+SdIMvOvcmKqN3k4SRBsi0Jwgxzzo5eZddONTm3sCi+Btw== X-Received: by 2002:adf:e407:: with SMTP id g7mr24709025wrm.47.1553978757026; Sat, 30 Mar 2019 13:45:57 -0700 (PDT) Received: from localhost.localdomain (ip5f5ab07d.dynamic.kabel-deutschland.de. [95.90.176.125]) by smtp.gmail.com with ESMTPSA id a9sm5903671wmb.30.2019.03.30.13.45.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 13:45:56 -0700 (PDT) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH 13/14] media: vicodec: Add support for stateless encoder Date: Sat, 30 Mar 2019 13:43:11 -0700 Message-Id: <20190330204311.107417-14-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190330204311.107417-1-dafna3@gmail.com> References: <20190330204311.107417-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adjust the stateless API code to support both encoder and decoder. Signed-off-by: Dafna Hirschfeld --- drivers/media/platform/vicodec/vicodec-core.c | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index f042c4b618ba..3808e72b2361 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -280,29 +280,31 @@ static int device_process(struct vicodec_ctx *ctx, ctx->state.header.size = htonl(vb2_get_plane_payload(&src_vb->vb2_buf, 0)); - /* - * set the reference buffer from the reference timestamp - * only if this is a P-frame - */ - if (!(ntohl(ctx->state.header.flags) & FWHT_FL_I_FRAME)) { - struct vb2_buffer *ref_vb2_buf; - int ref_buf_idx; - struct vb2_queue *vq_cap = + if (!ctx->is_enc) { + /* + * set the reference buffer from the reference timestamp + * only if this is a P-frame + */ + if (!(ntohl(ctx->state.header.flags) & FWHT_FL_I_FRAME)) { + struct vb2_buffer *ref_vb2_buf; + int ref_buf_idx; + struct vb2_queue *vq_cap = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, - V4L2_BUF_TYPE_VIDEO_CAPTURE); + 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_buf_idx = vb2_find_timestamp(vq_cap, + ctx->state.ref_frame_ts, 0); + if (ref_buf_idx < 0) + return -EINVAL; - ref_vb2_buf = vq_cap->bufs[ref_buf_idx]; - if (ref_vb2_buf->state == VB2_BUF_STATE_ERROR) - ret = -EINVAL; - ctx->state.ref_frame.buf = + ref_vb2_buf = vq_cap->bufs[ref_buf_idx]; + if (ref_vb2_buf->state == VB2_BUF_STATE_ERROR) + ret = -EINVAL; + ctx->state.ref_frame.buf = vb2_plane_vaddr(ref_vb2_buf, 0); - } else { - ctx->state.ref_frame.buf = NULL; + } else { + ctx->state.ref_frame.buf = NULL; + } } } p_dst = vb2_plane_vaddr(&dst_vb->vb2_buf, 0); @@ -1722,7 +1724,7 @@ static void vicodec_stop_streaming(struct vb2_queue *q) if ((!V4L2_TYPE_IS_OUTPUT(q->type) && !ctx->is_enc) || (V4L2_TYPE_IS_OUTPUT(q->type) && ctx->is_enc)) { - if (!ctx->is_stateless) + if (!ctx->is_stateless || ctx->is_enc) kvfree(ctx->state.ref_frame.buf); ctx->state.ref_frame.buf = NULL; ctx->state.ref_frame.luma = NULL; @@ -1800,20 +1802,26 @@ static int vicodec_try_ctrl(struct v4l2_ctrl *ctrl) struct vicodec_ctx *ctx = container_of(ctrl->handler, struct vicodec_ctx, hdl); const struct v4l2_ctrl_fwht_params *params; - struct vicodec_q_data *q_dst = get_q_data(ctx, - V4L2_BUF_TYPE_VIDEO_CAPTURE); + struct vicodec_q_data *q_data; + + if (ctx->is_enc) + q_data = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); + else + q_data = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); switch (ctrl->id) { case V4L2_CID_MPEG_VIDEO_FWHT_PARAMS: params = ctrl->p_new.p_fwht_params; - if (params->width > q_dst->coded_width || + if (params->width > q_data->coded_width || params->width < MIN_WIDTH || - params->height > q_dst->coded_height || + params->height > q_data->coded_height || params->height < MIN_HEIGHT) return -EINVAL; + if (ctx->is_enc) + return 0; if (!validate_by_version(params->flags, params->version)) return -EINVAL; - if (!validate_stateless_params_flags(params, q_dst->info)) + if (!validate_stateless_params_flags(params, q_data->info)) return -EINVAL; return 0; default: