From patchwork Thu Apr 10 23:42:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14047354 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBA8A213E94; Thu, 10 Apr 2025 23:43:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744328592; cv=none; b=VAi8p9VeK93ksRMpKN6jXTtpHdDXtMPQkDtD2R8q+wzACYj0EPSi7+gu+AIuz6/BMAZ3rBcfFziQnt23aUMQ9p7D5qwjuNSwwdf89gO3j0U8fZbZ7vA96JxJTljPGGwOlW3ZC0nnXQIbObbGSJwGJ7KEA6+av6aV8nvFAAKwJpI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744328592; c=relaxed/simple; bh=n/ByvwRWyn3E0+OXF4ONfIzKFiaT4RPmzY9bLKKb7tE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lo2H3KoO2fPmYNtrq8dHiUtYq5HlARxEEAq34n8F2GxKhqpZ+Sh6pc0B01yGIGoEJLSxC1hGW7QSIgtgqWiKVzCxDjB6p6S5h56DHkcfqQGEVSkVYYHE8PjlqcJTb0+k6D5A7MVY+w4pK1ja8flvRBVfCbfLxstEPUSIYW2LnbA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=SeW3htL9; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SeW3htL9" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4A99AA57; Fri, 11 Apr 2025 01:41:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744328470; bh=n/ByvwRWyn3E0+OXF4ONfIzKFiaT4RPmzY9bLKKb7tE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SeW3htL94+3Y0CrkDnUK99+gUnwBbUmI+aU1tKDdvNSWKFAR1m+1fu1uXpEx8c3O6 ubHFKGnAfPR7jsmyOuxDhNTVDHAAuo1mlmF6oqNhvPFYPAHt4l5bcSV1T+Z74YGVx1 SHpAXRTfJW1lfnTSfiERpY1o3Q1pYn01m2Wp6HIw= From: Laurent Pinchart To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: linux-renesas-soc@vger.kernel.org, Tomi Valkeinen , Kieran Bingham , David Airlie , Simona Vetter Subject: [PATCH 1/3] media: renesas: vsp1: Name nested structure in vsp1_drm Date: Fri, 11 Apr 2025 02:42:39 +0300 Message-ID: <20250410234241.28123-2-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250410234241.28123-1-laurent.pinchart+renesas@ideasonboard.com> References: <20250410234241.28123-1-laurent.pinchart+renesas@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The vsp1_drm structure defines an anonymous nested structure to store per-input data. In preparation for extending that structure, give it a name and is it through the driver. This improves code readability. Signed-off-by: Laurent Pinchart --- drivers/media/platform/renesas/vsp1/vsp1_drm.c | 18 +++++++++--------- drivers/media/platform/renesas/vsp1/vsp1_drm.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.c b/drivers/media/platform/renesas/vsp1/vsp1_drm.c index f8a575f6188a..e5339fda5941 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.c +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.c @@ -118,24 +118,22 @@ static int vsp1_du_pipeline_setup_rpf(struct vsp1_device *vsp1, struct vsp1_entity *uif, unsigned int brx_input) { + const struct vsp1_drm_input *input = &vsp1->drm->inputs[rpf->entity.index]; struct v4l2_subdev_selection sel = { .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; struct v4l2_subdev_format format = { .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; - const struct v4l2_rect *crop; int ret; /* * Configure the format on the RPF sink pad and propagate it up to the * BRx sink pad. */ - crop = &vsp1->drm->inputs[rpf->entity.index].crop; - format.pad = RWPF_PAD_SINK; - format.format.width = crop->width + crop->left; - format.format.height = crop->height + crop->top; + format.format.width = input->crop.width + input->crop.left; + format.format.height = input->crop.height + input->crop.top; format.format.code = rpf->fmtinfo->mbus; format.format.field = V4L2_FIELD_NONE; @@ -151,7 +149,7 @@ static int vsp1_du_pipeline_setup_rpf(struct vsp1_device *vsp1, sel.pad = RWPF_PAD_SINK; sel.target = V4L2_SEL_TGT_CROP; - sel.r = *crop; + sel.r = input->crop; ret = v4l2_subdev_call(&rpf->entity.subdev, pad, set_selection, NULL, &sel); @@ -826,12 +824,14 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index, { struct vsp1_device *vsp1 = dev_get_drvdata(dev); struct vsp1_drm_pipeline *drm_pipe = &vsp1->drm->pipe[pipe_index]; + struct vsp1_drm_input *input; struct vsp1_rwpf *rpf; int ret; if (rpf_index >= vsp1->info->rpf_count) return -EINVAL; + input = &vsp1->drm->inputs[rpf_index]; rpf = vsp1->rpf[rpf_index]; if (!cfg) { @@ -873,9 +873,9 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index, rpf->format.flags = cfg->premult ? V4L2_PIX_FMT_FLAG_PREMUL_ALPHA : 0; - vsp1->drm->inputs[rpf_index].crop = cfg->src; - vsp1->drm->inputs[rpf_index].compose = cfg->dst; - vsp1->drm->inputs[rpf_index].zpos = cfg->zpos; + input->crop = cfg->src; + input->compose = cfg->dst; + input->zpos = cfg->zpos; drm_pipe->pipe.inputs[rpf_index] = rpf; diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.h b/drivers/media/platform/renesas/vsp1/vsp1_drm.h index 3fd95b53f27e..7234737cc464 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.h +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.h @@ -59,7 +59,7 @@ struct vsp1_drm { struct vsp1_drm_pipeline pipe[VSP1_MAX_LIF]; struct mutex lock; - struct { + struct vsp1_drm_input { struct v4l2_rect crop; struct v4l2_rect compose; unsigned int zpos; From patchwork Thu Apr 10 23:42:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14047355 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E0FC215067; Thu, 10 Apr 2025 23:43:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744328595; cv=none; b=QOC2FAYNZW5GY65Qr33GluEf9bZ9oRSpYYI94NmtBEUR/N4eqk5wWJjJRiJdTi9aZ9UiUXvMRSMWRXYnhv54E3Ka7y66FVNaevfYnUlfv7uBTYwwpfNtyUIZj2X9tChSCLcdTfSZ6o+QAJu26Y2gTZ9WFkQVhseTtqBNI1OJF60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744328595; c=relaxed/simple; bh=JW8R+ouKfZDbf21xsY26yAdEIf0xJhExWbz+oLvI4WA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Br+GnfSdgq5N9I84XIUt8ArHqnUdud9WSbdmDpv0sIss7RGvf2tSyhsDDVAlPg1VgoTC0ZKEOexbbN4vLInu+nDMaZ6BtiptKT237MQtFojASf4gLR+mrMksiiKFw46rtw1sBtk2FdDCCOMXpHkRBLQNDEtFwnb/ZPDd0/UNxRs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=hr8lmWj+; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="hr8lmWj+" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9FE16D52; Fri, 11 Apr 2025 01:41:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744328471; bh=JW8R+ouKfZDbf21xsY26yAdEIf0xJhExWbz+oLvI4WA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hr8lmWj+6cUulhARcVZJtljzucl3uBSBwYTvrJQbxeCcpp7hALvdo0vFrozcp0Twe p25eJ3scChvfJs/hYFDwYkcQMhYyir3/PD13B9KI/xPMS5GSHKhqPwUVDqOHHs8198 e2khCeZL/HGEiXL3OPWmk7rT5hdwA/jU8337B7cI= From: Laurent Pinchart To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: linux-renesas-soc@vger.kernel.org, Tomi Valkeinen , Kieran Bingham , David Airlie , Simona Vetter Subject: [PATCH 2/3] media: renesas: vsp1: Expose color space through the DRM API Date: Fri, 11 Apr 2025 02:42:40 +0300 Message-ID: <20250410234241.28123-3-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250410234241.28123-1-laurent.pinchart+renesas@ideasonboard.com> References: <20250410234241.28123-1-laurent.pinchart+renesas@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that the VSP1 driver supports color spaces, expose them through the API used by the DU driver. This allows configuring the YCbCr encoding and quantization used by each plane, ensuring correct color rendering. Signed-off-by: Laurent Pinchart --- drivers/media/platform/renesas/vsp1/vsp1_drm.c | 4 ++++ drivers/media/platform/renesas/vsp1/vsp1_drm.h | 6 ++++-- include/media/vsp1.h | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.c b/drivers/media/platform/renesas/vsp1/vsp1_drm.c index e5339fda5941..fe55e8747b05 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.c +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.c @@ -136,6 +136,8 @@ static int vsp1_du_pipeline_setup_rpf(struct vsp1_device *vsp1, format.format.height = input->crop.height + input->crop.top; format.format.code = rpf->fmtinfo->mbus; format.format.field = V4L2_FIELD_NONE; + format.format.ycbcr_enc = input->ycbcr_enc; + format.format.quantization = input->quantization; ret = v4l2_subdev_call(&rpf->entity.subdev, pad, set_fmt, NULL, &format); @@ -876,6 +878,8 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index, input->crop = cfg->src; input->compose = cfg->dst; input->zpos = cfg->zpos; + input->ycbcr_enc = cfg->color_encoding; + input->quantization = cfg->color_range; drm_pipe->pipe.inputs[rpf_index] = rpf; diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.h b/drivers/media/platform/renesas/vsp1/vsp1_drm.h index 7234737cc464..07a5d0adbd08 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.h +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.h @@ -52,8 +52,8 @@ struct vsp1_drm_pipeline { * struct vsp1_drm - State for the API exposed to the DRM driver * @pipe: the VSP1 DRM pipeline used for display * @lock: protects the BRU and BRS allocation - * @inputs: source crop rectangle, destination compose rectangle and z-order - * position for every input (indexed by RPF index) + * @inputs: source crop rectangle, destination compose rectangle, z-order + * position and colorspace for every input (indexed by RPF index) */ struct vsp1_drm { struct vsp1_drm_pipeline pipe[VSP1_MAX_LIF]; @@ -63,6 +63,8 @@ struct vsp1_drm { struct v4l2_rect crop; struct v4l2_rect compose; unsigned int zpos; + enum v4l2_ycbcr_encoding ycbcr_enc; + enum v4l2_quantization quantization; } inputs[VSP1_MAX_RPF]; }; diff --git a/include/media/vsp1.h b/include/media/vsp1.h index 48f4a5023d81..4ea6352fd63f 100644 --- a/include/media/vsp1.h +++ b/include/media/vsp1.h @@ -52,6 +52,8 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index, * @alpha: alpha value (0: fully transparent, 255: fully opaque) * @zpos: Z position of the plane (from 0 to number of planes minus 1) * @premult: true for premultiplied alpha + * @color_encoding: color encoding (valid for YUV formats only) + * @color_range: color range (valid for YUV formats only) */ struct vsp1_du_atomic_config { u32 pixelformat; @@ -62,6 +64,8 @@ struct vsp1_du_atomic_config { unsigned int alpha; unsigned int zpos; bool premult; + enum v4l2_ycbcr_encoding color_encoding; + enum v4l2_quantization color_range; }; /** From patchwork Thu Apr 10 23:42:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14047356 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 640D0213E94; Thu, 10 Apr 2025 23:43:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744328597; cv=none; b=LqjORS+xG9ywpGq/nX2hx8R8AJyl9eBlxNNKrJknvQSNCA3aoEOOHV1c+x+/VIRQhxZC9U0a+apBPTZCK63dHTg+K6U0FKDr1Thf0NEKPzGIMaJ7fZa/PITW7eXW9LBZRYPposClbRgvdv4B97c7H1FMhK6dczqCawfCNGhBgdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744328597; c=relaxed/simple; bh=G4mR0T4QXAobaLYQreC+Pkhgic1JC7pUgVbD8hJMe78=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Sb+upODIL3riElTf1Z4jvJ65Mwkqy5fnxdnVM124uMN7KmIbjq9V7i/xFh3xiHsClvBWpzgslOLq2blX6tVPqMf8EcXcuQzS/kGMhlxPEaeeEjmMsnY3Vk5XTuF0BVYGWAt4a2Y6LgQXps7cKQTZSKJe5sqpRlkj5HnYnNd7RrM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=THD0TYU6; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="THD0TYU6" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F3038D90; Fri, 11 Apr 2025 01:41:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744328473; bh=G4mR0T4QXAobaLYQreC+Pkhgic1JC7pUgVbD8hJMe78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=THD0TYU65P1za8R2cMAzxKyzG92aiB8XXoh6z1KhkZT5T7to3LPusFmWlkn+9SVfd 7PQulVyL0tI/6SYPKT89iHn8w2nxUDAh87XR5Hn6exjdp6GlhYUHVuNpFuDeteXFhj 3go7TGuPRuzjta5zV+fok+dQ32Lp2Gm7eqt6idB0= From: Laurent Pinchart To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: linux-renesas-soc@vger.kernel.org, Tomi Valkeinen , Kieran Bingham , David Airlie , Simona Vetter Subject: [PATCH 3/3] drm: rcar-du: Create plane color properties Date: Fri, 11 Apr 2025 02:42:41 +0300 Message-ID: <20250410234241.28123-4-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250410234241.28123-1-laurent.pinchart+renesas@ideasonboard.com> References: <20250410234241.28123-1-laurent.pinchart+renesas@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that the VSP1 driver allows setting per-plance color encoding and color range for its DRM pipeline, create the corresponding DRM properties in the DU driver and wire them to the VSP. This completes support for plane color space. Signed-off-by: Laurent Pinchart --- drivers/gpu/drm/renesas/rcar-du/rcar_du_vsp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/renesas/rcar-du/rcar_du_vsp.c index 7aa0373563a4..09f9ab2111a2 100644 --- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_vsp.c +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_vsp.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -251,6 +252,12 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) cfg.premult = state->state.pixel_blend_mode == DRM_MODE_BLEND_PREMULTI; + cfg.color_encoding = state->state.color_encoding == DRM_COLOR_YCBCR_BT601 + ? V4L2_YCBCR_ENC_601 : V4L2_YCBCR_ENC_709; + cfg.color_range = state->state.color_range == DRM_COLOR_YCBCR_LIMITED_RANGE + ? V4L2_QUANTIZATION_LIM_RANGE + : V4L2_QUANTIZATION_FULL_RANGE; + vsp1_du_atomic_update(plane->vsp->vsp, crtc->vsp_pipe, plane->index, &cfg); } @@ -530,6 +537,14 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np, BIT(DRM_MODE_BLEND_PREMULTI) | BIT(DRM_MODE_BLEND_COVERAGE)); + drm_plane_create_color_properties(&plane->plane, + BIT(DRM_COLOR_YCBCR_BT601) | + BIT(DRM_COLOR_YCBCR_BT709), + BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) | + BIT(DRM_COLOR_YCBCR_FULL_RANGE), + DRM_COLOR_YCBCR_BT601, + DRM_COLOR_YCBCR_LIMITED_RANGE); + vsp->num_planes++; }