Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3215693imu; Sat, 24 Nov 2018 00:18:10 -0800 (PST) X-Google-Smtp-Source: AJdET5dXXAoKYIuQK8q5EdsEEfTSBdHEdPaCyZCJygnKhClv+QgnMXsc3dnEKuRqLW/2kde8uV/U X-Received: by 2002:a62:6001:: with SMTP id u1-v6mr19626080pfb.130.1543047490120; Sat, 24 Nov 2018 00:18:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543047490; cv=none; d=google.com; s=arc-20160816; b=D96uO2gvTIseQFkeq+RnurZV7SpRIswwdZZ8v+fYnp8phYQasOyJKJE7Urd0vun9sE xAjwYI5s4P3NmxsebAZyNt8jEyg0Pv5A3D2WGPJ0PtqOvbEGgsYCGyKDQ0f3/unyUJce cV/HIzjpLD4Ot4ekGNIFekN3+NbZkfaszkZbhc2UbEUg/GwqnAZ+cPi6HjhaRWi+Jkou xr77dWz/39LLZl6/A9fTIu+jPgItrBAbMr/OKh9Nv6puCHgInmt34mntnFgt3UL4HTLJ tvCgKJtdeeMPDkuBhKypXZ4RujNXnEjj/u0Hl7ZWaV7EAj9QwBd42evpaP0T2P0lZ47/ gIeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Bd94bqEgYma5YRmqtnPZZUfbNE9njErfH1T3FPhRdTY=; b=aorkT50wYTL2Ut4wq4EnA1Iwy26T3OXMmIw7pgiV8xJsoOdNclr9iEv/pNMSP2pFIg jUUahR7JjiLRbum12IrKMY0wt4cv7255k0F9z6E35zOyh2FKvgHFvaJwzkCJNAaIcPUq yB2hpFDh1HCc1kWwQDPmEzfRhKddJj/OxzTZ8HzlCkLv/hBR5lE0HYfkjDXyN4t4guUe 81yP06JNa+0l/fcYkfERPrNprlErTAQPh4lKxpJofzPcnBPbd5QPw1bva7Lj0X7WRvbt ySF+0Q4rGgq/NNZqDB0PzZi6HYO9Sd4+ncmRn2i3fQMInOD1jbVgZa+HRWxXI/2v4qRJ YCjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6si16704842pfv.181.2018.11.24.00.17.55; Sat, 24 Nov 2018 00:18:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502801AbeKWUKb (ORCPT + 99 others); Fri, 23 Nov 2018 15:10:31 -0500 Received: from mail.bootlin.com ([62.4.15.54]:49418 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502727AbeKWUK1 (ORCPT ); Fri, 23 Nov 2018 15:10:27 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 7126220DF9; Fri, 23 Nov 2018 10:26:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from localhost.localdomain (aaubervilliers-681-1-94-205.w90-88.abo.wanadoo.fr [90.88.35.205]) by mail.bootlin.com (Postfix) with ESMTPSA id 039B220E00; Fri, 23 Nov 2018 10:26:33 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Cc: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Chen-Yu Tsai , Thomas Petazzoni , linux-sunxi@googlegroups.com, Daniel Vetter , Paul Kocialkowski Subject: [PATCH v2 25/43] drm/sun4i: frontend: Apply format sub-sampling to CH1 dimensions Date: Fri, 23 Nov 2018 10:24:57 +0100 Message-Id: <20181123092515.2511-26-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123092515.2511-1-paul.kocialkowski@bootlin.com> References: <20181123092515.2511-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The frontend comes with two "channels", that can be configured independently. When used in YUV mode, the first channel (CH0) represents the luminance component while the second channel (CH1) represents the chrominance. In RGB mode, both have to be configured the same way. Use variables (with the YUV terminology) for each channel's dimensions, calculating the chroma dimensions from the luma dimensions and the sub-sampling factors from the format description. Since the configured size only has pixel precision, the fractional fixed-point part of the source size is dropped for both components to ensure that the scaling factors are accurate. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index 5626334c6e87..4700133b96e0 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -276,16 +276,24 @@ void sun4i_frontend_update_coord(struct sun4i_frontend *frontend, struct drm_plane *plane) { struct drm_plane_state *state = plane->state; + struct drm_framebuffer *fb = state->fb; + uint32_t luma_width, luma_height; + uint32_t chroma_width, chroma_height; /* Set height and width */ DRM_DEBUG_DRIVER("Frontend size W: %u H: %u\n", state->crtc_w, state->crtc_h); + + luma_width = state->src_w >> 16; + luma_height = state->src_h >> 16; + + chroma_width = DIV_ROUND_UP(luma_width, fb->format->hsub); + chroma_height = DIV_ROUND_UP(luma_height, fb->format->vsub); + regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_INSIZE_REG, - SUN4I_FRONTEND_INSIZE(state->src_h >> 16, - state->src_w >> 16)); + SUN4I_FRONTEND_INSIZE(luma_height, luma_width)); regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_INSIZE_REG, - SUN4I_FRONTEND_INSIZE(state->src_h >> 16, - state->src_w >> 16)); + SUN4I_FRONTEND_INSIZE(chroma_height, chroma_width)); regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_OUTSIZE_REG, SUN4I_FRONTEND_OUTSIZE(state->crtc_h, state->crtc_w)); @@ -293,14 +301,14 @@ void sun4i_frontend_update_coord(struct sun4i_frontend *frontend, SUN4I_FRONTEND_OUTSIZE(state->crtc_h, state->crtc_w)); regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_HORZFACT_REG, - state->src_w / state->crtc_w); + (luma_width << 16) / state->crtc_w); regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_HORZFACT_REG, - state->src_w / state->crtc_w); + (chroma_width << 16) / state->crtc_w); regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_VERTFACT_REG, - state->src_h / state->crtc_h); + (luma_height << 16) / state->crtc_h); regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_VERTFACT_REG, - state->src_h / state->crtc_h); + (chroma_height << 16) / state->crtc_h); regmap_write_bits(frontend->regs, SUN4I_FRONTEND_FRM_CTRL_REG, SUN4I_FRONTEND_FRM_CTRL_REG_RDY, -- 2.19.1