Received: by 10.213.65.68 with SMTP id h4csp283641imn; Tue, 13 Mar 2018 04:23:49 -0700 (PDT) X-Google-Smtp-Source: AG47ELs1aoei9s1RYSS4JEl9eCnNpPvYAERkyneDmKP8ShF0JqMkUeSI8LFmjn8IgVWhGc0SmzqG X-Received: by 10.98.251.5 with SMTP id x5mr277460pfm.18.1520940229745; Tue, 13 Mar 2018 04:23:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520940229; cv=none; d=google.com; s=arc-20160816; b=H659Xhj9nQDXioCW8KlcFU8qKqY2fkdAOM4AF4zY99sYQXJLG5ShC21Xq6ZAxrj+yF eFr48VEYJIJ2PIBbFGYCX9D3dTdKGIcofjXUUK7GOtnZATA1+qPprxWedT6mZ889T59n RBQh7ANV8bUyszqugFgPnDmVvcE3iF23bmZStkxiwXe7RygnUOdeWNhszopbLmEOBpeF LknBj1nyHSJw/YmnCQOZ+Q5w0mkJIYK7DBLqZik8pOselOOPNK0Prdj22vJzvAeRHHsH tOSewJmarQyo4M0bEJB/efDnugQ4BYO4THhJeSC4UT74NdzxV8Yo4Xf5fUZDk5cbQXfA 3lrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=HjXgL9u03cgps7vKfDSUQrrjVXqxjhD5+IwMa8v/Ob4=; b=ojribmrt0CwAoUb8uD3Ifq+H8YQRmDgfwAtcrZNhAXDcmDoXhwXaSTLhrPbBQRqmR4 mGV5Swz7xCU9WfSCY1HZeKmOWibbMRoEWCp++eZyEA5b4QgNWiW9oQbudNJTSpbIIj3s BkCfuV6z2pab1t6UHjIDgJkCD1yjcFJjIl4NRe7bz9LhkP2vRXyZ5gLzpDSs0wudDPI3 GH0giFveEJBjl/h+XKNPYk4X1K+zu7zDxoTbQJ34TN7eSUmQqmFKl1fpu3AGegBzMVZU GRi8VgnwIvjexQ7gtXIfIlDsMcBBHwEeQ/P82F+r+86YZbR+MF9wnCBVyYeOys/9A+Gj ayRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@micronovasrl.com header.s=dkim header.b=Quz3bavl; 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 32-v6si38752plg.555.2018.03.13.04.23.33; Tue, 13 Mar 2018 04:23:49 -0700 (PDT) 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=temperror (no key for signature) header.i=@micronovasrl.com header.s=dkim header.b=Quz3bavl; 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 S932866AbeCMLVN (ORCPT + 99 others); Tue, 13 Mar 2018 07:21:13 -0400 Received: from mail.micronovasrl.com ([212.103.203.10]:56032 "EHLO mail.micronovasrl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932576AbeCMLVM (ORCPT ); Tue, 13 Mar 2018 07:21:12 -0400 Received: from mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) by mail.micronovasrl.com (Postfix) with ESMTP id C7A68B004C2 for ; Tue, 13 Mar 2018 12:21:10 +0100 (CET) Authentication-Results: mail.micronovasrl.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=micronovasrl.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=micronovasrl.com; h=x-mailer:message-id:date:date:subject:subject:to:from:from; s=dkim; t=1520940069; x=1521804070; bh=lbF3QvDcbIp+JsNLvcTJY6Ot MwDLzQDm9GGw/d9S94Q=; b=Quz3bavloNdUDlkqJTQ3l7e8VKQ4lMNN5POgKIIO mmsv2PIt1oVqXz/HbF/nb5Jr4LdjbOXrFPDvECWUhnxiBZ2qaiOGch6qZQ+VqJeZ q1WBZp41UyEBUtVEHnpl8vLiKwFM7a3JL/uMqNYuAOfssbmZn3hNOiXHXHzlWHzp bBY= X-Virus-Scanned: Debian amavisd-new at mail.micronovasrl.com X-Spam-Flag: NO X-Spam-Score: -2.9 X-Spam-Level: X-Spam-Status: No, score=-2.9 tagged_above=-10 required=4.5 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9] autolearn=unavailable autolearn_force=no Received: from mail.micronovasrl.com ([127.0.0.1]) by mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id M7gDrku5lzyF for ; Tue, 13 Mar 2018 12:21:09 +0100 (CET) Received: from localhost.localdomain (62-11-51-166.dialup.tiscali.it [62.11.51.166]) by mail.micronovasrl.com (Postfix) with ESMTPSA id 24C64B00430; Tue, 13 Mar 2018 12:21:08 +0100 (CET) From: Giulio Benetti To: Maxime Ripard Cc: David Airlie , Chen-Yu Tsai , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Giulio Benetti Subject: [PATCH v2] drm/sun4i: add lvds mode_valid function Date: Tue, 13 Mar 2018 12:20:19 +0100 Message-Id: <1520940019-68977-1-git-send-email-giulio.benetti@micronovasrl.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org mode_valid function is missing for lvds. Add it making it pointed by encoder helper functions. Signed-off-by: Giulio Benetti --- drivers/gpu/drm/sun4i/sun4i_lvds.c | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_lvds.c b/drivers/gpu/drm/sun4i/sun4i_lvds.c index be3f14d..bffff4c 100644 --- a/drivers/gpu/drm/sun4i/sun4i_lvds.c +++ b/drivers/gpu/drm/sun4i/sun4i_lvds.c @@ -94,9 +94,64 @@ static void sun4i_lvds_encoder_disable(struct drm_encoder *encoder) } } +static enum drm_mode_status sun4i_lvds_encoder_mode_valid(struct drm_encoder *crtc, + const struct drm_display_mode *mode) +{ + struct sun4i_lvds *lvds = drm_encoder_to_sun4i_lvds(crtc); + struct sun4i_tcon *tcon = lvds->tcon; + u32 hsync = mode->hsync_end - mode->hsync_start; + u32 vsync = mode->vsync_end - mode->vsync_start; + unsigned long rate = mode->clock * 1000; + long rounded_rate; + + DRM_DEBUG_DRIVER("Validating modes...\n"); + + if (hsync < 1) + return MODE_HSYNC_NARROW; + + if (hsync > 0x3ff) + return MODE_HSYNC_WIDE; + + if ((mode->hdisplay < 1) || (mode->htotal < 1)) + return MODE_H_ILLEGAL; + + if ((mode->hdisplay > 0x7ff) || (mode->htotal > 0xfff)) + return MODE_BAD_HVALUE; + + DRM_DEBUG_DRIVER("Horizontal parameters OK\n"); + + if (vsync < 1) + return MODE_VSYNC_NARROW; + + if (vsync > 0x3ff) + return MODE_VSYNC_WIDE; + + if ((mode->vdisplay < 1) || (mode->vtotal < 1)) + return MODE_V_ILLEGAL; + + if ((mode->vdisplay > 0x7ff) || (mode->vtotal > 0xfff)) + return MODE_BAD_VVALUE; + + DRM_DEBUG_DRIVER("Vertical parameters OK\n"); + + tcon->dclk_min_div = 7; + tcon->dclk_max_div = 7; + rounded_rate = clk_round_rate(tcon->dclk, rate); + if (rounded_rate < rate) + return MODE_CLOCK_LOW; + + if (rounded_rate > rate) + return MODE_CLOCK_HIGH; + + DRM_DEBUG_DRIVER("Clock rate OK\n"); + + return MODE_OK; +} + static const struct drm_encoder_helper_funcs sun4i_lvds_enc_helper_funcs = { .disable = sun4i_lvds_encoder_disable, .enable = sun4i_lvds_encoder_enable, + .mode_valid = sun4i_lvds_encoder_mode_valid, }; static const struct drm_encoder_funcs sun4i_lvds_enc_funcs = { -- 2.7.4