Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1267943lfc; Wed, 1 Jun 2022 13:38:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5X2Kb/f6SD5xJOjq4lCvc+pCb1Y6E/62DpyVnZUdCfu5+0aKsVusnmUZiDeH9EC3sGTut X-Received: by 2002:a63:455d:0:b0:3fc:7f18:6857 with SMTP id u29-20020a63455d000000b003fc7f186857mr1067332pgk.292.1654115908146; Wed, 01 Jun 2022 13:38:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654115908; cv=none; d=google.com; s=arc-20160816; b=hjGfE7mIB+GYRDXOzySKKWl/ocRsyYzfURdDRX7LvwGVDpSx+a1tRGlC3ua3YA544o y8u2XRxArnMV4Ak3Z9Sp0PZumnXXul2FoPByKweGyynhd5W14dBcXRBCcq6hsoFhl9pe /p1KUPNzyTnnHuuFFrtjSkGSNFW/78iH/D0GeifGAgzLpD+amWT2E23RzhzgeGuly/yw siRg0rFY9b9xK9CEohIyRGYtBW/4aBVeAYyfyGHcULLGaS+x3mlAm3Y3gFbEyLWfzXRH lygnrvx24stqUiUPP3V6D6XYtqNJxxO/MpJrcNLB96byR9woPNoiOMaCYpV93FqSnNup swug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=lCOUyyDM2EIXc4RPNW8pyLJMNdGYc/IzffrR0m7ZqEw=; b=DWVyZHo8kcc1uid6uPwOLRT4j/MDiZRqs2mVXQu6sOXuufA03qvm+vdZdWjRAMcM52 gNEjL1Fmqm6UmZ/AuKPjqZXTGVlWavE+the+HlsksYETuaf0HEWgl6+Jf6tM41Uvh9Ew SrlHIglnTeod2ZHlZa4lCYrtboUkNZx4fzIqGJL/EF485zyySsIEzViTBahXe0Z3kAeQ nvq29UlYczklv/Z7CwGa1BnL4N7x7HJX+hSOiFYcf4bigfRjK27jmhf/O8n10QuKgmfb R8eUiq0OH4/45cwUIlNYxqTlqgQ/rcr01pV/AKkhN7ra8QJtxdMmnJLXvFjX3WzGoUCw fVPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=B2MfWPPe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b19-20020a056a000cd300b0050cf84f4e8fsi3133400pfv.29.2022.06.01.13.38.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:38:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=B2MfWPPe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2B42C289718; Wed, 1 Jun 2022 12:47:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349707AbiFAI5R (ORCPT + 99 others); Wed, 1 Jun 2022 04:57:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238309AbiFAI5P (ORCPT ); Wed, 1 Jun 2022 04:57:15 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 021B549C8E for ; Wed, 1 Jun 2022 01:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654073831; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lCOUyyDM2EIXc4RPNW8pyLJMNdGYc/IzffrR0m7ZqEw=; b=B2MfWPPemgZpykUZ4iF9Y08YU8T5+chDzAmHKjKhx6k0qc+v3BDhfJ+YXHYlIxhsrXpGJA uYjZ3j2AMGRBkA8aspIdAGWSjgusrc0O+n7shsVNkQ86rdhEIQRIzMEon0XTITv0PpHX1V pAeY8TPFPt4EGzQ5qUvCSD568pttHts= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-516-_RbTV0vMNyW01Nt8XPXAnQ-1; Wed, 01 Jun 2022 04:57:09 -0400 X-MC-Unique: _RbTV0vMNyW01Nt8XPXAnQ-1 Received: by mail-ej1-f70.google.com with SMTP id p7-20020a170906614700b006f87f866117so591357ejl.21 for ; Wed, 01 Jun 2022 01:57:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=lCOUyyDM2EIXc4RPNW8pyLJMNdGYc/IzffrR0m7ZqEw=; b=qB/l2zzMh3VFY/iCPoyODWdLhwzPf46TYrdTd10YwxXeeY+a55gpl9yW3+myr4pp8V hRS/hHnMp3RPFcJXJ/q78Nq6gF54RHCpbz9gO0hZKoBxAryM5CtPVeYnlDiNgf7sz6ZY UqA6/ygV94Bdn8divyzKsiCHADeF5rcCaB7ds4aG/VVhT1GoSLH7wmju8zN6n+WjSn3k M4UCv5C7dJ08Avnc78yRt4sP8dzIzL7e0SIl1V2ptYVBwr2V3nYzNqMOt53b8L6IW2kA O3vk84QDaKHVv/OwnHmt4M4/sfUhzdXqhrS0pgFE00iznP+zDCYzWqED4C5gHIPI70ZY DYSQ== X-Gm-Message-State: AOAM533V5uZgRzMQCDfgN3W37qPI1Bdj/HfZ275DUtBaKXDuxr9VJSCZ EL+S3z1+O0K8ox2z7WORo1C/0ogKWffv9b1r2RyHggsvO5AAIIcsnzUoUuzKS+Vu7evat9+00UU W4jB0HqSJrlbMeUXnyVMJMxMS X-Received: by 2002:a17:907:3ea0:b0:6ff:7d7a:480d with SMTP id hs32-20020a1709073ea000b006ff7d7a480dmr12015284ejc.750.1654073828312; Wed, 01 Jun 2022 01:57:08 -0700 (PDT) X-Received: by 2002:a17:907:3ea0:b0:6ff:7d7a:480d with SMTP id hs32-20020a1709073ea000b006ff7d7a480dmr12015265ejc.750.1654073828091; Wed, 01 Jun 2022 01:57:08 -0700 (PDT) Received: from [192.168.43.127] ([109.36.130.134]) by smtp.gmail.com with ESMTPSA id y22-20020aa7ca16000000b0042dcbc3f302sm619741eds.36.2022.06.01.01.57.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Jun 2022 01:57:07 -0700 (PDT) Message-ID: Date: Wed, 1 Jun 2022 10:57:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 8/8] drm/mediatek: Config orientation property if panel provides it Content-Language: en-US To: Hsin-Yi Wang , Chun-Kuang Hu Cc: Thierry Reding , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, Rob Clark , Stephen Boyd , Douglas Anderson , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20220601081823.1038797-1-hsinyi@chromium.org> <20220601081823.1038797-9-hsinyi@chromium.org> From: Hans de Goede In-Reply-To: <20220601081823.1038797-9-hsinyi@chromium.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 6/1/22 10:18, Hsin-Yi Wang wrote: > Panel orientation property should be set before drm_dev_register(). > Mediatek drm driver calls drm_dev_register() in .bind(). However, most > panels sets orientation property relatively late, mostly in .get_modes() > callback, since this is when they are able to get the connector and > binds the orientation property to it, though the value should be known > when the panel is probed. > > Let the drm driver check if the remote end point is a panel and if it > contains the orientation property. If it does, set it before > drm_dev_register() is called. > > Signed-off-by: Hsin-Yi Wang > --- > The concept is the same as the previous version. > https://patchwork.kernel.org/project/linux-mediatek/patch/20220530113033.124072-1-hsinyi@chromium.org/ > The only difference is, it now uses the panel API instead of parsing > orientation from the driver. > --- > drivers/gpu/drm/mediatek/mtk_dsi.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c > index bd3f5b485085..12836a697f56 100644 > --- a/drivers/gpu/drm/mediatek/mtk_dsi.c > +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c > @@ -185,6 +185,7 @@ struct mtk_dsi { > struct drm_encoder encoder; > struct drm_bridge bridge; > struct drm_bridge *next_bridge; > + struct drm_panel *panel; > struct drm_connector *connector; > struct phy *phy; > > @@ -822,6 +823,16 @@ static int mtk_dsi_encoder_init(struct drm_device *drm, struct mtk_dsi *dsi) > ret = PTR_ERR(dsi->connector); > goto err_cleanup_encoder; > } > + > + /* Read panel orientation */ > + if (dsi->panel) { > + enum drm_panel_orientation orientation; > + > + orientation = drm_panel_get_orientation(dsi->panel); > + if (orientation != DRM_MODE_PANEL_ORIENTATION_UNKNOWN) > + drm_connector_set_panel_orientation(dsi->connector, orientation); > + } > + > drm_connector_attach_encoder(dsi->connector, &dsi->encoder); > > return 0; drm_connector_set_panel_orientation() is a no-op when called with DRM_MODE_PANEL_ORIENTATION_UNKNOWN, so the check for this is not necessary. This allows this to be simplified to: /* Read panel orientation */ if (dsi->panel) drm_connector_set_panel_orientation(dsi->connector, drm_panel_get_orientation(dsi->panel)); Note since drm_panel_get_orientation() checks for a NULL panel, you could even drop the "if (dsi->panel)", but I think the meaning of the code is more clear with that present. > @@ -837,6 +848,9 @@ static int mtk_dsi_bind(struct device *dev, struct device *master, void *data) > struct drm_device *drm = data; > struct mtk_dsi *dsi = dev_get_drvdata(dev); > > + /* Get panel if existed */ > + ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0, &dsi->panel, NULL); > + Check ret? or maybe not assign to ret ? I understand some errors are expected so maybe something like: if (ret && ret != -ENODEV) return ret; ? Note -ENODEV is probably not the right error the check for! Regards, Hans > ret = mtk_dsi_encoder_init(drm, dsi); > if (ret) > return ret;