dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Jonathan Cavitt <jonathan.cavitt@intel.com>,
	dri-devel@lists.freedesktop.org
Cc: jonathan.cavitt@intel.com, saurabhg.gupta@intel.com,
	alex.zuo@intel.com, matthew.auld@intel.com,
	himal.prasad.ghimiray@intel.com, matthew.brost@intel.com
Subject: Re: [PATCH] drm: Add drm_mode_display_size helper function
Date: Wed, 01 Oct 2025 10:53:56 +0300	[thread overview]
Message-ID: <f21e9a9eeec721cd52ee403a10690912c9efdff2@intel.com> (raw)
In-Reply-To: <20250930212654.146694-2-jonathan.cavitt@intel.com>

On Tue, 30 Sep 2025, Jonathan Cavitt <jonathan.cavitt@intel.com> wrote:
> Add a helper function that computes the product of hdisplay and
> vdisplay.
>
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> ---
>  drivers/gpu/drm/drm_gem_vram_helper.c | 2 +-
>  drivers/gpu/drm/drm_mipi_dbi.c        | 2 +-
>  include/drm/drm_modes.h               | 5 +++++
>  3 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index 90760d0ca071..4ac71c34f4c6 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -967,7 +967,7 @@ drm_vram_helper_mode_valid_internal(struct drm_device *dev,
>  
>  	max_fbpages = (vmm->vram_size / 2) >> PAGE_SHIFT;
>  
> -	fbsize = mode->hdisplay * mode->vdisplay * max_bpp;
> +	fbsize = drm_mode_display_size(mode) * max_bpp;
>  	fbpages = DIV_ROUND_UP(fbsize, PAGE_SIZE);
>  
>  	if (fbpages > max_fbpages)
> diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
> index e33c78fc8fbd..54212bf85160 100644
> --- a/drivers/gpu/drm/drm_mipi_dbi.c
> +++ b/drivers/gpu/drm/drm_mipi_dbi.c
> @@ -691,7 +691,7 @@ int mipi_dbi_dev_init(struct mipi_dbi_dev *dbidev,
>  		      const struct drm_simple_display_pipe_funcs *funcs,
>  		      const struct drm_display_mode *mode, unsigned int rotation)
>  {
> -	size_t bufsize = mode->vdisplay * mode->hdisplay * sizeof(u16);
> +	size_t bufsize = drm_mode_display_size(mode) * sizeof(u16);
>  
>  	dbidev->drm.mode_config.preferred_depth = 16;
>  
> diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
> index b9bb92e4b029..775c94c55cda 100644
> --- a/include/drm/drm_modes.h
> +++ b/include/drm/drm_modes.h
> @@ -572,4 +572,9 @@ struct drm_display_mode *
>  drm_mode_create_from_cmdline_mode(struct drm_device *dev,
>  				  struct drm_cmdline_mode *cmd);
>  
> +static inline u32 drm_mode_display_size(const struct drm_display_mode *mode)
> +{
> +	return mode->hdisplay * mode->vdisplay;
> +}

All functions here need kernel-doc.

I wonder if "size" is specific enough.


BR,
Jani.



> +
>  #endif /* __DRM_MODES_H__ */

-- 
Jani Nikula, Intel

  reply	other threads:[~2025-10-01  7:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-30 21:26 [PATCH] drm: Add drm_mode_display_size helper function Jonathan Cavitt
2025-10-01  7:53 ` Jani Nikula [this message]
2025-10-01 11:32 ` Ville Syrjälä

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=f21e9a9eeec721cd52ee403a10690912c9efdff2@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=alex.zuo@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=jonathan.cavitt@intel.com \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=saurabhg.gupta@intel.com \
    /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