Message ID | df4099d79c985c73bdc890eb0e026494b7fa5c96.1680273039.git.geert+renesas@glider.be |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp630916vqo; Fri, 31 Mar 2023 08:06:20 -0700 (PDT) X-Google-Smtp-Source: AKy350Y9RfQYCndprFFBFznkp6KPnUGKE00YMSIiv9e8bkLvsnU+o9aT7B6BUKig1IavQzef4MnP X-Received: by 2002:a17:907:7784:b0:930:e2c:ddc3 with SMTP id ky4-20020a170907778400b009300e2cddc3mr26733918ejc.72.1680275180037; Fri, 31 Mar 2023 08:06:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680275180; cv=none; d=google.com; s=arc-20160816; b=Wr7eJoLc54vsyEZjjbKYmn7I24vTOgKaMOppsgEkj+3HdSafwWh0uxA2ToU0h+Usjl +Suy2CtGGu/AZ0JpF7/Zo7LtGKRasV8EabtXboVW12Gjy1tUrDImis4jzVIqyTz+nwA/ /leXPxtajS4JGR4HozlJ65fNRoQaz1HbmtOWvioNxl+iM7tniIqIlVD3F9U4U9zWhvre uvsax8bxMUgel5g16FGjaV5t/esX2pZtTr65j8lXq5sL3RVnIhBYzYQR9c5dQORDAu0J nweMM0xllhLQXLrJQA76zSncACtP0+HJUgXoYFgGRdI8n1usgHidOazmj0JLgg/955WG B5ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=+8SOPXPUwkhPiNRO52O13EH03/wXsQzRe14BeVil9p4=; b=SL9gKgIb7OWRt07reUum0chm/YEqPbqxVz9pEav+kugPqiKnYkF4kjgUi1GzVOFz/9 M/xMR8H10hidsx6Yp8JV6G6AsnqTqMA/FUx/yTCT9Q6lYlS7wkjySgTHzLyJIJOqRmp2 c2D3TSdvecNIEYuUJ0p1YIL9j3r9JH1gw51DMAra6wH9Y1PIq4oyrZd0E17FWn5rgBwq RKf46NG/YJxVM0hH/322IwSXmALKDNf6VjNjqVf6blU42hHay58m7qdPn8tzHJ5IK/q/ +Fo7SI1rhvCDhMJubMel0iNHKnf8tjj+QFZ1mkPkkGSxvdqwo/u2YhsXIHknV2uDfjKK vTSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m8-20020a1709062b8800b0093defbd6270si2000442ejg.1015.2023.03.31.08.05.56; Fri, 31 Mar 2023 08:06:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233069AbjCaOxU (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Fri, 31 Mar 2023 10:53:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232997AbjCaOxG (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 31 Mar 2023 10:53:06 -0400 Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE4A02063B for <linux-kernel@vger.kernel.org>; Fri, 31 Mar 2023 07:52:41 -0700 (PDT) Received: from ramsan.of.borg ([84.195.187.55]) by albert.telenet-ops.be with bizsmtp id f2se2900R1C8whw062sej5; Fri, 31 Mar 2023 16:52:39 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from <geert@linux-m68k.org>) id 1piG2N-00FUgh-5E; Fri, 31 Mar 2023 16:48:16 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from <geert@linux-m68k.org>) id 1piG36-008fIa-J5; Fri, 31 Mar 2023 16:48:16 +0200 From: Geert Uytterhoeven <geert+renesas@glider.be> To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>, Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch> Cc: dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven <geert+renesas@glider.be> Subject: [PATCH 3/5] drm: shmobile: Switch to drm_crtc_init_with_planes() Date: Fri, 31 Mar 2023 16:48:09 +0200 Message-Id: <df4099d79c985c73bdc890eb0e026494b7fa5c96.1680273039.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: <cover.1680273039.git.geert+renesas@glider.be> References: <cover.1680273039.git.geert+renesas@glider.be> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.4 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761896226715949249?= X-GMAIL-MSGID: =?utf-8?q?1761896226715949249?= |
Series |
drm: shmobile: Fixes and enhancements
|
|
Commit Message
Geert Uytterhoeven
March 31, 2023, 2:48 p.m. UTC
The SH-Mobile DRM driver uses the legacy drm_crtc_init(), which
advertizes only the formats in safe_modeset_formats[] (XR24 and AR24) as
being supported.
Switch to drm_crtc_init_with_planes(), and advertize all supported
(A)RGB modes, so we can use RGB565 as the default mode for the console.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 30 +++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
Comments
Hi Geert, Thank you for the patch. On Fri, Mar 31, 2023 at 04:48:09PM +0200, Geert Uytterhoeven wrote: > The SH-Mobile DRM driver uses the legacy drm_crtc_init(), which > advertizes only the formats in safe_modeset_formats[] (XR24 and AR24) as > being supported. > > Switch to drm_crtc_init_with_planes(), and advertize all supported > (A)RGB modes, so we can use RGB565 as the default mode for the console. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> > --- > drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 30 +++++++++++++++++++++-- > 1 file changed, 28 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c > index 08dc1428aa16caf0..11dd2bc803e7cb62 100644 > --- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c > +++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c > @@ -18,6 +18,7 @@ > #include <drm/drm_gem_dma_helper.h> > #include <drm/drm_modeset_helper.h> > #include <drm/drm_modeset_helper_vtables.h> > +#include <drm/drm_plane_helper.h> > #include <drm/drm_probe_helper.h> > #include <drm/drm_simple_kms_helper.h> > #include <drm/drm_vblank.h> > @@ -478,16 +479,41 @@ static const struct drm_crtc_funcs crtc_funcs = { > .disable_vblank = shmob_drm_disable_vblank, > }; > > +static const uint32_t modeset_formats[] = { > + DRM_FORMAT_RGB565, > + DRM_FORMAT_RGB888, > + DRM_FORMAT_ARGB8888, > + DRM_FORMAT_XRGB8888, > +}; > + > +static const struct drm_plane_funcs primary_plane_funcs = { > + DRM_PLANE_NON_ATOMIC_FUNCS, > +}; > + > int shmob_drm_crtc_create(struct shmob_drm_device *sdev) > { > struct drm_crtc *crtc = &sdev->crtc.crtc; > + struct drm_plane *primary; > int ret; > > sdev->crtc.dpms = DRM_MODE_DPMS_OFF; > > - ret = drm_crtc_init(sdev->ddev, crtc, &crtc_funcs); > - if (ret < 0) > + primary = __drm_universal_plane_alloc(sdev->ddev, sizeof(*primary), 0, > + 0, &primary_plane_funcs, > + modeset_formats, > + ARRAY_SIZE(modeset_formats), > + NULL, DRM_PLANE_TYPE_PRIMARY, > + NULL); > + if (IS_ERR(primary)) > + return PTR_ERR(primary); This seems like a bit of a hack to me. Why don't you use the planes created by shmob_drm_plane_create() instead of allocating a new one ? > + > + ret = drm_crtc_init_with_planes(sdev->ddev, crtc, primary, NULL, > + &crtc_funcs, NULL); > + if (ret < 0) { > + drm_plane_cleanup(primary); > + kfree(primary); > return ret; > + } > > drm_crtc_helper_add(crtc, &crtc_helper_funcs); >
Hi Laurent, Thanks for your comments! On Wed, Apr 5, 2023 at 5:59 AM Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote: > On Fri, Mar 31, 2023 at 04:48:09PM +0200, Geert Uytterhoeven wrote: > > The SH-Mobile DRM driver uses the legacy drm_crtc_init(), which > > advertizes only the formats in safe_modeset_formats[] (XR24 and AR24) as > > being supported. > > > > Switch to drm_crtc_init_with_planes(), and advertize all supported > > (A)RGB modes, so we can use RGB565 as the default mode for the console. > > > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> > > --- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c > > +++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c > > @@ -18,6 +18,7 @@ > > #include <drm/drm_gem_dma_helper.h> > > #include <drm/drm_modeset_helper.h> > > #include <drm/drm_modeset_helper_vtables.h> > > +#include <drm/drm_plane_helper.h> > > #include <drm/drm_probe_helper.h> > > #include <drm/drm_simple_kms_helper.h> > > #include <drm/drm_vblank.h> > > @@ -478,16 +479,41 @@ static const struct drm_crtc_funcs crtc_funcs = { > > .disable_vblank = shmob_drm_disable_vblank, > > }; > > > > +static const uint32_t modeset_formats[] = { > > + DRM_FORMAT_RGB565, > > + DRM_FORMAT_RGB888, > > + DRM_FORMAT_ARGB8888, > > + DRM_FORMAT_XRGB8888, > > +}; > > + > > +static const struct drm_plane_funcs primary_plane_funcs = { > > + DRM_PLANE_NON_ATOMIC_FUNCS, > > +}; > > + > > int shmob_drm_crtc_create(struct shmob_drm_device *sdev) > > { > > struct drm_crtc *crtc = &sdev->crtc.crtc; > > + struct drm_plane *primary; > > int ret; > > > > sdev->crtc.dpms = DRM_MODE_DPMS_OFF; > > > > - ret = drm_crtc_init(sdev->ddev, crtc, &crtc_funcs); > > - if (ret < 0) > > + primary = __drm_universal_plane_alloc(sdev->ddev, sizeof(*primary), 0, > > + 0, &primary_plane_funcs, > > + modeset_formats, > > + ARRAY_SIZE(modeset_formats), > > + NULL, DRM_PLANE_TYPE_PRIMARY, > > + NULL); > > + if (IS_ERR(primary)) > > + return PTR_ERR(primary); > > This seems like a bit of a hack to me. Why don't you use the planes I'm following what Thomas did in the nouveau driver.... > created by shmob_drm_plane_create() instead of allocating a new one ? Is that possible? shmob_drm_plane_create() creates overlay planes, while this is for the primary plane. > > > + > > + ret = drm_crtc_init_with_planes(sdev->ddev, crtc, primary, NULL, > > + &crtc_funcs, NULL); > > + if (ret < 0) { > > + drm_plane_cleanup(primary); > > + kfree(primary); > > return ret; > > + } > > > > drm_crtc_helper_add(crtc, &crtc_helper_funcs); Gr{oetje,eeting}s, Geert
Hi Geert, On Mon, Apr 10, 2023 at 11:35:56AM +0200, Geert Uytterhoeven wrote: > On Wed, Apr 5, 2023 at 5:59 AM Laurent Pinchart wrote: > > On Fri, Mar 31, 2023 at 04:48:09PM +0200, Geert Uytterhoeven wrote: > > > The SH-Mobile DRM driver uses the legacy drm_crtc_init(), which > > > advertizes only the formats in safe_modeset_formats[] (XR24 and AR24) as > > > being supported. > > > > > > Switch to drm_crtc_init_with_planes(), and advertize all supported > > > (A)RGB modes, so we can use RGB565 as the default mode for the console. > > > > > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> > > > > --- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c > > > +++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c > > > @@ -18,6 +18,7 @@ > > > #include <drm/drm_gem_dma_helper.h> > > > #include <drm/drm_modeset_helper.h> > > > #include <drm/drm_modeset_helper_vtables.h> > > > +#include <drm/drm_plane_helper.h> > > > #include <drm/drm_probe_helper.h> > > > #include <drm/drm_simple_kms_helper.h> > > > #include <drm/drm_vblank.h> > > > @@ -478,16 +479,41 @@ static const struct drm_crtc_funcs crtc_funcs = { > > > .disable_vblank = shmob_drm_disable_vblank, > > > }; > > > > > > +static const uint32_t modeset_formats[] = { > > > + DRM_FORMAT_RGB565, > > > + DRM_FORMAT_RGB888, > > > + DRM_FORMAT_ARGB8888, > > > + DRM_FORMAT_XRGB8888, > > > +}; > > > + > > > +static const struct drm_plane_funcs primary_plane_funcs = { > > > + DRM_PLANE_NON_ATOMIC_FUNCS, > > > +}; > > > + > > > int shmob_drm_crtc_create(struct shmob_drm_device *sdev) > > > { > > > struct drm_crtc *crtc = &sdev->crtc.crtc; > > > + struct drm_plane *primary; > > > int ret; > > > > > > sdev->crtc.dpms = DRM_MODE_DPMS_OFF; > > > > > > - ret = drm_crtc_init(sdev->ddev, crtc, &crtc_funcs); > > > - if (ret < 0) > > > + primary = __drm_universal_plane_alloc(sdev->ddev, sizeof(*primary), 0, > > > + 0, &primary_plane_funcs, > > > + modeset_formats, > > > + ARRAY_SIZE(modeset_formats), > > > + NULL, DRM_PLANE_TYPE_PRIMARY, > > > + NULL); > > > + if (IS_ERR(primary)) > > > + return PTR_ERR(primary); > > > > This seems like a bit of a hack to me. Why don't you use the planes > > I'm following what Thomas did in the nouveau driver.... > > > created by shmob_drm_plane_create() instead of allocating a new one ? > > Is that possible? shmob_drm_plane_create() creates overlay planes, > while this is for the primary plane. You're right, for some reason I overlooked that. Sorry for the noise. It would be good to move handling of the primary plane to shmob_drm_plane.c, but that's for later, when moving the driver to the atomic API. For now, Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> > > > + > > > + ret = drm_crtc_init_with_planes(sdev->ddev, crtc, primary, NULL, > > > + &crtc_funcs, NULL); > > > + if (ret < 0) { > > > + drm_plane_cleanup(primary); > > > + kfree(primary); > > > return ret; > > > + } > > > > > > drm_crtc_helper_add(crtc, &crtc_helper_funcs);
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c index 08dc1428aa16caf0..11dd2bc803e7cb62 100644 --- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c +++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c @@ -18,6 +18,7 @@ #include <drm/drm_gem_dma_helper.h> #include <drm/drm_modeset_helper.h> #include <drm/drm_modeset_helper_vtables.h> +#include <drm/drm_plane_helper.h> #include <drm/drm_probe_helper.h> #include <drm/drm_simple_kms_helper.h> #include <drm/drm_vblank.h> @@ -478,16 +479,41 @@ static const struct drm_crtc_funcs crtc_funcs = { .disable_vblank = shmob_drm_disable_vblank, }; +static const uint32_t modeset_formats[] = { + DRM_FORMAT_RGB565, + DRM_FORMAT_RGB888, + DRM_FORMAT_ARGB8888, + DRM_FORMAT_XRGB8888, +}; + +static const struct drm_plane_funcs primary_plane_funcs = { + DRM_PLANE_NON_ATOMIC_FUNCS, +}; + int shmob_drm_crtc_create(struct shmob_drm_device *sdev) { struct drm_crtc *crtc = &sdev->crtc.crtc; + struct drm_plane *primary; int ret; sdev->crtc.dpms = DRM_MODE_DPMS_OFF; - ret = drm_crtc_init(sdev->ddev, crtc, &crtc_funcs); - if (ret < 0) + primary = __drm_universal_plane_alloc(sdev->ddev, sizeof(*primary), 0, + 0, &primary_plane_funcs, + modeset_formats, + ARRAY_SIZE(modeset_formats), + NULL, DRM_PLANE_TYPE_PRIMARY, + NULL); + if (IS_ERR(primary)) + return PTR_ERR(primary); + + ret = drm_crtc_init_with_planes(sdev->ddev, crtc, primary, NULL, + &crtc_funcs, NULL); + if (ret < 0) { + drm_plane_cleanup(primary); + kfree(primary); return ret; + } drm_crtc_helper_add(crtc, &crtc_helper_funcs);