From patchwork Thu Feb 15 05:32:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniele Castagna X-Patchwork-Id: 10220569 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 1E6CB6055C for ; Thu, 15 Feb 2018 08:36:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D102290B4 for ; Thu, 15 Feb 2018 08:36:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 020C3290BA; Thu, 15 Feb 2018 08:36:56 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AE0D2290B4 for ; Thu, 15 Feb 2018 08:36:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E32176E1BD; Thu, 15 Feb 2018 08:36:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-f179.google.com (mail-qt0-f179.google.com [209.85.216.179]) by gabe.freedesktop.org (Postfix) with ESMTPS id AFFCE6E0B6 for ; Thu, 15 Feb 2018 05:33:20 +0000 (UTC) Received: by mail-qt0-f179.google.com with SMTP id d14so10601964qtg.1 for ; Wed, 14 Feb 2018 21:33:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Jyii7176HkQH45bVAYJlvSlkii0e7QuvIRLTDeh8Too=; b=AjHjNHWsMxPd0VJWnXp757RKYcT4CAJDOYDG68rAlIp1uHZBBF6l388BtrXlLSxIZZ AfQ0RhGHnir9U6f3JLwe7/kowmeeLYKmaZ9NF+XYsMoA4y9Ul9IW9arLGQ26/WOmP0vz L8IPDsHX3jxp3CPbS0dTYy/cxb+HwzbpSeSWAU7jO1IUmB3IKTQajT/Jr2BZZDZZ81e3 EtmFweVcLUdNU34erlhZCIHXBhtnP2vcnXw3JWlF3ReBYAbYysC+qqfGh90fWOYwjd7X ij5vrvlOXNJbitUIc4JEmrchW3wbSDTC4yr1JD0cIpuDxc3eBYEyu2q2l3wi8v6Hpb6K 9BlQ== X-Gm-Message-State: APf1xPA3TvhgSllq//u1EOmq6pssWYFHLJgjvk/OseAcljyo6kPl3zjU dRaGDRsxoXvjf4oGE/0AzMIpMhdisd4= X-Google-Smtp-Source: AH8x227eTk4tiX8AhvieAjmFUmJnqOz1xTLMrtx+P/ekVcnfAHqYjqD3FJV9wWunjm+frP+jg0rcjQ== X-Received: by 10.237.33.4 with SMTP id 4mr2458881qtc.132.1518672799325; Wed, 14 Feb 2018 21:33:19 -0800 (PST) Received: from dcastagna1.nyc.corp.google.com ([2620:0:1003:101a:749d:49f2:f0b1:dd83]) by smtp.gmail.com with ESMTPSA id l62sm13808198qkl.23.2018.02.14.21.33.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Feb 2018 21:33:18 -0800 (PST) From: Daniele Castagna To: dri-devel@lists.freedesktop.org Subject: [PATCH 09/10] drm/rockchip: Implement drm plane->ctm property. Date: Thu, 15 Feb 2018 00:32:59 -0500 Message-Id: <20180215053300.70482-10-dcastagna@chromium.org> X-Mailer: git-send-email 2.16.1.291.g4437f3f132-goog In-Reply-To: <20180215053300.70482-1-dcastagna@chromium.org> References: <20180215053300.70482-1-dcastagna@chromium.org> X-Mailman-Approved-At: Thu, 15 Feb 2018 08:36:05 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Validate drm PLANE_CTM matrix and map it to YUV2YUV registers. Change-Id: Ib4fe49558c6266bf0c310af121d625cd7b2cedf6 --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 45 +++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index ea43ab797f555..8c8118c3db308 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -656,6 +656,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane, struct drm_framebuffer *fb = state->fb; struct vop_win *vop_win = to_vop_win(plane); const struct vop_win_data *win = vop_win->data; + int i; int ret; struct drm_rect clip; int min_scale = win->phy->scl ? FRAC_16_16(1, 8) : @@ -697,6 +698,25 @@ static int vop_plane_atomic_check(struct drm_plane *plane, return -EINVAL; } + if (state->ctm) { + struct drm_color_ctm* color_ctm = (struct drm_color_ctm*)state->ctm->data; + if (state->ctm->length != sizeof(struct drm_color_ctm)) { + DRM_ERROR("Invalid PLANE_CTM blob size.\n"); + return -EINVAL; + } + + for (i = 0; i < 9; i++) { + /* + * YUV2YUV R2R registers have a signed fixed point S2.10 format. + * The input values, that are in signed fixed point S31.32 format, + * can be converted only if the first 30 MSBs are all 1s or 0s. + */ + uint32_t msbs = (uint32_t) (color_ctm->matrix[i] >> 34); + if (msbs != ~0u && msbs != 0) + return -EOVERFLOW; + } + } + return 0; } @@ -816,6 +836,31 @@ static void vop_plane_atomic_update(struct drm_plane *plane, } } + if (!win_index) { + VOP_YUV2YUV_SET(vop, win0_r2r_en, !!state->ctm); + } else if (win_index == 1) { + VOP_YUV2YUV_SET(vop, win1_r2r_en, !!state->ctm); + } else if (win_index == 2) { + VOP_YUV2YUV_SET(vop, win2_r2r_en, !!state->ctm); + } + if (state->ctm) { + struct drm_color_ctm* color_ctm = (struct drm_color_ctm*)state->ctm->data; + /* + * Convert matrix values from fixed point S31.32 to S2.10, by discarding + * the lowest 22 bits. + */ + for (i = 0; i < 9; i++) { + uint32_t value = (color_ctm->matrix[i] >> 22) & 0x1FFF; + if (!win_index) { + VOP_YUV2YUV_SET(vop, win0_r2r_coefficients[i], value); + } else if (win_index == 1){ + VOP_YUV2YUV_SET(vop, win1_r2r_coefficients[i], value); + } else if (win_index == 2) { + VOP_YUV2YUV_SET(vop, win2_r2r_coefficients[i], value); + } + } + } + if (win->phy->scl) scl_vop_cal_scl_fac(vop, win, actual_w, actual_h, drm_rect_width(dest), drm_rect_height(dest),