From: Thomas Zimmermann <tzimmermann@suse.de>
To: patrik.r.jakobsson@gmail.com, airlied@gmail.com, daniel@ffwll.ch
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 5/7] drm/gma500: Inline psbfb_create() into psbfb_probe()
Date: Thu, 23 Feb 2023 13:17:31 +0100 [thread overview]
Message-ID: <20230223121733.12549-6-tzimmermann@suse.de> (raw)
In-Reply-To: <20230223121733.12549-1-tzimmermann@suse.de>
Inline psbfb_create() into its only caller psbfb_probe(). Streamline
the color-depth selection.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/gma500/fbdev.c | 65 ++++++++++++++--------------------
1 file changed, 26 insertions(+), 39 deletions(-)
diff --git a/drivers/gpu/drm/gma500/fbdev.c b/drivers/gpu/drm/gma500/fbdev.c
index 2c511359a7c6..083233692c55 100644
--- a/drivers/gpu/drm/gma500/fbdev.c
+++ b/drivers/gpu/drm/gma500/fbdev.c
@@ -137,31 +137,49 @@ static const struct fb_ops psb_fbdev_ops = {
* struct drm_fb_helper_funcs
*/
-static int psbfb_create(struct drm_fb_helper *fb_helper,
- struct drm_fb_helper_surface_size *sizes)
+static int psbfb_probe(struct drm_fb_helper *fb_helper,
+ struct drm_fb_helper_surface_size *sizes)
{
struct drm_device *dev = fb_helper->dev;
struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
struct pci_dev *pdev = to_pci_dev(dev->dev);
struct fb_info *info;
struct drm_framebuffer *fb;
- struct drm_mode_fb_cmd2 mode_cmd;
+ struct drm_mode_fb_cmd2 mode_cmd = { };
int size;
int ret;
struct psb_gem_object *backing;
struct drm_gem_object *obj;
u32 bpp, depth;
- mode_cmd.width = sizes->surface_width;
- mode_cmd.height = sizes->surface_height;
+ /* No 24-bit packed mode */
+ if (sizes->surface_bpp == 24) {
+ sizes->surface_bpp = 32;
+ sizes->surface_depth = 24;
+ }
bpp = sizes->surface_bpp;
depth = sizes->surface_depth;
- /* No 24bit packed */
- if (bpp == 24)
- bpp = 32;
+ /*
+ * If the mode does not fit in 32 bit then switch to 16 bit to get
+ * a console on full resolution. The X mode setting server will
+ * allocate its own 32-bit GEM framebuffer.
+ */
+ size = ALIGN(sizes->surface_width * DIV_ROUND_UP(bpp, 8), 64) *
+ sizes->surface_height;
+ size = ALIGN(size, PAGE_SIZE);
+
+ if (size > dev_priv->vram_stolen_size) {
+ sizes->surface_bpp = 16;
+ sizes->surface_depth = 16;
+ }
+ bpp = sizes->surface_bpp;
+ depth = sizes->surface_depth;
+ mode_cmd.width = sizes->surface_width;
+ mode_cmd.height = sizes->surface_height;
mode_cmd.pitches[0] = ALIGN(mode_cmd.width * DIV_ROUND_UP(bpp, 8), 64);
+ mode_cmd.pixel_format = drm_mode_legacy_fb_format(bpp, depth);
size = mode_cmd.pitches[0] * mode_cmd.height;
size = ALIGN(size, PAGE_SIZE);
@@ -180,8 +198,6 @@ static int psbfb_create(struct drm_fb_helper *fb_helper,
goto err_drm_gem_object_put;
}
- mode_cmd.pixel_format = drm_mode_legacy_fb_format(bpp, depth);
-
fb = psb_framebuffer_create(dev, &mode_cmd, obj);
if (IS_ERR(fb)) {
ret = PTR_ERR(fb);
@@ -217,35 +233,6 @@ static int psbfb_create(struct drm_fb_helper *fb_helper,
return ret;
}
-static int psbfb_probe(struct drm_fb_helper *fb_helper,
- struct drm_fb_helper_surface_size *sizes)
-{
- struct drm_device *dev = fb_helper->dev;
- struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
- unsigned int fb_size;
- int bytespp;
-
- bytespp = sizes->surface_bpp / 8;
- if (bytespp == 3) /* no 24bit packed */
- bytespp = 4;
-
- /*
- * If the mode will not fit in 32bit then switch to 16bit to get
- * a console on full resolution. The X mode setting server will
- * allocate its own 32bit GEM framebuffer
- */
- fb_size = ALIGN(sizes->surface_width * bytespp, 64) *
- sizes->surface_height;
- fb_size = ALIGN(fb_size, PAGE_SIZE);
-
- if (fb_size > dev_priv->vram_stolen_size) {
- sizes->surface_bpp = 16;
- sizes->surface_depth = 16;
- }
-
- return psbfb_create(fb_helper, sizes);
-}
-
static const struct drm_fb_helper_funcs psb_fb_helper_funcs = {
.fb_probe = psbfb_probe,
};
--
2.39.2
next prev parent reply other threads:[~2023-02-23 12:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-23 12:17 [PATCH 0/7] drm/gma500: Convert fbdev to DRM client Thomas Zimmermann
2023-02-23 12:17 ` [PATCH 1/7] drm/gma500: Remove unnecessary include statements Thomas Zimmermann
2023-02-23 12:17 ` [PATCH 2/7] drm/gma500: Move fbdev code into separate source file Thomas Zimmermann
2023-02-27 7:10 ` Patrik Jakobsson
2023-02-27 7:40 ` Thomas Zimmermann
2023-02-27 7:48 ` Patrik Jakobsson
2023-03-06 14:51 ` Patrik Jakobsson
2023-02-23 12:17 ` [PATCH 3/7] drm/gma500: Remove fbdev vma open and close callbacks Thomas Zimmermann
2023-02-23 12:17 ` [PATCH 4/7] drm/gma500: Fix naming in fb_ops Thomas Zimmermann
2023-02-23 12:17 ` Thomas Zimmermann [this message]
2023-03-06 14:51 ` [PATCH 5/7] drm/gma500: Inline psbfb_create() into psbfb_probe() Patrik Jakobsson
2023-02-23 12:17 ` [PATCH 6/7] drm/gma500: Implement client-based fbdev emulation Thomas Zimmermann
2023-02-23 19:01 ` kernel test robot
2023-02-24 7:58 ` Thomas Zimmermann
2023-02-23 19:22 ` kernel test robot
2023-02-23 21:04 ` kernel test robot
2023-02-23 12:17 ` [PATCH 7/7] drm/gma500: Pass fb_info to psb_fbdev_vm_fault() Thomas Zimmermann
2023-03-06 14:52 ` Patrik Jakobsson
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=20230223121733.12549-6-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=patrik.r.jakobsson@gmail.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