From patchwork Wed Jan 20 09:26:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 366973 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp368618jam; Wed, 20 Jan 2021 03:22:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzY6B7+3G3SPn+/u8mil46TlQQMaBl9YRRQa9beh3aUSLCye80ZvTriqPNGzujaoukyhlaE X-Received: by 2002:a17:907:3f29:: with SMTP id hq41mr5897831ejc.227.1611141737855; Wed, 20 Jan 2021 03:22:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611141737; cv=none; d=google.com; s=arc-20160816; b=W786k71uAmSy989EcFIGSPBEHKxtLkEHLwp1GFmFTte5FhVUgBOoDDqVZ0lzBSK12U QrKCLUbr2h/BMzadiWV6QxHsmfp4mxNvw8vZkojGiBPmqzZdkW0JkcW41uq6We//B45o +FO9W4kDirOAi1PUFchuuqyZV3iEzg8GpNpgSyJLD09slMVMl5DWm9d/SrmD9duXi6Sz 1iFjCwYeTpSBl7+YfeJIGGgiIrVW/8GU+kZFGB4BtOS+Gxm9loHG8GECH2ozO5xYEoq8 jx3PgnurYsVBNEL8He7GuJg4U38E6I8hlprpc8ZI8i7wlA4s8em5n5W+X4jnM/jbeCWU iFfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6MiTsU3N2AEa1ZXLRORW5cxTPfFrxekkDKqSBZREPFg=; b=EMWqcnDNOY/DJAeLu3Bo09cip2AMZ7DTcE5sTx7hJY5h69YZi62wLoB4iih8gR9yLl QKEevR8HfQ55+TDuo33sDDPGKWNIIxoRJYWozGIDnbI+Gkkzamll3qN1xU/A/iyKmsVc /om4aGJAGgg2L+SInpWVG/o9b9oCFCcAY67/+puH9yEI7mC4ozxjU/uFieuUfuTHWRIk eo8Ex1BxU/m7xarK82rIAdxxwGVqD/BEMk31x+9//6sLb3al3afM5JnnjnGMTtBWWDx2 v/o3fzzKQ1O1Uc8h46NNKidk6ww7C6LKj6yzyrWMTAhkyBYWd967VzE2bIwrlHw6puXn II4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lfSJbpRh; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-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 lt6si541295ejb.133.2021.01.20.03.22.17; Wed, 20 Jan 2021 03:22:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-media-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=lfSJbpRh; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-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 S1733128AbhATKg2 (ORCPT + 3 others); Wed, 20 Jan 2021 05:36:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731335AbhATJ2o (ORCPT ); Wed, 20 Jan 2021 04:28:44 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FE73C06179F for ; Wed, 20 Jan 2021 01:26:39 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id b5so16117816ejv.4 for ; Wed, 20 Jan 2021 01:26:39 -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 :mime-version:content-transfer-encoding; bh=6MiTsU3N2AEa1ZXLRORW5cxTPfFrxekkDKqSBZREPFg=; b=lfSJbpRhrQiT4g6I14nJUgeGqQvOqM29Xz7/bAZ/PIuZedSRZDj2QPpgqc+5DjCVqF lOnL4vlKTAycvbcio8+ic8jhyhLYaxkIdZS4Hr6iQBplw0djoG+w7DScLglfdQPIk0XF adhYwqWjeOVvU/BOXbJ/LqkUAUpN4TnunYjcZMt9bv+UZ7qET00ViAC6JW6rsm4UUPQP 3SPV3tFrQBxAGXqT1OQammYCPTTKULP7i9sXLWD2QlixUyqwvqvENUH88VuswxHp7IDU ZGUvG43e3FTaJh/76t7sD8061BtoxC8a6RGnRCogUx1DFTcx9ARZLXA8712IywvvYG+y S7FQ== 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:mime-version:content-transfer-encoding; bh=6MiTsU3N2AEa1ZXLRORW5cxTPfFrxekkDKqSBZREPFg=; b=a2ysv8pS4WRuO6Q0WcODp+5w0wwHHoHIp+AfByG4IkEvLGCaglYSfHnOUqi6I2Oyky uH588JjN1/AdcvyVKJIJO/DM5L1YFqy5S1JgL4A4lLU+T8/eP3CVVvNuem8+B1h7tRw4 cXzWoIJJ1+UPpYIvDhr1nJKy4iKfYCQM9ojZdDe5XdTaiziV1UgvWmGqGIKAe+s9hpUO TGRASg+V5ktEJpBLYW2skFQO30H7HD5ocyU1XzRn6K0EvAGCcWF4jHuk2NlxfKyVSQv3 g5x6rJDDo9OHM34aEx+YjiqVfd830Ee7KnbNldMYMWQCc9ri2xaHEI+8VoHNPi0c+jmS bVNw== X-Gm-Message-State: AOAM533dZsWKDYUIq4kVH/WmPZ7CczNcfCxBkDCm2fliFHz10KLGEXus SuYKrjLPHTm4socb3VS/XOXXpGiNyx+dpK1x X-Received: by 2002:a17:906:ae9b:: with SMTP id md27mr5819629ejb.357.1611134797966; Wed, 20 Jan 2021 01:26:37 -0800 (PST) Received: from localhost.localdomain (hst-221-66.medicom.bg. [84.238.221.66]) by smtp.gmail.com with ESMTPSA id k16sm619392ejd.78.2021.01.20.01.26.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 01:26:37 -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 v4 5/5] venus: venc: Add support for CLL and Mastering display controls Date: Wed, 20 Jan 2021 11:26:06 +0200 Message-Id: <20210120092606.3987207-6-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210120092606.3987207-1-stanimir.varbanov@linaro.org> References: <20210120092606.3987207-1-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@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 | 2 ++ 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, 74 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index b984d508ed71..d2776a18217f 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -238,6 +238,8 @@ struct venc_controls { } level; u32 base_priority_id; + 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 1f1c3faa4631..ecbe05a5cee1 100644 --- a/drivers/media/platform/qcom/venus/hfi_helper.h +++ b/drivers/media/platform/qcom/venus/hfi_helper.h @@ -513,6 +513,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 @@ -809,6 +810,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 e4775ec97a87..464027c88499 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 9fbe8388a938..5a18330b82b8 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -262,6 +262,12 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID: ctr->base_priority_id = 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; } @@ -277,7 +283,7 @@ int venc_ctrl_init(struct venus_inst *inst) { int ret; - ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 51); + ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 53); if (ret) return ret; @@ -483,6 +489,14 @@ int venc_ctrl_init(struct venus_inst *inst) V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID, 0, 6, 1, 0); + 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;