mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Rayyan Ansari <rayyan@ansari.sh>, dri-devel@lists.freedesktop.org
Cc: devicetree@vger.kernel.org, linux-fbdev@vger.kernel.org,
	janne@jannau.net,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Javier Martinez Canillas <javierm@redhat.com>,
	linux-kernel@vger.kernel.org, Hans de Goede <hdegoede@redhat.com>,
	Rob Herring <robh+dt@kernel.org>,
	~postmarketos/upstreaming@lists.sr.ht, asahi@lists.linux.dev
Subject: Re: [PATCH v4 1/2] drm/simpledrm: Allow physical width and height configuration via panel node
Date: Tue, 31 Jan 2023 09:57:19 +0100	[thread overview]
Message-ID: <ee4af5cb-6f2b-fde4-b81c-ef088d3272a8@suse.de> (raw)
In-Reply-To: <20230126182435.70544-2-rayyan@ansari.sh>


[-- Attachment #1.1: Type: text/plain, Size: 3206 bytes --]



Am 26.01.23 um 19:24 schrieb Rayyan Ansari:
> Parse the width-mm and height-mm devicetree properties of the panel node,
> and use this to set the DRM Display Mode instead of calculating it
> based on a hardcoded DPI.
> 
> Signed-off-by: Rayyan Ansari <rayyan@ansari.sh>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>   drivers/gpu/drm/tiny/simpledrm.c | 32 +++++++++++++++++++++++---------
>   1 file changed, 23 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c
> index 162eb44dcba8..f8b18441cfcb 100644
> --- a/drivers/gpu/drm/tiny/simpledrm.c
> +++ b/drivers/gpu/drm/tiny/simpledrm.c
> @@ -599,16 +599,12 @@ static const struct drm_mode_config_funcs simpledrm_mode_config_funcs = {
>    */
>   
>   static struct drm_display_mode simpledrm_mode(unsigned int width,
> -					      unsigned int height)
> +					      unsigned int height,
> +					      unsigned int width_mm,
> +					      unsigned int height_mm)
>   {
> -	/*
> -	 * Assume a monitor resolution of 96 dpi to
> -	 * get a somewhat reasonable screen size.
> -	 */
>   	const struct drm_display_mode mode = {
> -		DRM_MODE_INIT(60, width, height,
> -			      DRM_MODE_RES_MM(width, 96ul),
> -			      DRM_MODE_RES_MM(height, 96ul))
> +		DRM_MODE_INIT(60, width, height, width_mm, height_mm)
>   	};
>   
>   	return mode;
> @@ -622,6 +618,8 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
>   	struct simpledrm_device *sdev;
>   	struct drm_device *dev;
>   	int width, height, stride;
> +	int width_mm = 0, height_mm = 0;
> +	struct device_node *panel_node;
>   	const struct drm_format_info *format;
>   	struct resource *res, *mem;
>   	void __iomem *screen_base;
> @@ -676,6 +674,13 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
>   		format = simplefb_get_format_of(dev, of_node);
>   		if (IS_ERR(format))
>   			return ERR_CAST(format);
> +
> +		panel_node = of_parse_phandle(of_node, "panel", 0);
> +		if (panel_node) {
> +			simplefb_read_u32_of(dev, panel_node, "width-mm", &width_mm);
> +			simplefb_read_u32_of(dev, panel_node, "height-mm", &height_mm);
> +			of_node_put(panel_node);
> +		}
>   	} else {
>   		drm_err(dev, "no simplefb configuration found\n");
>   		return ERR_PTR(-ENODEV);
> @@ -686,7 +691,16 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
>   			return ERR_PTR(-EINVAL);
>   	}
>   
> -	sdev->mode = simpledrm_mode(width, height);
> +	/*
> +	 * Assume a monitor resolution of 96 dpi if physical dimensions
> +	 * are not specified to get a somewhat reasonable screen size.
> +	 */
> +	if (!width_mm)
> +		width_mm = DRM_MODE_RES_MM(width, 96ul);
> +	if (!height_mm)
> +		height_mm = DRM_MODE_RES_MM(height, 96ul);
> +
> +	sdev->mode = simpledrm_mode(width, height, width_mm, height_mm);
>   	sdev->format = format;
>   	sdev->pitch = stride;
>   

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

  reply	other threads:[~2023-01-31  9:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26 18:24 [PATCH v4 0/2] SimpleDRM: allow configuring physical width and height Rayyan Ansari
2023-01-26 18:24 ` [PATCH v4 1/2] drm/simpledrm: Allow physical width and height configuration via panel node Rayyan Ansari
2023-01-31  8:57   ` Thomas Zimmermann [this message]
2023-01-26 18:24 ` [PATCH v4 2/2] dt-bindings: display: simple-framebuffer: Document the " Rayyan Ansari
2023-01-30 19:01   ` Rob Herring
2023-01-31  9:42 ` [PATCH v4 0/2] SimpleDRM: allow configuring physical width and height Thomas Zimmermann

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=ee4af5cb-6f2b-fde4-b81c-ef088d3272a8@suse.de \
    --to=tzimmermann@suse.de \
    --cc=asahi@lists.linux.dev \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hdegoede@redhat.com \
    --cc=janne@jannau.net \
    --cc=javierm@redhat.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rayyan@ansari.sh \
    --cc=robh+dt@kernel.org \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /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®