From patchwork Fri Oct 13 14:13:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 115777 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp781958qgn; Fri, 13 Oct 2017 07:13:43 -0700 (PDT) X-Received: by 10.98.206.68 with SMTP id y65mr1528245pfg.138.1507904022995; Fri, 13 Oct 2017 07:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507904022; cv=none; d=google.com; s=arc-20160816; b=Wal9N72f6Qnq/wgO1zx/tN/MuCVHMD+bc+59o9etFNd7t227K6+E5wBi0FXKFPBSWw KHbkqJHRwGpsWm7RItgUQXLsFQAeIaoOIjR3j8JAJO70EcI7x1G+BJmKiCBAxGHBQI0I zkr3F3y+j38kjjKyt7Vps5sFsQ/z2nj5sSdjZ9IYvRYE2YLudq4g/riq/YpAUIiMqeoy ebwMFREzztQ9qT2NeWjtG4CmDn7wfHh+eP0rp3jxJsgiFW9mLnwlbzqrwRBk4s80T5m+ COTm9tjUS4BYFOKuqm4dpvX2UYA8jeYpOPD4HZkD7ynYgYOpk7a3uvXu67HVCeI9NxN6 JvUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=JZ/J5IfPBPJaEK8JP++fpWOObksdOPOxMXiYpLBT8fg=; b=zM9OSZahYcKKBu84q2BH5ScEd9zUpLlcvGaGkzCnk+EHGyMjIS3IAWfMdqgpIZ1j3z tmOlBZGyE4/DXrbHKVNxfdctfISrsdtt6cTUuH0IyktfZcbYX/iXOfVUZsW84hzAHKkj 8BXRPMjvM8VRVbIiF3gmqePhQ5R+p4s3zSDbPkgcM60cDSDG0uGqwXMfmZcyLBovTcBd SFsZjQYhhRmq7C9nn33nfN1qcQNPYXkqm2J5M3pUiO1oy05jl6u3zM39vWl/BYGs5Itc KM6ATXhwKUiC4bdZqDGxpJGwxlywtgEJmvYH+97xMpJ5Rpcjv5lNkegE2U26vRt9GdJ3 kUYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bYVeoG4n; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d5si623549pgu.305.2017.10.13.07.13.42; Fri, 13 Oct 2017 07:13:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bYVeoG4n; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753720AbdJMONl (ORCPT + 11 others); Fri, 13 Oct 2017 10:13:41 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:56643 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753415AbdJMONk (ORCPT ); Fri, 13 Oct 2017 10:13:40 -0400 Received: by mail-wm0-f54.google.com with SMTP id l68so22066159wmd.5 for ; Fri, 13 Oct 2017 07:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=CrjQIjVd5bpfy1J9NJWrbIbzkFSKcFQeA1RNhRTUzDI=; b=bYVeoG4nLZfvHwsmU223zq+ffFQZm00tvWMMD5mM5Bts5MA6v9EEYQt1x8Mfm3xlg9 9G6YlO89iBF52ByToPTk4Hz4b4pkclLSpZUpAXzO9EAdUmGHjARvVcYTzU4Bvr1bRFuz Vf/mC+uoI+1Xn5O3fS0ytPqYRkl9KyMEuj5PY= 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=CrjQIjVd5bpfy1J9NJWrbIbzkFSKcFQeA1RNhRTUzDI=; b=oQriBcnCGEKV7RzkUj1r+F5FPaR7tsNMK3NPFiLOSXNMHc7PycZ2OyX5EQ/U+z5xWz 5EaGCiSnSSOTOtwJ+PkVceUTOJTI1+BBNw4TmlHzzta74ELQBsEK6LiI0nKQUKRZlaxV XzRkR1v5/TVkjAGhNmNWqAnu1QaaUEsMrKschRYRJ5CyBHYms5pxkmDy3VP9RIMRuWsW ECl8lQorjm5b1gMv+/IwH9uK9TG7uv7HsTVFFB+EE9bp3ThqeETBrhaK9KztBEV13bs9 YcyhjxpGlEOK7FGGsUHld43ZzcvxuSQOBCKCCZLuyTl9CoVayQ2e0JEH2H/jN0e8ICA1 Gllw== X-Gm-Message-State: AMCzsaXfocFE+R55tS+5VVB7OAsVXcAf1XGaLQVmFWfgA3AEnCujIb+V I0Aq8BLKmCrePgRgSNjn4tesQRSDmOE= X-Google-Smtp-Source: ABhQp+QS4YeYGKTIoKzbEzx9dnJNTB+TB5jWMpwLdn4VrPCj0Eg+5XwmkqPUysiDRBFK/Howuc1kGQ== X-Received: by 10.28.152.5 with SMTP id a5mr1733109wme.131.1507904019187; Fri, 13 Oct 2017 07:13:39 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 10sm1879322wmy.35.2017.10.13.07.13.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 07:13:38 -0700 (PDT) From: Stanimir Varbanov To: Hans Verkuil Cc: Nicolas Dufresne , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Stanimir Varbanov Subject: [PATCH] venus: reimplement decoder stop command Date: Fri, 13 Oct 2017 17:13:17 +0300 Message-Id: <20171013141317.23211-1-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.11.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This addresses the wrong behavior of decoder stop command by rewriting it. These new implementation enqueue an empty buffer on the decoder input buffer queue to signal end-of-stream. The client should stop queuing buffers on the V4L2 Output queue and continue queuing/dequeuing buffers on Capture queue. This process will continue until the client receives a buffer with V4L2_BUF_FLAG_LAST flag raised, which means that this is last decoded buffer with data. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 2 -- drivers/media/platform/qcom/venus/helpers.c | 7 ------ drivers/media/platform/qcom/venus/hfi.c | 1 + drivers/media/platform/qcom/venus/vdec.c | 34 +++++++++++++++++++---------- 4 files changed, 24 insertions(+), 20 deletions(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index cba092bcb76d..a0fe80df0cbd 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -194,7 +194,6 @@ struct venus_buffer { * @fh: a holder of v4l file handle structure * @streamon_cap: stream on flag for capture queue * @streamon_out: stream on flag for output queue - * @cmd_stop: a flag to signal encoder/decoder commands * @width: current capture width * @height: current capture height * @out_width: current output width @@ -258,7 +257,6 @@ struct venus_inst { } controls; struct v4l2_fh fh; unsigned int streamon_cap, streamon_out; - bool cmd_stop; u32 width; u32 height; u32 out_width; diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index cac429be5609..6a85dd10ecd4 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -626,13 +626,6 @@ void venus_helper_vb2_buf_queue(struct vb2_buffer *vb) mutex_lock(&inst->lock); - if (inst->cmd_stop) { - vbuf->flags |= V4L2_BUF_FLAG_LAST; - v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_DONE); - inst->cmd_stop = false; - goto unlock; - } - v4l2_m2m_buf_queue(m2m_ctx, vbuf); if (!(inst->streamon_out & inst->streamon_cap)) diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index c09490876516..ba29fd4d4984 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -484,6 +484,7 @@ int hfi_session_process_buf(struct venus_inst *inst, struct hfi_frame_data *fd) return -EINVAL; } +EXPORT_SYMBOL_GPL(hfi_session_process_buf); irqreturn_t hfi_isr_thread(int irq, void *dev_id) { diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index da611a5eb670..c9e9576bb08a 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -469,8 +469,14 @@ static int vdec_subscribe_event(struct v4l2_fh *fh, static int vdec_try_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd) { - if (cmd->cmd != V4L2_DEC_CMD_STOP) + switch (cmd->cmd) { + case V4L2_DEC_CMD_STOP: + if (cmd->flags & V4L2_DEC_CMD_STOP_TO_BLACK) + return -EINVAL; + break; + default: return -EINVAL; + } return 0; } @@ -479,6 +485,7 @@ static int vdec_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd) { struct venus_inst *inst = to_inst(file); + struct hfi_frame_data fdata = {0}; int ret; ret = vdec_try_decoder_cmd(file, fh, cmd); @@ -486,12 +493,23 @@ vdec_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd) return ret; mutex_lock(&inst->lock); - inst->cmd_stop = true; - mutex_unlock(&inst->lock); - hfi_session_flush(inst); + /* + * Implement V4L2_DEC_CMD_STOP by enqueue an empty buffer on decoder + * input to signal EOS. + */ + if (!(inst->streamon_out & inst->streamon_cap)) + goto unlock; + + fdata.buffer_type = HFI_BUFFER_INPUT; + fdata.flags |= HFI_BUFFERFLAG_EOS; + fdata.device_addr = 0xdeadbeef; - return 0; + ret = hfi_session_process_buf(inst, &fdata); + +unlock: + mutex_unlock(&inst->lock); + return ret; } static const struct v4l2_ioctl_ops vdec_ioctl_ops = { @@ -718,7 +736,6 @@ static int vdec_start_streaming(struct vb2_queue *q, unsigned int count) inst->reconfig = false; inst->sequence_cap = 0; inst->sequence_out = 0; - inst->cmd_stop = false; ret = vdec_init_session(inst); if (ret) @@ -807,11 +824,6 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type, vb->timestamp = timestamp_us * NSEC_PER_USEC; vbuf->sequence = inst->sequence_cap++; - if (inst->cmd_stop) { - vbuf->flags |= V4L2_BUF_FLAG_LAST; - inst->cmd_stop = false; - } - if (vbuf->flags & V4L2_BUF_FLAG_LAST) { const struct v4l2_event ev = { .type = V4L2_EVENT_EOS };