From patchwork Tue Dec 8 14:59:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 339749 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3761245jai; Tue, 8 Dec 2020 07:02:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwo/R5scsaI/1hQm+ckXUBq9+PR2B8q4W9NANgRxzdu0f7sxV9HkmIdgzKKubd9mQhnRiPs X-Received: by 2002:a05:6402:1045:: with SMTP id e5mr9079539edu.40.1607439777957; Tue, 08 Dec 2020 07:02:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607439777; cv=none; d=google.com; s=arc-20160816; b=OsoRRnazjJnhOeA2LUbVpwQsbO9x2aJpUNvRKNa0WA5Sp9AdlyU9OjMzvHLQCZE/Qe f2SlGfAgzmNh59dR9Q39mLTTNKCCS5UCR2123S3qJipB263WIEFGobg76pzQ5QdmVqgR gO//3pkxTtCDYCoS6IJTzIT+2UqqMWkqTN2o3j+fxMfzpXUgkZOPu21Hm7QbF8Vlky6q imrKB/JNUJujHEmaWYMHfNcoJk8Q/3IaUOg1N21FGYHrJtr5dUQcAjP7W9f6Ybpu3ET0 E9zvtscNJ8ZhBwGQ1VmVeXiF3Ax8vMHMATjJb8JwNHXR/k+4dkO3OMO8ihmhWIjTweLU owvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=j+YLOasW8YuUdzuHOZH72Yv1TWfSXfhlcWPLx1oOYs4=; b=zVr296wX7c3cbeaaH/QzE66FdTyg6F6CQ//UpBphKeZ2ntLii8ESKZzeZDkU5/F/OJ /AM4TokI1LG2ROJDGzVFbZoKfhkVOE0pbIlqpHi5dC6FDrSwOXWhUnf9Uc8bMHd+LLTp B881/kOsAAXw538aPHqZ8ZFF+SNcyk0wHO5kImS+85Hzf3c5ma31klRfOTWRw0bxVELK +4zsBGZYhN4s9DjekcR9Van1YPuoUZ8oApGk29w4AA83627iQHA42R1rTyzgt8VwiVXT 2KGT3x+q7VkOAUer6FW1AoJDQKhzgDitfFYdUkQs584wf0Y13Q9tR0YoY9sY8otvDqXd L6Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d5lAC0Nw; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si8507024ejk.142.2020.12.08.07.02.57; Tue, 08 Dec 2020 07:02:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d5lAC0Nw; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729892AbgLHPBa (ORCPT + 15 others); Tue, 8 Dec 2020 10:01:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729950AbgLHPB2 (ORCPT ); Tue, 8 Dec 2020 10:01:28 -0500 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6AEBC0611CA for ; Tue, 8 Dec 2020 07:00:08 -0800 (PST) Received: by mail-ej1-x641.google.com with SMTP id bo9so24923903ejb.13 for ; Tue, 08 Dec 2020 07:00:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j+YLOasW8YuUdzuHOZH72Yv1TWfSXfhlcWPLx1oOYs4=; b=d5lAC0NwTBwcfOe0jv09YCUT7qLyfp2JPYcqY8SLtfKKcVMeFynORTs+CBSrmYw5Tu mCLb4mQpr37JnTqLmXEaw75eEENGJpzQxsgRAtLx78UMt9qucis0VKy4QdCNAXgnkAHH uNXRAOqBjPKRgNBvLiP/h0H03bNkNojRdy3I8rBn8sEdgnSsN9iM5eCFGiNBRr7AkefI erOnfFW978ZkDy7WOB7bS+b2Eqn3JEfPkYrB7L9dj5lRhphju2nkB3nIie8lcT96Zc5j M7u5xeqs3JGYzPiQy5+rWGWc7114MpzPojOjEQaJY/aueSd5ASuDEyDaZZyv5x19VksI kOWA== 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=j+YLOasW8YuUdzuHOZH72Yv1TWfSXfhlcWPLx1oOYs4=; b=S/L4cRwQWajEpZ/DBCG/6ALTMgBJiFhOqdCGEM5xeU3c16+TFbvOOVk3+Vv9o0tTgx h3jSfjIHoKsbn1ag2wwScB5FRR9O90xlsVAcptwGNxxTd8OK50D0Asd0gUm/OfrZaMiH fPtw+0ZOYUoe9Gn9b4QkVznqnjHqUzS44Z5xP22/qVlClmlDbgH0hmOY6nk1ztx4nRok SQTO5wdlLuOHjXh4W4aMB6bKBLH1dpIu+Xjcq+VUi0Wko1RqBBUojYKExA0F8dxatEjs nYibUe+/73TXlL3+Do4NbCqoJcUcoHt0zDSnWahzBZZKvgIvOv068Xpdq80uOYqZWu7U 6owg== X-Gm-Message-State: AOAM531KgZIYWRPeMrPtPb5rjQ/9OA9R2yqeTirlBV7PLpjW468aK/Gj zdkUXL4HbPi9k+r4v3Rim1aSGA== X-Received: by 2002:a17:906:ce23:: with SMTP id sd3mr23768469ejb.69.1607439606404; Tue, 08 Dec 2020 07:00:06 -0800 (PST) Received: from localhost.localdomain (hst-221-90.medicom.bg. [84.238.221.90]) by smtp.gmail.com with ESMTPSA id qn4sm4968292ejb.50.2020.12.08.07.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 07:00:05 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Hans Verkuil , Ezequiel Garcia , Nicolas Dufresne , Stanimir Varbanov Subject: [PATCH v3 3/3] venus: venc: Add support for CLL and Mastering display controls Date: Tue, 8 Dec 2020 16:59:31 +0200 Message-Id: <20201208145931.6187-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201208145931.6187-1-stanimir.varbanov@linaro.org> References: <20201208145931.6187-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Create CLL and Mastering display colour volume v4l2 controls for encoder, add handling of HDR10 PQ SEI packet payloads for v4. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 3 ++ drivers/media/platform/qcom/venus/hfi_cmds.c | 8 +++++ .../media/platform/qcom/venus/hfi_helper.h | 20 +++++++++++++ drivers/media/platform/qcom/venus/venc.c | 29 +++++++++++++++++++ .../media/platform/qcom/venus/venc_ctrls.c | 16 +++++++++- 5 files changed, 75 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index f03ed427accd..2bf494020d18 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -256,6 +256,9 @@ struct venc_controls { u32 hevc; u32 vp9; } level; + + struct v4l2_ctrl_hdr10_cll_info cll; + struct v4l2_ctrl_hdr10_mastering_display mastering; }; struct venus_buffer { diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.c b/drivers/media/platform/qcom/venus/hfi_cmds.c index 7022368c1e63..081e5a816bca 100644 --- a/drivers/media/platform/qcom/venus/hfi_cmds.c +++ b/drivers/media/platform/qcom/venus/hfi_cmds.c @@ -1205,6 +1205,14 @@ pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt, pkt->shdr.hdr.size += sizeof(u32) + sizeof(*cu); break; } + case HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI: { + struct hfi_hdr10_pq_sei *in = pdata, *hdr10 = prop_data; + + memcpy(hdr10, in, sizeof(*hdr10)); + pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hdr10); + break; + } + case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE: case HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER: case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE: diff --git a/drivers/media/platform/qcom/venus/hfi_helper.h b/drivers/media/platform/qcom/venus/hfi_helper.h index 60ee2479f7a6..8e8dc6b5c855 100644 --- a/drivers/media/platform/qcom/venus/hfi_helper.h +++ b/drivers/media/platform/qcom/venus/hfi_helper.h @@ -506,6 +506,7 @@ #define HFI_PROPERTY_PARAM_VENC_VPX_ERROR_RESILIENCE_MODE 0x2005029 #define HFI_PROPERTY_PARAM_VENC_HIER_B_MAX_NUM_ENH_LAYER 0x200502c #define HFI_PROPERTY_PARAM_VENC_HIER_P_HYBRID_MODE 0x200502f +#define HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI 0x2005036 /* * HFI_PROPERTY_CONFIG_VENC_COMMON_START @@ -791,6 +792,25 @@ struct hfi_ltr_mark { u32 mark_frame; }; +struct hfi_mastering_display_colour_sei_payload { + u32 display_primaries_x[3]; + u32 display_primaries_y[3]; + u32 white_point_x; + u32 white_point_y; + u32 max_display_mastering_luminance; + u32 min_display_mastering_luminance; +}; + +struct hfi_content_light_level_sei_payload { + u32 max_content_light; + u32 max_pic_average_light; +}; + +struct hfi_hdr10_pq_sei { + struct hfi_mastering_display_colour_sei_payload mastering; + struct hfi_content_light_level_sei_payload cll; +}; + struct hfi_framesize { u32 buffer_type; u32 width; diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 1c61602c5de1..90d7f967cd54 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -588,6 +588,35 @@ static int venc_set_properties(struct venus_inst *inst) return ret; } + if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { + struct hfi_hdr10_pq_sei hdr10; + unsigned int c; + + ptype = HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI; + + for (c = 0; c < 3; c++) { + hdr10.mastering.display_primaries_x[c] = + ctr->mastering.display_primaries_x[c]; + hdr10.mastering.display_primaries_y[c] = + ctr->mastering.display_primaries_y[c]; + } + + hdr10.mastering.white_point_x = ctr->mastering.white_point_x; + hdr10.mastering.white_point_y = ctr->mastering.white_point_y; + hdr10.mastering.max_display_mastering_luminance = + ctr->mastering.max_display_mastering_luminance; + hdr10.mastering.min_display_mastering_luminance = + ctr->mastering.min_display_mastering_luminance; + + hdr10.cll.max_content_light = ctr->cll.max_content_light_level; + hdr10.cll.max_pic_average_light = + ctr->cll.max_pic_average_light_level; + + ret = hfi_session_set_property(inst, ptype, &hdr10); + if (ret) + return ret; + } + /* IDR periodicity, n: * n = 0 - only the first I-frame is IDR frame * n = 1 - all I-frames will be IDR frames diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media/platform/qcom/venus/venc_ctrls.c index cf860e6446c0..2e62666e3ff6 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -208,6 +208,12 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE: ctr->frame_skip_mode = ctrl->val; break; + case V4L2_CID_COLORIMETRY_HDR10_CLL_INFO: + ctr->cll = *ctrl->p_new.p_hdr10_cll; + break; + case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY: + ctr->mastering = *ctrl->p_new.p_hdr10_mastering; + break; default: return -EINVAL; } @@ -223,7 +229,7 @@ int venc_ctrl_init(struct venus_inst *inst) { int ret; - ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 33); + ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 35); if (ret) return ret; @@ -374,6 +380,14 @@ int venc_ctrl_init(struct venus_inst *inst) (1 << V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT)), V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED); + v4l2_ctrl_new_std_compound(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_COLORIMETRY_HDR10_CLL_INFO, + v4l2_ctrl_ptr_create(NULL)); + + v4l2_ctrl_new_std_compound(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY, + v4l2_ctrl_ptr_create(NULL)); + ret = inst->ctrl_handler.error; if (ret) goto err;