mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Aditya Garg <gargaditya08@live.com>
Cc: "maarten.lankhorst@linux.intel.com"
	<maarten.lankhorst@linux.intel.com>,
	"mripard@kernel.org" <mripard@kernel.org>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"daniel@ffwll.ch" <daniel@ffwll.ch>,
	"Jiri Kosina" <jikos@kernel.org>,
	"bentiss@kernel.org" <bentiss@kernel.org>,
	"Thomas Weißschuh" <thomas@t-8ch.de>,
	"Orlando Chamberlain" <orlandoch.dev@gmail.com>,
	"Kerem Karabay" <kekrby@gmail.com>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>
Subject: Re: [RFC PATCH v5 10/10] drm/tiny: add driver for Apple Touch Bars in x86 Macs
Date: Mon, 17 Feb 2025 09:04:28 +0100	[thread overview]
Message-ID: <3df4e526-66a4-4dcd-8c6e-adacd9a2a5aa@suse.de> (raw)
In-Reply-To: <1C5F4A8E-018C-4A39-B8EE-CDDDF9FABD7A@live.com>

Hi Aditya,

the code looks correct overall. There's one place where I think it 
fails. See below.

Am 15.02.25 um 14:43 schrieb Aditya Garg:
[...]
> DEFINE_DRM_GEM_FOPS(appletbdrm_drm_fops);
> @@ -484,10 +537,38 @@ static const struct drm_driver appletbdrm_drm_driver = {
> static int appletbdrm_setup_mode_config(struct appletbdrm_device *adev)
> {
> 	struct drm_connector *connector = &adev->connector;
> +	struct drm_plane *primary_plane;
> +	struct drm_crtc *crtc;
> +	struct drm_encoder *encoder;
> 	struct drm_device *drm = &adev->drm;
> 	struct device *dev = adev->dev;
> 	int ret;
>
> +	primary_plane = &adev->primary_plane;
> +	ret = drm_universal_plane_init(drm, primary_plane, 0,
> +				       &appletbdrm_primary_plane_funcs,
> +				       appletbdrm_primary_plane_formats,
> +				       ARRAY_SIZE(appletbdrm_primary_plane_formats),
> +				       NULL,
> +				       DRM_PLANE_TYPE_PRIMARY, NULL);
> +	if (ret)
> +		return ret;
> +	drm_plane_helper_add(primary_plane, &appletbdrm_primary_plane_helper_funcs);
> +
> +	crtc = &adev->crtc;
> +	ret = drm_crtc_init_with_planes(drm, crtc, primary_plane, NULL,
> +					&appletbdrm_crtc_funcs, NULL);
> +	if (ret)
> +		return ret;
> +	drm_crtc_helper_add(crtc, &appletbdrm_crtc_helper_funcs);
> +
> +	encoder = &adev->encoder;
> +	ret = drm_encoder_init(drm, encoder, &appletbdrm_encoder_funcs,
> +			       DRM_MODE_ENCODER_DAC, NULL);
> +	if (ret)
> +		return ret;
> +	encoder->possible_crtcs = drm_crtc_mask(crtc);
> +
> 	ret = drmm_mode_config_init(drm);

Try to do drmm_mode_config_init() first. The initialization of planes, 
crtcs and encoders requires it. See [1] for how other drivers order 
these calls.

> 	if (ret)
> 		return dev_err_probe(dev, ret, "Failed to initialize mode configuration\n");
> @@ -530,13 +611,13 @@ static int appletbdrm_setup_mode_config(struct appletbdrm_device *adev)
> 	if (ret)
> 		return dev_err_probe(dev, ret, "Failed to set non-desktop property\n");
>
> -	ret = drm_simple_display_pipe_init(drm, &adev->pipe, &appletbdrm_pipe_funcs,
> -					   appletbdrm_formats, ARRAY_SIZE(appletbdrm_formats),
> -					   NULL, &adev->connector);
> +	ret = drm_connector_attach_encoder(connector, encoder);
> +
> 	if (ret)
> 		return dev_err_probe(dev, ret, "Failed to initialize simple display pipe\n");
>
> -	drm_plane_enable_fb_damage_clips(&adev->pipe.plane);

> +	drm_plane_helper_add(primary_plane, &appletbdrm_primary_plane_helper_funcs);

This line can be removed. You've already set the plane helpers a few 
lines above.

> +	drm_plane_enable_fb_damage_clips(&adev->primary_plane);

And this call should better be done next to the plane init. The code at 
[1] again gives you an example of the preferable order.

Best regards
Thomas

[1] 
https://elixir.bootlin.com/linux/v6.13.2/source/drivers/gpu/drm/tiny/bochs.c#L606

>
> 	drm_mode_config_reset(drm);
>
>
> The commit history having both old and new revisions of the driver is here:
>
> https://github.com/AdityaGarg8/apple-touchbar-drv/blob/atomic/usr/src/apple-touchbar-advanced-0.1/appletbdrm.c
>
> Thanks
> Aditya

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)


  reply	other threads:[~2025-02-17  8:04 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-17 11:44 [PATCH v5 0/10] Touch Bar support for T2 Macs Aditya Garg
2024-08-17 11:45 ` [PATCH v5 1/10] HID: hid-appletb-bl: add driver for the backlight of Apple Touch Bars Aditya Garg
2024-08-17 11:46 ` [PATCH v5 2/10] HID: hid-appletb-kbd: add driver for the keyboard mode Aditya Garg
2024-09-27 15:39   ` Benjamin Tissoires
2024-09-28  5:56     ` Aditya Garg
2024-08-17 11:47 ` [PATCH v5 3/10] HID: hid-appletb-kbd: add support for fn toggle between media and function mode Aditya Garg
2024-08-17 11:48 ` [PATCH v5 4/10] HID: multitouch: support getting the contact ID from HID_DG_TRANSDUCER_INDEX fields Aditya Garg
2024-09-27 15:56   ` Benjamin Tissoires
2024-08-17 11:48 ` [PATCH v5 5/10] HID: multitouch: support getting the tip state from HID_DG_TOUCH fields Aditya Garg
2024-08-17 11:49 ` [PATCH v5 6/10] HID: multitouch: take cls->maxcontacts into account for devices without a HID_DG_CONTACTMAX field too Aditya Garg
2024-08-17 11:50 ` [PATCH v5 7/10] HID: multitouch: allow specifying if a device is direct in a class Aditya Garg
2024-09-27 15:59   ` Benjamin Tissoires
2024-08-17 11:50 ` [PATCH v5 8/10] HID: multitouch: add device ID for Apple Touch Bars Aditya Garg
2024-08-17 11:51 ` [PATCH v5 9/10] drm/format-helper: Add conversion from XRGB8888 to BGR888 Aditya Garg
2024-09-27  7:52   ` Thomas Zimmermann
2024-08-17 11:52 ` [PATCH v5 10/10] drm/tiny: add driver for Apple Touch Bars in x86 Macs Aditya Garg
2024-09-27  7:42   ` mripard
2024-09-27 16:48     ` Aditya Garg
2024-09-27  7:48   ` Thomas Zimmermann
2024-09-27 16:49     ` Aditya Garg
2025-02-15 13:43     ` [RFC PATCH " Aditya Garg
2025-02-17  8:04       ` Thomas Zimmermann [this message]
2025-02-17 11:43         ` Aditya Garg
2024-08-31 12:37 ` [PATCH v5 0/10] Touch Bar support for T2 Macs Aditya Garg
2024-09-11 12:21   ` Jiri Kosina
2024-09-17 10:06     ` [PATCH v5 0/10] [DRM REVIEW NEEDED] " Aditya Garg
2024-09-26 17:50     ` [WHY SUCH DELAY!] " Aditya Garg
2024-09-26 18:03       ` Jiri Kosina
2024-09-26 18:05         ` Aditya Garg
2024-09-26 18:11           ` Jiri Kosina
2024-09-26 20:37         ` Dave Airlie
2024-09-26 20:39           ` Jiri Kosina
2024-09-27 15:22       ` Benjamin Tissoires
2024-09-27 16:42         ` Aditya Garg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3df4e526-66a4-4dcd-8c6e-adacd9a2a5aa@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gargaditya08@live.com \
    --cc=jikos@kernel.org \
    --cc=kekrby@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=orlandoch.dev@gmail.com \
    --cc=thomas@t-8ch.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®