Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp12443361ybl; Sat, 28 Dec 2019 12:29:40 -0800 (PST) X-Google-Smtp-Source: APXvYqwgKzDmO5zDaI9d44cX0XCK45Su9C8KgahMhFtVy1FxspA6nU9UJxwOGcLWdwQz9+FQ7s7P X-Received: by 2002:a05:6830:1653:: with SMTP id h19mr50097578otr.305.1577564980131; Sat, 28 Dec 2019 12:29:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577564980; cv=none; d=google.com; s=arc-20160816; b=CDZVwSwnSXEkM3Zj1VT72r7ND6cVZqDF+xXQoyjOZ/ItIOV1tp1TqsrxRlCoJArr6o i2l36yij9ZovufHArjYPHO5T1QxOQt3ASSS0Vc3rwXwhHORYQLu5ZIS4zpTGnQ1+I5hm /f8biuvxHHqn/QpbLt35mwf7ZD7iPY2qxXOZWE9JGdeX/G2wwB46ijsVzTmTMUMlunFi nXxO+G/y9s7Glwda8K9y2VnQphEvdfNr7c8NWIrdYv6oJbQgrCoTPGf8ulBi9gkboXCb Y4NBLGNiz0W0UaRolulHuukL/4gBcvpM5Vt3vilTEtD7KaqfABHv7OMD7SrP8qtbWO4n ZPXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=0Yk+zLVsSDRHOg6D2iiMvRkTjejM32fOXnmZsURk2P4=; b=b51rs8JnL1DCB8BPKGcorACq7UOpE401iswGaCLkpMXi0U2Bz4EfV7RPxN1+nOrcwX z7N/uARbsEIwDlA7aFqQgzPKodCTMChP+gSgIc33lsrH/jmBc8OOg6Hc5a6AZ+oYFnzg aFbld3Ppq+/8MBlSU8yLND/qFyOaL46lXkNwb0h2tQc8BAvJnW1Ty0/+804gYlq7n9Bf hQHRjiFTC8ayFKOt/rUClyb6cVfrPE+vYYXgoCHV9mH91OeRyWJhN66UhgFlYS3X6o1P 6ZMPOjFbFlxOgVFwC2ADYSa6zFLfYWIwNMwsE/jjD6+qFCBQqffM2cKa5/tred/92Esy V3yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@globallogic.com header.s=google header.b=G5vXA9W8; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=globallogic.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r25si14702529otp.280.2019.12.28.12.29.28; Sat, 28 Dec 2019 12:29:40 -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; dkim=pass header.i=@globallogic.com header.s=google header.b=G5vXA9W8; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=globallogic.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726812AbfL1U2n (ORCPT + 99 others); Sat, 28 Dec 2019 15:28:43 -0500 Received: from mail-pj1-f66.google.com ([209.85.216.66]:39284 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726371AbfL1U2m (ORCPT ); Sat, 28 Dec 2019 15:28:42 -0500 Received: by mail-pj1-f66.google.com with SMTP id t101so6451823pjb.4 for ; Sat, 28 Dec 2019 12:28:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=globallogic.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0Yk+zLVsSDRHOg6D2iiMvRkTjejM32fOXnmZsURk2P4=; b=G5vXA9W8+N+c30YAoRsRVjmw7eyC3MnRCXaPm2xC2VrA9nuAWTaRKeP668iDDXlsQp 9mCYnODGdPsm+TyobDSKsg463csJ1Ml3lvs+znsULMBUqvBMAeuF/9icWD4NxofqwLVs vt/NJ6KS3OHxgddv7DS1NbtcAqsu7U9JNxtPzSds+BzPXlCAq63f86WvfEUJ+316Ru5o IMcsmF4QkxidZhDJFqXfHPvYHKW79LAPDkON7RFFeyQOo5K3RqxLR5Qf8PCkYDwhxpDX L9bJQPjRKuo4eQJ+VQAW/LyP3ueIowuIt3sDR1mRIVQ5EdSrIknI5zioZC1TmqDTELYI u3kw== 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=0Yk+zLVsSDRHOg6D2iiMvRkTjejM32fOXnmZsURk2P4=; b=nWI7Mr1W118V2ZSsaGlvCGhpp0Nm8ZU0QYXBwGvGcsd9KM/3+3jSR58XmpPqDOSMYs iZAhAxUo2uMlHDAEjgnWwbLvbhXxQ6NloL9epuj2G9p/QKOnV24P0u4HcABfZIfXkcdV huZjp7E/8J9bb2Ax/XrjD0M5k+kICuIgrebjFzYxaIL15FRaiElgkBGXDh1ovEBA3B9p 5K4TVobdP88PP7MHP1EE7SOlOZCwjWCyQKR6cHO+6/fpMBw9jv4GmET63ocKl+3wv/vb NziZ2LX2iFa7u0m/+701y805Jj+0w0+ZnX9DHX89tdbKCtunrQXF9h2/nCQunjzcFm2W EDnA== X-Gm-Message-State: APjAAAUw7HkWqGlcKPym84/0FmO/rfB+su+kK2dIaPmhq9pHqX0uNRQj 3Yv93O7AGMFluLIJD58Pf3PcIo9GiRY= X-Received: by 2002:a17:90a:25cb:: with SMTP id k69mr35247333pje.121.1577564921974; Sat, 28 Dec 2019 12:28:41 -0800 (PST) Received: from virtualhost-PowerEdge-R810.synapse.com ([195.238.92.107]) by smtp.gmail.com with ESMTPSA id i68sm46771169pfe.173.2019.12.28.12.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Dec 2019 12:28:41 -0800 (PST) From: roman.stratiienko@globallogic.com To: mripard@kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, jernej.skrabec@siol.net Cc: Roman Stratiienko Subject: [RFC 2/4] drm/sun4i: Use CRTC size instead of PRIMARY plane size as mixer frame. Date: Sat, 28 Dec 2019 22:28:16 +0200 Message-Id: <20191228202818.69908-3-roman.stratiienko@globallogic.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191228202818.69908-1-roman.stratiienko@globallogic.com> References: <20191228202818.69908-1-roman.stratiienko@globallogic.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roman Stratiienko According to DRM documentation the only difference between PRIMARY and OVERLAY plane is that each CRTC must have PRIMARY plane and OVERLAY are optional. Allow PRIMARY plane to have dimension different from full-screen. Signed-off-by: Roman Stratiienko --- drivers/gpu/drm/sun4i/sun4i_crtc.c | 4 +++ drivers/gpu/drm/sun4i/sun8i_mixer.c | 35 ++++++++++++++++++++++++++ drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 30 ---------------------- drivers/gpu/drm/sun4i/sunxi_engine.h | 8 ++++++ 4 files changed, 47 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_crtc.c b/drivers/gpu/drm/sun4i/sun4i_crtc.c index 3a153648b369..156ea8f19d7d 100644 --- a/drivers/gpu/drm/sun4i/sun4i_crtc.c +++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c @@ -139,8 +139,12 @@ static void sun4i_crtc_mode_set_nofb(struct drm_crtc *crtc) struct drm_display_mode *mode = &crtc->state->adjusted_mode; struct drm_encoder *encoder = sun4i_crtc_get_encoder(crtc); struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc); + struct sunxi_engine *engine = scrtc->engine; sun4i_tcon_mode_set(scrtc->tcon, encoder, mode); + + if (engine->ops->mode_set) + engine->ops->mode_set(engine, mode); } static const struct drm_crtc_helper_funcs sun4i_crtc_helper_funcs = { diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c index eea4813602b7..bb9a665fd053 100644 --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c @@ -257,6 +257,40 @@ const struct de2_fmt_info *sun8i_mixer_format_info(u32 format) return NULL; } +static void sun8i_mode_set(struct sunxi_engine *engine, + struct drm_display_mode *mode) +{ + u32 dst_w = mode->crtc_hdisplay; + u32 dst_h = mode->crtc_vdisplay; + u32 outsize = SUN8I_MIXER_SIZE(dst_w, dst_h); + bool interlaced = false; + u32 val; + struct sun8i_mixer *mixer = engine_to_sun8i_mixer(engine); + u32 bld_base = sun8i_blender_base(mixer); + + DRM_DEBUG_DRIVER("Mode change, updating global size W: %u H: %u\n", + dst_w, dst_h); + regmap_write(mixer->engine.regs, + SUN8I_MIXER_GLOBAL_SIZE, + outsize); + regmap_write(mixer->engine.regs, + SUN8I_MIXER_BLEND_OUTSIZE(bld_base), outsize); + + interlaced = mode->flags & DRM_MODE_FLAG_INTERLACE; + + if (interlaced) + val = SUN8I_MIXER_BLEND_OUTCTL_INTERLACED; + else + val = 0; + + regmap_update_bits(mixer->engine.regs, + SUN8I_MIXER_BLEND_OUTCTL(bld_base), + SUN8I_MIXER_BLEND_OUTCTL_INTERLACED, + val); + DRM_DEBUG_DRIVER("Switching display mixer interlaced mode %s\n", + interlaced ? "on" : "off"); +} + static void sun8i_atomic_begin(struct sunxi_engine *engine, struct drm_crtc_state *old_state) { @@ -325,6 +359,7 @@ static const struct sunxi_engine_ops sun8i_engine_ops = { .commit = sun8i_mixer_commit, .layers_init = sun8i_layers_init, .atomic_begin = sun8i_atomic_begin, + .mode_set = sun8i_mode_set, }; static struct regmap_config sun8i_mixer_regmap_config = { diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c index c87fd842918e..893076716070 100644 --- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c @@ -99,36 +99,6 @@ static int sun8i_ui_layer_update_coord(struct sun8i_mixer *mixer, int channel, insize = SUN8I_MIXER_SIZE(src_w, src_h); outsize = SUN8I_MIXER_SIZE(dst_w, dst_h); - if (plane->type == DRM_PLANE_TYPE_PRIMARY) { - bool interlaced = false; - u32 val; - - DRM_DEBUG_DRIVER("Primary layer, updating global size W: %u H: %u\n", - dst_w, dst_h); - regmap_write(mixer->engine.regs, - SUN8I_MIXER_GLOBAL_SIZE, - outsize); - regmap_write(mixer->engine.regs, - SUN8I_MIXER_BLEND_OUTSIZE(bld_base), outsize); - - if (state->crtc) - interlaced = state->crtc->state->adjusted_mode.flags - & DRM_MODE_FLAG_INTERLACE; - - if (interlaced) - val = SUN8I_MIXER_BLEND_OUTCTL_INTERLACED; - else - val = 0; - - regmap_update_bits(mixer->engine.regs, - SUN8I_MIXER_BLEND_OUTCTL(bld_base), - SUN8I_MIXER_BLEND_OUTCTL_INTERLACED, - val); - - DRM_DEBUG_DRIVER("Switching display mixer interlaced mode %s\n", - interlaced ? "on" : "off"); - } - /* Set height and width */ DRM_DEBUG_DRIVER("Layer source offset X: %d Y: %d\n", state->src.x1 >> 16, state->src.y1 >> 16); diff --git a/drivers/gpu/drm/sun4i/sunxi_engine.h b/drivers/gpu/drm/sun4i/sunxi_engine.h index 548710a936d5..9783c112d512 100644 --- a/drivers/gpu/drm/sun4i/sunxi_engine.h +++ b/drivers/gpu/drm/sun4i/sunxi_engine.h @@ -108,6 +108,14 @@ struct sunxi_engine_ops { * This function is optional. */ void (*vblank_quirk)(struct sunxi_engine *engine); + + /** + * @mode_set: + * + * This function is optional. + */ + void (*mode_set)(struct sunxi_engine *engine, + struct drm_display_mode *mode); }; /** -- 2.17.1