From patchwork Mon Mar 19 14:29:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 10292405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B78E6600F6 for ; Mon, 19 Mar 2018 14:29:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A394F2905E for ; Mon, 19 Mar 2018 14:29:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 984AD291AC; Mon, 19 Mar 2018 14:29:38 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 55A3E2905E for ; Mon, 19 Mar 2018 14:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933122AbeCSO3g (ORCPT ); Mon, 19 Mar 2018 10:29:36 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:34533 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932708AbeCSO3f (ORCPT ); Mon, 19 Mar 2018 10:29:35 -0400 Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20180319142933epoutp0387e204da1a30d80ee5c6d6501af1e298~dWLKiXz6Q0828008280epoutp03U; Mon, 19 Mar 2018 14:29:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20180319142933epoutp0387e204da1a30d80ee5c6d6501af1e298~dWLKiXz6Q0828008280epoutp03U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1521469773; bh=Wfj7EoA8uspFKvSTo3WtOMt/sAqJ9j2z0CaOI4YogCQ=; h=From:To:Cc:Subject:Date:References:From; b=Q6ywZ1Yq3pYB81ZTbEa2RAqIHZSxlQczs+T4v85RSBdz+bblj9Z4xK49gHbiOKPe3 9eau4sxNWrS9p9mb0gCWhUkDMNU7dYPHf/4WD1FUTDgRQEmny4c/T14LkXWrCsr9gS aWdTbdkhCi4ADdCFKZlh3ULeVbv2BMOKfAVBBMYw= Received: from epsmges2p4.samsung.com (unknown [182.195.42.72]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20180319142932epcas2p42d7e489bc1e72996b9149e6e65253af5~dWLJlgfae0450304503epcas2p4U; Mon, 19 Mar 2018 14:29:32 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id 75.2B.04080.C49CFAA5; Mon, 19 Mar 2018 23:29:32 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20180319142931epcas2p38fdca1ec6e4a5e5dd654d3ca3ed3577e~dWLIo_nmz0238202382epcas2p3r; Mon, 19 Mar 2018 14:29:31 +0000 (GMT) X-AuditID: b6c32a48-9adff70000000ff0-d0-5aafc94c06da Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id E4.17.03890.B49CFAA5; Mon, 19 Mar 2018 23:29:31 +0900 (KST) Received: from AMDC3061.digital.local ([106.116.147.40]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P5U00JN5DKUB7B0@mmp1.samsung.com>; Mon, 19 Mar 2018 23:29:31 +0900 (KST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, smitha.t@samsung.com, a.hajda@samsung.com, linux-samsung-soc@vger.kernel.org, Sylwester Nawrocki Subject: [PATCH] s5p-mfc: Ensure HEVC QP controls range is properly updated Date: Mon, 19 Mar 2018 15:29:16 +0100 Message-id: <20180319142916.21489-1-s.nawrocki@samsung.com> X-Mailer: git-send-email 2.14.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBIsWRmVeSWpSXmKPExsWy7bCmha7PyfVRBifP8FvcWneO1eLU5GdM Fj0btrJazDi/j8ni8Jt2Vou7e7YxOrB59G1ZxejxeZOcx6mvn9kDmKO4bFJSczLLUov07RK4 Mpbv/sBWsFakYv2UG2wNjLMEuxg5OSQETCQu/3rJ3sXIxSEksINRYvvvDijnO6PEsg+XmWCq bp9+yQSR2M0o8fbKZCjnF6PEsSnPWUCq2AQMJXqP9jGC2CIC8hJPem+wgdjMAlMZJaYulAWx hQW8JaZ0XmcFsVkEVCWWL78O1ssrYC1x7MkjqG3yEu8X3GeEsO+ySuzY4QRhu0hsP/EaKi4s 8er4FnYIW1ri2aqNUPFqic62LrAXJARaGCX+TLvEBpGwljh8/CIrxEF8Eh2H/wIVcQDFeSU6 2oQgSjwkpu6dDlXuKLHkzSSw24QEYiVur5zHOoFRcgEjwypGsdSC4tz01GKjAhO94sTc4tK8 dL3k/NxNjOD40vLYwXjgnM8hRgEORiUe3oWS66OEWBPLiitzDzFKcDArifA+vbIuSog3JbGy KrUoP76oNCe1+BCjNAeLkjhvW4BLlJBAemJJanZqakFqEUyWiYNTqoFxP8vj79W5b40K33fO m3UwRU2muJths5PCjm1+rocUdjzv+81/QXBJ7V7zv8w7goqnBe/xtf0ta2Vx9q/+iuy2bzJ9 Dcncm4qPBp1waBLVWjqb2Uw06b9Z1QOBjk9OC6XPGD+cdkH0Q8tGF9lJASf3WkTEqvR8iZcP ufbrX//S7OS1P51nzyhVYinOSDTUYi4qTgQAGVzu36sCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGJMWRmVeSWpSXmKPExsVy+t9jAV3vk+ujDC7c5rO4te4cq8Wpyc+Y LHo2bGW1mHF+H5PF4TftrBZ392xjdGDz6NuyitHj8yY5j1NfP7MHMEdx2aSk5mSWpRbp2yVw ZSzf/YGtYK1IxfopN9gaGGcJdjFyckgImEjcPv2SqYuRi0NIYCejxJlJm5ghnF+MEn+/7mAH qWITMJToPdrHCGKLCMhLPOm9wQZSxCwwmVFi9bkWsCJhAW+JKZ3XWUFsFgFVieXLr7OA2LwC 1hLHnjxiglgnL/F+wX3GCYxcCxgZVjFKphYU56bnFhsVGOWllusVJ+YWl+al6yXn525iBPp+ 22Gt/h2Mj5fEH2IU4GBU4uF1OLouSog1say4MvcQowQHs5II79MrQCHelMTKqtSi/Pii0pzU 4kOM0hwsSuK8/PnHIoUE0hNLUrNTUwtSi2CyTBycUg2MnG9XfpvEYhX/uz400P8h45lJrdPl Y6bvDfS+8bpZ7oMkW7tOzyalIoOyRD9B9VC+O3XH537f32/C/lDbjWvWlR3bi7j+FZm0vs// aCi55PZrlfYZ9os+z5s++8AWzj0uaV7/2J5J+k+ZLfa/8U/tRY9ShY7Q1M0qv+d17TNUze32 Z1jHdOGEEktxRqKhFnNRcSIA9/12dfkBAAA= X-CMS-MailID: 20180319142931epcas2p38fdca1ec6e4a5e5dd654d3ca3ed3577e X-Msg-Generator: CA CMS-TYPE: 102P X-CMS-RootMailID: 20180319142931epcas2p38fdca1ec6e4a5e5dd654d3ca3ed3577e X-RootMTR: 20180319142931epcas2p38fdca1ec6e4a5e5dd654d3ca3ed3577e References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When value of V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP or V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP controls is changed we should update range of a set of HEVC quantization parameter v4l2 controls as specified in the HEVC controls documentation. Signed-off-by: Sylwester Nawrocki Acked-by: Hans Verkuil --- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c index 6c80ebc5dbcc..810dabe2f1b9 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c @@ -1773,6 +1773,42 @@ static inline int vui_sar_idc(enum v4l2_mpeg_video_h264_vui_sar_idc sar) return t[sar]; } +/* + * Update range of all HEVC quantization parameter controls that depend on the + * V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP, V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP controls. + */ +static void __enc_update_hevc_qp_ctrls_range(struct s5p_mfc_ctx *ctx, + int min, int max) +{ + static const int __hevc_qp_ctrls[] = { + V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_QP, + V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_QP, + V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_QP, + V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L0_QP, + V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L1_QP, + V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L2_QP, + V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L3_QP, + V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L4_QP, + V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L5_QP, + V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L6_QP, + }; + struct v4l2_ctrl *ctrl = NULL; + int i, j; + + for (i = 0; i < ARRAY_SIZE(__hevc_qp_ctrls); i++) { + for (j = 0; j < ARRAY_SIZE(ctx->ctrls); j++) { + if (ctx->ctrls[j]->id == __hevc_qp_ctrls[i]) { + ctrl = ctx->ctrls[j]; + break; + } + } + if (WARN_ON(!ctrl)) + break; + + __v4l2_ctrl_modify_range(ctrl, min, max, ctrl->step, min); + } +} + static int s5p_mfc_enc_s_ctrl(struct v4l2_ctrl *ctrl) { struct s5p_mfc_ctx *ctx = ctrl_to_ctx(ctrl); @@ -2038,9 +2074,13 @@ static int s5p_mfc_enc_s_ctrl(struct v4l2_ctrl *ctrl) break; case V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP: p->codec.hevc.rc_min_qp = ctrl->val; + __enc_update_hevc_qp_ctrls_range(ctx, ctrl->val, + p->codec.hevc.rc_max_qp); break; case V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP: p->codec.hevc.rc_max_qp = ctrl->val; + __enc_update_hevc_qp_ctrls_range(ctx, p->codec.hevc.rc_min_qp, + ctrl->val); break; case V4L2_CID_MPEG_VIDEO_HEVC_LEVEL: p->codec.hevc.level_v4l2 = ctrl->val;