From patchwork Sun Dec 17 00:17:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 10117607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 704586057C for ; Sun, 17 Dec 2017 00:17:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6381829257 for ; Sun, 17 Dec 2017 00:17:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57A3F29283; Sun, 17 Dec 2017 00:17:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4D942933E for ; Sun, 17 Dec 2017 00:17:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757052AbdLQAR0 (ORCPT ); Sat, 16 Dec 2017 19:17:26 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:50492 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756922AbdLQARW (ORCPT ); Sat, 16 Dec 2017 19:17:22 -0500 Received: from localhost.localdomain (unknown [IPv6:2a02:a03f:62fe:1100:6c1c:56de:3a70:e025]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 99B7920226; Sun, 17 Dec 2017 01:17:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1513469831; bh=XV2XIBoeS5SpxA4BiL/b8if9bONT63OZd0eM30N1SqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D9CEsrjbacCdzj2qU+qrjgPhexAJEZDayGGIXDT/ps8nC4GwHtpVj5GQoY1ZCYkdX Qqnp4z4zqhodKogkwlsmLSeu/VzhF5aA0F1RzKum0Ojl7LrtIC7DZ1uj3rxgkxkSmi JAUn9xiJJFVPfi5X0wCFHi3ZgnLEU9lA0pYDPkeA= From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Alexandru Gheorghe , Russell King , Ben Skeggs , Sinclair Yeh , Thomas Hellstrom , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi Subject: [PATCH/RFC 2/4] drm: rcar-du: Use standard colorkey properties Date: Sun, 17 Dec 2017 02:17:22 +0200 Message-Id: <20171217001724.1348-3-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171217001724.1348-1-laurent.pinchart+renesas@ideasonboard.com> References: <20171217001724.1348-1-laurent.pinchart+renesas@ideasonboard.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that KMS has standard color keying properties, instantiate them for all the non-primary planes. This replaces the custom colorkey field in the driver plane state structure. The custom colorkey property is kept to ensure backward-compatibility, but now implemented as an alias for the standard colorkey.mode, colorkey.min and colorkey.max properties. Signed-off-by: Laurent Pinchart --- drivers/gpu/drm/rcar-du/rcar_du_plane.c | 60 +++++++++++++++++++++++---------- drivers/gpu/drm/rcar-du/rcar_du_plane.h | 2 -- drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 1 - 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c index 4a3d16cf3ed6..b3b43c280ead 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c @@ -432,7 +432,7 @@ static void rcar_du_plane_setup_mode(struct rcar_du_group *rgrp, * PnMR_SPIM_TP_OFF bit set in their pnmr field, disabling color keying * automatically. */ - if ((state->colorkey & RCAR_DU_COLORKEY_MASK) == RCAR_DU_COLORKEY_NONE) + if (state->state.colorkey.mode == 0) pnmr |= PnMR_SPIM_TP_OFF; /* For packed YUV formats we need to select the U/V order. */ @@ -441,26 +441,30 @@ static void rcar_du_plane_setup_mode(struct rcar_du_group *rgrp, rcar_du_plane_write(rgrp, index, PnMR, pnmr); + colorkey = ((state->state.colorkey.min >> 24) & 0x00ff0000) + | ((state->state.colorkey.min >> 16) & 0x0000ff00) + | ((state->state.colorkey.min >> 8) & 0x000000ff); + switch (state->format->fourcc) { case DRM_FORMAT_RGB565: - colorkey = ((state->colorkey & 0xf80000) >> 8) - | ((state->colorkey & 0x00fc00) >> 5) - | ((state->colorkey & 0x0000f8) >> 3); + colorkey = ((colorkey & 0xf80000) >> 8) + | ((colorkey & 0x00fc00) >> 5) + | ((colorkey & 0x0000f8) >> 3); rcar_du_plane_write(rgrp, index, PnTC2R, colorkey); break; case DRM_FORMAT_ARGB1555: case DRM_FORMAT_XRGB1555: - colorkey = ((state->colorkey & 0xf80000) >> 9) - | ((state->colorkey & 0x00f800) >> 6) - | ((state->colorkey & 0x0000f8) >> 3); + colorkey = ((colorkey & 0xf80000) >> 9) + | ((colorkey & 0x00f800) >> 6) + | ((colorkey & 0x0000f8) >> 3); rcar_du_plane_write(rgrp, index, PnTC2R, colorkey); break; case DRM_FORMAT_XRGB8888: case DRM_FORMAT_ARGB8888: rcar_du_plane_write(rgrp, index, PnTC3R, - PnTC3R_CODE | (state->colorkey & 0xffffff)); + PnTC3R_CODE | colorkey); break; } } @@ -575,6 +579,9 @@ int __rcar_du_plane_atomic_check(struct drm_plane *plane, struct drm_rect clip; int ret; + if (state->colorkey.min != state->colorkey.max) + return -EINVAL; + if (!state->crtc) { /* * The visible field is not reset by the DRM core but only @@ -699,7 +706,6 @@ static void rcar_du_plane_reset(struct drm_plane *plane) state->hwindex = -1; state->source = RCAR_DU_PLANE_MEMORY; state->alpha = 255; - state->colorkey = RCAR_DU_COLORKEY_NONE; state->state.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1; plane->state = &state->state; @@ -714,12 +720,17 @@ static int rcar_du_plane_atomic_set_property(struct drm_plane *plane, struct rcar_du_plane_state *rstate = to_rcar_plane_state(state); struct rcar_du_device *rcdu = to_rcar_plane(plane)->group->dev; - if (property == rcdu->props.alpha) + if (property == rcdu->props.alpha) { rstate->alpha = val; - else if (property == rcdu->props.colorkey) - rstate->colorkey = val; - else + } else if (property == rcdu->props.colorkey) { + state->colorkey.mode = val & RCAR_DU_COLORKEY_MASK ? 1 : 0; + state->colorkey.min = ((val & 0x00ff0000) << 24) + | ((val & 0x0000ff00) << 16) + | ((val & 0x000000ff) << 8); + state->colorkey.max = state->colorkey.min; + } else { return -EINVAL; + } return 0; } @@ -732,12 +743,18 @@ static int rcar_du_plane_atomic_get_property(struct drm_plane *plane, container_of(state, const struct rcar_du_plane_state, state); struct rcar_du_device *rcdu = to_rcar_plane(plane)->group->dev; - if (property == rcdu->props.alpha) + if (property == rcdu->props.alpha) { *val = rstate->alpha; - else if (property == rcdu->props.colorkey) - *val = rstate->colorkey; - else + } else if (property == rcdu->props.colorkey) { + u32 colorkey = ((state->colorkey.min >> 24) & 0x00ff0000) + | ((state->colorkey.min >> 16) & 0x0000ff00) + | ((state->colorkey.min >> 8) & 0x000000ff); + + *val = colorkey | (state->colorkey.mode ? + RCAR_DU_COLORKEY_SOURCE : RCAR_DU_COLORKEY_NONE); + } else { return -EINVAL; + } return 0; } @@ -766,6 +783,11 @@ static const uint32_t formats[] = { DRM_FORMAT_NV16, }; +static const struct drm_prop_enum_list colorkey_modes[] = { + { 0, "disabled" }, + { 1, "source" }, +}; + int rcar_du_planes_init(struct rcar_du_group *rgrp) { struct rcar_du_device *rcdu = rgrp->dev; @@ -808,6 +830,10 @@ int rcar_du_planes_init(struct rcar_du_group *rgrp) rcdu->props.colorkey, RCAR_DU_COLORKEY_NONE); drm_plane_create_zpos_property(&plane->plane, 1, 1, 7); + drm_plane_create_colorkey_properties(&plane->plane, + colorkey_modes, + ARRAY_SIZE(colorkey_modes), + false); } return 0; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.h b/drivers/gpu/drm/rcar-du/rcar_du_plane.h index 890321b4665d..d8baf12cc716 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.h @@ -51,7 +51,6 @@ static inline struct rcar_du_plane *to_rcar_plane(struct drm_plane *plane) * @format: information about the pixel format used by the plane * @hwindex: 0-based hardware plane index, -1 means unused * @alpha: value of the plane alpha property - * @colorkey: value of the plane colorkey property */ struct rcar_du_plane_state { struct drm_plane_state state; @@ -61,7 +60,6 @@ struct rcar_du_plane_state { enum rcar_du_plane_source source; unsigned int alpha; - unsigned int colorkey; }; static inline struct rcar_du_plane_state * diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c index 2c260c33840b..882d1f7a328b 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c @@ -68,7 +68,6 @@ void rcar_du_vsp_enable(struct rcar_du_crtc *crtc) .format = rcar_du_format_info(DRM_FORMAT_ARGB8888), .source = RCAR_DU_PLANE_VSPD1, .alpha = 255, - .colorkey = 0, }; if (rcdu->info->gen >= 3)