Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1539275ima; Thu, 25 Oct 2018 00:24:16 -0700 (PDT) X-Google-Smtp-Source: AJdET5fyhqK2XTejW5hVOkjGAlUb3gExTv9F0jfBdHT9Lo1rBgzO7b1phE4NR5/mk8ke9sdyMVoa X-Received: by 2002:a63:6848:: with SMTP id d69-v6mr422339pgc.113.1540452256714; Thu, 25 Oct 2018 00:24:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540452256; cv=none; d=google.com; s=arc-20160816; b=FYXLuFN9ksOxLU5OZWgWM/H2C7rccGjOzLOBti8PB/U7qvKi+mGQde3QPRB76urqA2 2dfMafyzd+kn8bl/X7f9ibNPGu3Tu7FSyUxBOVoK1GiNsR/lPTxWWZFHDY8XTV5KlyU6 Wstv+AYJTtlpI7I0H/Bi3NmHcSo9NhipITNj8tC5F3FaFTI+i2UkWkzW3V3oPOZ8vP3O XVxbr6obOzOJtEaMlTOcCJMAwjcfYOmGx/HJF5/NXoekmPFlDpxt5QGeOhIeT/cT1cKi EReoXeUCUzfLIrjXMWQ04S4OSkEnPmwnakt/GzABvQGovvE99JQiuk7dbGRWXegvtjsR t5ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature; bh=gQP0ncsJXP6q+kP/m78cM78LwQ8I1Xu6so7ugHVMEco=; b=pBxfDWqOXb+qDxkZLrgv/AQZ1IrF53IS34avhIDYLH4GpsDG8rhAFK83VYqQe7xDvP v/Jw+er+PGtNZm/PpEFwH1gS87PRKH3MoqFxAVSi/9p/JyD4P2YmUELJEtzs44ajV/GQ zt0r7h+i+j7cL5NFdD354zJPHC1+ggPLfGnB+AJY3HT2s5EAA02DJgJyJid408GaGf3c EQsEThEE8EInmDyKHH1+pt0t87oamDNOD3cbM8tHPaU2gxkNtVtKUdgVQqZul2Kd1A4h pR75I4WBmjQKYT2kacEeMW62Qepr/nBegSJHThAEoBNF4c3NstM136oq6s8fnwklSFQo grQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=jrWg2tn+; dkim=pass header.i=@codeaurora.org header.s=default header.b=jrWg2tn+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q25-v6si2268455pgd.357.2018.10.25.00.24.00; Thu, 25 Oct 2018 00:24:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=jrWg2tn+; dkim=pass header.i=@codeaurora.org header.s=default header.b=jrWg2tn+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726819AbeJYPzI (ORCPT + 99 others); Thu, 25 Oct 2018 11:55:08 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:37648 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726465AbeJYPzH (ORCPT ); Thu, 25 Oct 2018 11:55:07 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id BB04D60C48; Thu, 25 Oct 2018 07:23:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1540452217; bh=P5qrV/27JOt4/3qTEupaSGD5er/xGC2QBt9aJo3H+CA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jrWg2tn+UJ2utpDxGCrn0I2nU0JQ9aEM80YQ+riLw2n0NpdvbVZamv0rYGBd1MXm4 wXR9tE2m0WYUgY82iKPZ4cK1t0BC0tRhg0rODel9XjLfK0HhQjRtqFx2zlB3IcEiwV 8kzsJXltswtqtPS42Cc0ySIKRYHYbCw5uaZ6aGnU= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 0D8C160316; Thu, 25 Oct 2018 07:23:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1540452217; bh=P5qrV/27JOt4/3qTEupaSGD5er/xGC2QBt9aJo3H+CA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jrWg2tn+UJ2utpDxGCrn0I2nU0JQ9aEM80YQ+riLw2n0NpdvbVZamv0rYGBd1MXm4 wXR9tE2m0WYUgY82iKPZ4cK1t0BC0tRhg0rODel9XjLfK0HhQjRtqFx2zlB3IcEiwV 8kzsJXltswtqtPS42Cc0ySIKRYHYbCw5uaZ6aGnU= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 25 Oct 2018 12:53:37 +0530 From: Vikash Garodia To: Tomasz Figa Cc: mgottam@codeaurora.org, Stanimir Varbanov , Hans Verkuil , Mauro Carvalho Chehab , Linux Media Mailing List , Linux Kernel Mailing List , linux-arm-msm , Alexandre Courbot , linux-media-owner@vger.kernel.org Subject: Re: [PATCH v2] media: venus: add support for key frame In-Reply-To: References: <1540389162-30358-1-git-send-email-mgottam@codeaurora.org> Message-ID: <86344762e1eeab8fe8a940a1bfffa2c1@codeaurora.org> X-Sender: vgarodia@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-10-24 20:02, Tomasz Figa wrote: > On Wed, Oct 24, 2018 at 10:52 PM Malathi Gottam > wrote: >> >> When client requests for a keyframe, set the property >> to hardware to generate the sync frame. >> >> Signed-off-by: Malathi Gottam >> --- >> drivers/media/platform/qcom/venus/venc_ctrls.c | 16 +++++++++++++++- >> 1 file changed, 15 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c >> b/drivers/media/platform/qcom/venus/venc_ctrls.c >> index 45910172..6c2655d 100644 >> --- a/drivers/media/platform/qcom/venus/venc_ctrls.c >> +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c >> @@ -79,8 +79,10 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) >> { >> struct venus_inst *inst = ctrl_to_inst(ctrl); >> struct venc_controls *ctr = &inst->controls.enc; >> + struct hfi_enable en = { .enable = 1 }; >> u32 bframes; >> int ret; >> + u32 ptype; >> >> switch (ctrl->id) { >> case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: >> @@ -173,6 +175,15 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) >> >> ctr->num_b_frames = bframes; >> break; >> + case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME: >> + if (inst->streamon_out && inst->streamon_cap) { >> + ptype = >> HFI_PROPERTY_CONFIG_VENC_REQUEST_SYNC_FRAME; >> + ret = hfi_session_set_property(inst, ptype, >> &en); >> + >> + if (ret) >> + return ret; >> + } >> + break; > > This is still not the right way to handle this. > > Please see the documentation of this control [1]: > > "V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME (button) > Force a key frame for the next queued buffer. Applicable to encoders. > This is a general, codec-agnostic keyframe control." > > Even if the driver is not streaming, it must remember that the > keyframe was requested for next buffer. The next time userspace QBUFs > an OUTPUT buffer, it should ask the hardware to encode that OUTPUT > buffer into a keyframe. That's correct. Driver can cache the client request and set it when the hardware is capable of accepting the property. Still the issue having the requested OUTPUT buffer to be encoded as sync frame will be there. If there are few frames queued before streamon, driver will only keep a note that it has to set the request for keyframe, but not the exact one which was requested. > [1] > https://www.kernel.org/doc/html/latest/media/uapi/v4l/extended-controls.html?highlight=v4l2_cid_mpeg_video_force_key_frame > > But generally, the proper modern way for the userspace to request a > keyframe is to set the V4L2_BUF_FLAG_KEYFRAME flag in the > vb2_buffer_flag when queuing an OUTPUT buffer. It's the only > guaranteed way to ensure that the keyframe will be encoded exactly for > the selected frame. (The V4L2 control API doesn't guarantee any > synchronization between controls and buffers itself.) This is a better way to handle it to ensure exact buffer gets encoded as sync frame. > Best regards, > Tomasz