From patchwork Tue Dec 8 14:59:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 339747 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3761030jai; Tue, 8 Dec 2020 07:02:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJypx5mH/FBpAtWED+jcZ/XK3lwsD3s/4b6kBviIJIlXOI7QVneKd3+sBvzIztX3jHHU19QK X-Received: by 2002:a17:906:c097:: with SMTP id f23mr24308499ejz.136.1607439766974; Tue, 08 Dec 2020 07:02:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607439766; cv=none; d=google.com; s=arc-20160816; b=xy72eFc2alq45BFbGOiTwCLOWkDmCS3zBsLMyZv1kJjAwagxEm9kpkI0H4CLqEYDpg gXV8McYneAMBfTQDvRuO8to+xcySJEhWw/PnjlcSUWy4DzrH6avFapgFN+QOG07ILbux RXz35UxzBnyTEgjCufMWbCxqxA+rHwEHLZYKjpp1RMvERu2trK1y5i7tjold43KwDSTz ry68SQc4h1om4VA+3Q14Fb3bcmHPK0PKMj7LozbV9NUb8Zz689ff7mxpUTJ7fFvn8dl9 8M/LVqDAowlq7AvwBZpS2+nX0LSMk1s4WC/vYkx+NGaZ02EIlbT7mOJbQWJUKCapFMjN Xivw== 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=P6FpCVJOv/zJ2FR7DCBu8JVOzQBPu/rr75Zvr4H4RVA=; b=OBeS/jqnrplm9ELGpSeIzK7zxGeES7UAXKZgy+VTTxlVEOTEtfUJkri3OycxfjVcRZ DrLQaEid0z8yVqlZWrgLkOnI9f0gPWr2Q4h4yKQ/fPcyJFG+xP1kNJDw8lxMr8au0m+j Ht8CLXyPa7Otr3fzYMIiw0EAkOecR8d33uVcOqwrkjYwjZZIQESL22zkfsmS53ZtgawA sXZBKvEE2LI8iRFUASaqOsJJ0cZQ0bYyLWz2GxpjZXezzU6LnJfXLJsJnNsTlQ8t9e2Y /OwzwvNfOOxG9n4DyhBCVVMz5rUpAxa21zP4l2QZvs3XrGceqHZyUGDUUUyTg2l8wBJd Wjhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZP4GSS6O; 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.45; Tue, 08 Dec 2020 07:02:46 -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=ZP4GSS6O; 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 S1729984AbgLHPBL (ORCPT + 15 others); Tue, 8 Dec 2020 10:01:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729817AbgLHPBL (ORCPT ); Tue, 8 Dec 2020 10:01:11 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59FDBC0617A6 for ; Tue, 8 Dec 2020 07:00:04 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id i24so10010758edj.8 for ; Tue, 08 Dec 2020 07:00:04 -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=P6FpCVJOv/zJ2FR7DCBu8JVOzQBPu/rr75Zvr4H4RVA=; b=ZP4GSS6ONtnFvNMeSKWrZTBRelperQH9K+ESHWGoENPB7dZiSNj5vG9XACKqGn38U/ cJ+est8iiEGWSQjiz0AOGAEEGBV4+XCZT6zDl77QVBzIP2sPM+1r6KOH1s4x9dvYLIJe ynyFO/I23H4W/y8/6GGrWgK9z9E3q5mXmzV/69eKvwCA2YWZE7SlKcjogW9ujO+0Ziof +1GlHYnU5vrlOZ5VPgQ+smm5HyNIFseOC/I8BTVRLRt+6/ae/A4WCQbqLUoPw35gQDqK uLmG4GKMfj22RisjcZXF9p3BUKS+5bvPsg91XtErX3us0BljxmZud/p7ABcnW7IVHcpM vH8Q== 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=P6FpCVJOv/zJ2FR7DCBu8JVOzQBPu/rr75Zvr4H4RVA=; b=XWz+UKSAAZbrOEydsftd1IQfQSuTViUnfHOeLg2m8Qt7raYzDZm2CVOwS9UO9h9/4V VjNAIY5IWs9wmrEM2hES1GznIewNm+NAhFt10bMzlobabezGSY3DRq+sXf7rk9edq2UQ ylTJJ5LxkK5L1Fs/IBgzsCH+9/EDfLnhOAALx0Dmx8KG7lrbYmMSj8H5y7zddGf4wI6d NBbAEXWiI7tiXcDMJutMZtNE7kIrY6p6R1Puj6aSqTNeQBAOAjUYd81Zfy9tdwaVrLAl jimROzd6pg7eB3QwXbLcgmTkYK3xvtlE1q+kBCpQi9YlPg9fcY+opo/2VJ6dh3AQRkRy iU5A== X-Gm-Message-State: AOAM531is4FuAYtfj8qWL4he/HyBUhR0NULW4mLtsvu+B/Ji02sxVP8j 7XkuDNjkdbBDg469mtbhti01sw== X-Received: by 2002:a50:f61b:: with SMTP id c27mr24741436edn.61.1607439603040; Tue, 08 Dec 2020 07:00:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 07:00:02 -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 1/3] v4l: Add HDR10 static metadata controls Date: Tue, 8 Dec 2020 16:59:29 +0200 Message-Id: <20201208145931.6187-2-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 Here we introduce a new Colorimetry control class and add Content light level and Mastering display colour volume v4l2 compound controls, relevant payload structures and validation. Signed-off-by: Stanimir Varbanov --- .../media/videodev2.h.rst.exceptions | 2 + drivers/media/v4l2-core/v4l2-ctrls.c | 68 +++++++++++++++++++ include/media/v4l2-ctrls.h | 4 ++ include/uapi/linux/v4l2-controls.h | 35 ++++++++++ include/uapi/linux/videodev2.h | 2 + 5 files changed, 111 insertions(+) -- 2.17.1 diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b/Documentation/userspace-api/media/videodev2.h.rst.exceptions index 0ed170c6e720..af4b8b87c5d7 100644 --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions @@ -147,6 +147,8 @@ replace symbol V4L2_CTRL_TYPE_HEVC_PPS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_AREA :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_FWHT_PARAMS :c:type:`v4l2_ctrl_type` +replace symbol V4L2_CTRL_TYPE_HDR10_CLL_INFO :c:type:`v4l2_ctrl_hdr10_cll_info` +replace symbol V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY :c:type:`v4l2_ctrl_hdr10_mastering_display` # V4L2 capability defines replace define V4L2_CAP_VIDEO_CAPTURE device-capabilities diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 5cbe0ffbf501..7bd6c3098f30 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -1015,6 +1015,9 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE: return "HEVC Decode Mode"; case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE: return "HEVC Start Code"; + case V4L2_CID_COLORIMETRY_HDR10_CLL_INFO: return "HDR10 Content Light Info"; + case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY: return "HDR10 Mastering Display"; + /* CAMERA controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */ case V4L2_CID_CAMERA_CLASS: return "Camera Controls"; @@ -1466,6 +1469,12 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS: *type = V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS; break; + case V4L2_CID_COLORIMETRY_HDR10_CLL_INFO: + *type = V4L2_CTRL_TYPE_HDR10_CLL_INFO; + break; + case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY: + *type = V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY; + break; case V4L2_CID_UNIT_CELL_SIZE: *type = V4L2_CTRL_TYPE_AREA; *flags |= V4L2_CTRL_FLAG_READ_ONLY; @@ -1765,6 +1774,12 @@ static void std_log(const struct v4l2_ctrl *ctrl) case V4L2_CTRL_TYPE_FWHT_PARAMS: pr_cont("FWHT_PARAMS"); break; + case V4L2_CTRL_TYPE_HDR10_CLL_INFO: + pr_cont("HDR10_CLL_INFO"); + break; + case V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY: + pr_cont("HDR10_MASTERING_DISPLAY"); + break; default: pr_cont("unknown type %d", ctrl->type); break; @@ -1817,6 +1832,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, struct v4l2_ctrl_hevc_sps *p_hevc_sps; struct v4l2_ctrl_hevc_pps *p_hevc_pps; struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params; + struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering; struct v4l2_area *area; void *p = ptr.p + idx * ctrl->elem_size; unsigned int i; @@ -2112,6 +2128,52 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, zero_padding(*p_hevc_slice_params); break; + case V4L2_CTRL_TYPE_HDR10_CLL_INFO: + break; + + case V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY: + p_hdr10_mastering = p; + + for (i = 0; i < 3; ++i) { + if (p_hdr10_mastering->display_primaries_x[i] < + V4L2_HDR10_MASTERING_PRIMARIES_X_LOW || + p_hdr10_mastering->display_primaries_x[i] > + V4L2_HDR10_MASTERING_PRIMARIES_X_HIGH || + p_hdr10_mastering->display_primaries_y[i] < + V4L2_HDR10_MASTERING_PRIMARIES_Y_LOW || + p_hdr10_mastering->display_primaries_y[i] > + V4L2_HDR10_MASTERING_PRIMARIES_Y_HIGH) + return -EINVAL; + } + + if (p_hdr10_mastering->white_point_x < + V4L2_HDR10_MASTERING_WHITE_POINT_X_LOW || + p_hdr10_mastering->white_point_x > + V4L2_HDR10_MASTERING_WHITE_POINT_X_HIGH || + p_hdr10_mastering->white_point_y < + V4L2_HDR10_MASTERING_WHITE_POINT_Y_LOW || + p_hdr10_mastering->white_point_y > + V4L2_HDR10_MASTERING_WHITE_POINT_Y_HIGH) + return -EINVAL; + + if (p_hdr10_mastering->max_display_mastering_luminance < + V4L2_HDR10_MASTERING_MAX_LUMA_LOW || + p_hdr10_mastering->max_display_mastering_luminance > + V4L2_HDR10_MASTERING_MAX_LUMA_HIGH || + p_hdr10_mastering->min_display_mastering_luminance < + V4L2_HDR10_MASTERING_MIN_LUMA_LOW || + p_hdr10_mastering->min_display_mastering_luminance > + V4L2_HDR10_MASTERING_MIN_LUMA_HIGH) + return -EINVAL; + + if (p_hdr10_mastering->max_display_mastering_luminance == + V4L2_HDR10_MASTERING_MAX_LUMA_LOW && + p_hdr10_mastering->min_display_mastering_luminance == + V4L2_HDR10_MASTERING_MIN_LUMA_HIGH) + return -EINVAL; + + break; + case V4L2_CTRL_TYPE_AREA: area = p; if (!area->width || !area->height) @@ -2804,6 +2866,12 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS: elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params); break; + case V4L2_CTRL_TYPE_HDR10_CLL_INFO: + elem_size = sizeof(struct v4l2_ctrl_hdr10_cll_info); + break; + case V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY: + elem_size = sizeof(struct v4l2_ctrl_hdr10_mastering_display); + break; case V4L2_CTRL_TYPE_AREA: elem_size = sizeof(struct v4l2_area); break; diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 167ca8c8424f..8308acc89b11 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -54,6 +54,8 @@ struct video_device; * @p_hevc_sps: Pointer to an HEVC sequence parameter set structure. * @p_hevc_pps: Pointer to an HEVC picture parameter set structure. * @p_hevc_slice_params: Pointer to an HEVC slice parameters structure. + * @p_hdr10_cll: Pointer to an HDR10 Content Light Level structure. + * @p_hdr10_mastering : Pointer to an HDR10 Mastering Display structure. * @p_area: Pointer to an area. * @p: Pointer to a compound value. * @p_const: Pointer to a constant compound value. @@ -78,6 +80,8 @@ union v4l2_ctrl_ptr { struct v4l2_ctrl_hevc_sps *p_hevc_sps; struct v4l2_ctrl_hevc_pps *p_hevc_pps; struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params; + struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll; + struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering; struct v4l2_area *p_area; void *p; const void *p_const; diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 823b214aac0c..8563f789cbe2 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -66,6 +66,7 @@ #define V4L2_CTRL_CLASS_RF_TUNER 0x00a20000 /* RF tuner controls */ #define V4L2_CTRL_CLASS_DETECT 0x00a30000 /* Detection controls */ #define V4L2_CTRL_CLASS_CODEC_STATELESS 0x00a40000 /* Stateless codecs controls */ +#define V4L2_CTRL_CLASS_COLORIMETRY 0x00a50000 /* Colorimetry controls */ /* User-class control IDs */ @@ -1635,6 +1636,40 @@ struct v4l2_ctrl_fwht_params { __u32 quantization; }; +#define V4L2_CID_COLORIMETRY_BASE (V4L2_CTRL_CLASS_COLORIMETRY | 0x900) +#define V4L2_CID_COLORIMETRY_CLASS (V4L2_CTRL_CLASS_COLORIMETRY | 1) + +#define V4L2_CID_COLORIMETRY_HDR10_CLL_INFO (V4L2_CID_COLORIMETRY_BASE + 0) + +struct v4l2_ctrl_hdr10_cll_info { + __u16 max_content_light_level; + __u16 max_pic_average_light_level; +}; + +#define V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY (V4L2_CID_COLORIMETRY_BASE + 1) + +#define V4L2_HDR10_MASTERING_PRIMARIES_X_LOW 5 +#define V4L2_HDR10_MASTERING_PRIMARIES_X_HIGH 37000 +#define V4L2_HDR10_MASTERING_PRIMARIES_Y_LOW 5 +#define V4L2_HDR10_MASTERING_PRIMARIES_Y_HIGH 42000 +#define V4L2_HDR10_MASTERING_WHITE_POINT_X_LOW 5 +#define V4L2_HDR10_MASTERING_WHITE_POINT_X_HIGH 37000 +#define V4L2_HDR10_MASTERING_WHITE_POINT_Y_LOW 5 +#define V4L2_HDR10_MASTERING_WHITE_POINT_Y_HIGH 42000 +#define V4L2_HDR10_MASTERING_MAX_LUMA_LOW 50000 +#define V4L2_HDR10_MASTERING_MAX_LUMA_HIGH 100000000 +#define V4L2_HDR10_MASTERING_MIN_LUMA_LOW 1 +#define V4L2_HDR10_MASTERING_MIN_LUMA_HIGH 50000 + +struct v4l2_ctrl_hdr10_mastering_display { + __u16 display_primaries_x[3]; + __u16 display_primaries_y[3]; + __u16 white_point_x; + __u16 white_point_y; + __u32 max_display_mastering_luminance; + __u32 min_display_mastering_luminance; +}; + /* MPEG-compression definitions kept for backwards compatibility */ #ifndef __KERNEL__ #define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 79dbde3bcf8d..1bde498e36a0 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1792,6 +1792,8 @@ enum v4l2_ctrl_type { V4L2_CTRL_TYPE_H264_PRED_WEIGHTS = 0x0205, V4L2_CTRL_TYPE_FWHT_PARAMS = 0x0220, + V4L2_CTRL_TYPE_HDR10_CLL_INFO = 0x0221, + V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY = 0x0222, }; /* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ 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;