From patchwork Mon Nov 23 23:02:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 330692 Delivered-To: patch@linaro.org Received: by 2002:a17:907:2110:0:0:0:0 with SMTP id qn16csp3905760ejb; Mon, 23 Nov 2020 15:05:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJycwdC3r3ZGF3TK0O5gsOmwuHBs5nQDM4M5Pca/fpP0/ATbB+H+c1ozTaYvY2daEWMiuDxL X-Received: by 2002:a05:6402:54c:: with SMTP id i12mr1491891edx.9.1606172722502; Mon, 23 Nov 2020 15:05:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606172722; cv=none; d=google.com; s=arc-20160816; b=jdBPeGpNR5i73SipTE7ZA5wwgt3be5bE5rBICFs46Omc1sHX/LzYxLEK4mCkWx6Cmz mBzpxo285ipQOWB84JGfm1x2wR0uaAT3UO8v85Nq5x9kW2JZYOoSTeG7qAg6ie3D/i3k StFvJuzQiyyPPTDmquetjcmfqY1UutF1O+vzCxE5qfdpsRxeht00XqJ20AopNh/SS8Gz Y9MzFUR5c4t0xNFCtp9MEZzzUerU6XF3UNxRqRemz8MyfLWNfqGl27HN7r9CuDwOUpgW 9ZPij5mXcD4B/Vx6nGNDTgnXCvRljSz3uOqRrwzv9SxxSCvy+cCWNWF86KYr8mMCSY9n hRiA== 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=Ig5qutKRJGU1yXjmQCggg+HJKA/iCr5AyEcACinSfrY=; b=0TtfsK6TYzREiIz23hIN4F6w8AdED7cAqhU6KLU1lpK2aHV9nudFTgChrrwkWCZism /J+QjXtCssUn0aZxvyHfBia377tEOvLB3lYGyDIqRS3nvpTn3xB1STSemZngtWv/TVXD UFuSteJVIvJrf+FoGxxn4Z2VEwCMJWLfkoY1xZwSyO44C2DB8rP5owSk5jU9Fd/CTZBK RRQZgPYAzJZjukZ8gqGV9svt32aPo7PdansL+ChZZEZc8lvRm3AlNOON8dveWDL9YRuv m5ZrlFAgcslRsQzYNwf85mOVSB1yCrMp2v65kGrRvmsjlopTeHPIs2Sbl5LXArAUn887 UW8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UpqUn136; 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 q2si4997217ejd.502.2020.11.23.15.05.22; Mon, 23 Nov 2020 15:05:22 -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=UpqUn136; 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 S2388199AbgKWXD0 (ORCPT + 15 others); Mon, 23 Nov 2020 18:03:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388167AbgKWXD0 (ORCPT ); Mon, 23 Nov 2020 18:03:26 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 344FEC0613CF for ; Mon, 23 Nov 2020 15:03:24 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id i2so1414670wrs.4 for ; Mon, 23 Nov 2020 15:03:24 -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=Ig5qutKRJGU1yXjmQCggg+HJKA/iCr5AyEcACinSfrY=; b=UpqUn136TPn1vBGfXQ9TvI3oBkyqkcEE6GJqfE2pgB0KAB5lkuSHgzxEy5V3hUdSzT MKI1YZyMdpR6DEmEpgpI6sfJ9paUDEmAZHKrpnBC8KcjANSVDJSPrwapCUqZRsx1HHYs zp1BMzdQBqINhyJrE7XHlA2KbDBo9XXAOm4YZAhYETz/HdeH0q6u3vpksjMgZLl9Jm/f 22MWOyw5c5ycdQwTFH3YXH+px8GMMYkVIo8qxKfr8OHnjJz5qFPOCmbyRzBfhaZYubuG DLUp1VO7kR/wZSWD2m82MwY7CI8VHap8AnpXvVU0gQb1JoHxRwUXe1l3BHKANPfvOONd LNSg== 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=Ig5qutKRJGU1yXjmQCggg+HJKA/iCr5AyEcACinSfrY=; b=Yvuy7o+C37EJjrsgRftzCG/VVfTEbRhf7l3bWS3ZojVH1lEOqiyzYn6KRqhw9MmFH5 XEIY8yh9ebk0BHT/4byfpdRUw5g3zZFD6A9uAX1d8TLXHozbU/kaV+ZhFLZKLMUNTkZg gLSBt6GYNz9Q4g0VaVnioSH7wIwHiWSGPKSgwt+CFufDuYvAJQ3du3MHEwJ/WKNIPRT6 Xx4SnDVMmxUOIkgn5JlhAKFgy/RPEImCw4Hw1LnKtiFLwaOa7Nk3AZGOzr11P3P77b6E jcJdrerNETFTSdM5VRR8sqZ7HIgYSmHqw6UXOBGWfA24x3iuYjdozr3OCnyS01Nj8hTv lvWg== X-Gm-Message-State: AOAM533Surmo2ZmODOqsdRuJUw2KRt44nU00wx0fwYdmOOghcseCO7mW 4R9zYa46R90wlI4SpiGW2JgSeA== X-Received: by 2002:a5d:448b:: with SMTP id j11mr1965244wrq.236.1606172602975; Mon, 23 Nov 2020 15:03:22 -0800 (PST) Received: from localhost.localdomain (hst-221-74.medicom.bg. [84.238.221.74]) by smtp.gmail.com with ESMTPSA id q66sm1501463wme.6.2020.11.23.15.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 15:03:22 -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 v2 3/3] venus: venc: Add support for CLL and Mastering display controls Date: Tue, 24 Nov 2020 01:02:57 +0200 Message-Id: <20201123230257.31690-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201123230257.31690-1-stanimir.varbanov@linaro.org> References: <20201123230257.31690-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 3bc129a4f817..3ae6cd2b8d31 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -245,6 +245,9 @@ struct venc_controls { u32 profile; u32 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 0bf92cc21f3a..daeaca30e9e3 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -587,6 +587,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_luminance; + hdr10.mastering.min_display_mastering_luminance = + ctr->mastering.min_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 0708b3b89d0c..87ba0cf9f37e 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -198,6 +198,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_MPEG_VIDEO_HDR10_CLL_INFO: + ctr->cll = *ctrl->p_new.p_hdr10_cll; + break; + case V4L2_CID_MPEG_VIDEO_HDR10_MASTERING_DISPLAY: + ctr->mastering = *ctrl->p_new.p_hdr10_mastering; + break; default: return -EINVAL; } @@ -213,7 +219,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; @@ -364,6 +370,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_MPEG_VIDEO_HDR10_CLL_INFO, + v4l2_ctrl_ptr_create(NULL)); + + v4l2_ctrl_new_std_compound(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_HDR10_MASTERING_DISPLAY, + v4l2_ctrl_ptr_create(NULL)); + ret = inst->ctrl_handler.error; if (ret) goto err;