Skip to content

Commit 03e1b3d

Browse files
Thomas ZimmermannMaarten Lankhorst
authored andcommitted
drm/i915/display: Remove preferred_bpp from struct intel_fbdev
The value preferred_bpp in struct intel_fbdev duplicates preferred_bpp in struct drm_fb_helper. Remove the former. Instead let intel_fbdev_init_bios() read the framebuffer from the hardware. Then derive preferred_bpp from its format and initialize struct drm_fb_helper with the value. The default is 32 (i.e., XRGB8888). Also removes one of those deprecated references to the cpp field of struct drm_format_info. Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Maarten Lankhorst <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Maarten Lankhorst <[email protected]>
1 parent a1c008b commit 03e1b3d

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

drivers/gpu/drm/i915/display/intel_fbdev.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ struct intel_fbdev {
6060
struct intel_framebuffer *fb;
6161
struct i915_vma *vma;
6262
unsigned long vma_flags;
63-
int preferred_bpp;
6463
};
6564

6665
static struct intel_fbdev *to_intel_fbdev(struct drm_fb_helper *fb_helper)
@@ -430,7 +429,6 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
430429
goto out;
431430
}
432431

433-
ifbdev->preferred_bpp = fb->base.format->cpp[0] * 8;
434432
ifbdev->fb = fb;
435433

436434
drm_framebuffer_get(&ifbdev->fb->base);
@@ -461,6 +459,23 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
461459
return false;
462460
}
463461

462+
static unsigned int intel_fbdev_color_mode(const struct drm_format_info *info)
463+
{
464+
unsigned int bpp;
465+
466+
if (!info->depth || info->num_planes != 1 || info->has_alpha || info->is_yuv)
467+
return 0;
468+
469+
bpp = drm_format_info_bpp(info, 0);
470+
471+
switch (bpp) {
472+
case 16:
473+
return info->depth; // 15 or 16
474+
default:
475+
return bpp;
476+
}
477+
}
478+
464479
static void intel_fbdev_suspend_worker(struct work_struct *work)
465480
{
466481
intel_fbdev_set_suspend(&container_of(work,
@@ -625,6 +640,7 @@ void intel_fbdev_setup(struct drm_i915_private *i915)
625640
{
626641
struct drm_device *dev = &i915->drm;
627642
struct intel_fbdev *ifbdev;
643+
unsigned int preferred_bpp = 0;
628644
int ret;
629645

630646
if (!HAS_DISPLAY(i915))
@@ -633,14 +649,15 @@ void intel_fbdev_setup(struct drm_i915_private *i915)
633649
ifbdev = kzalloc(sizeof(*ifbdev), GFP_KERNEL);
634650
if (!ifbdev)
635651
return;
636-
drm_fb_helper_prepare(dev, &ifbdev->helper, 32, &intel_fb_helper_funcs);
637652

638653
i915->display.fbdev.fbdev = ifbdev;
639654
INIT_WORK(&i915->display.fbdev.suspend_work, intel_fbdev_suspend_worker);
640655
if (intel_fbdev_init_bios(dev, ifbdev))
641-
ifbdev->helper.preferred_bpp = ifbdev->preferred_bpp;
642-
else
643-
ifbdev->preferred_bpp = ifbdev->helper.preferred_bpp;
656+
preferred_bpp = intel_fbdev_color_mode(ifbdev->fb->base.format);
657+
if (!preferred_bpp)
658+
preferred_bpp = 32;
659+
660+
drm_fb_helper_prepare(dev, &ifbdev->helper, preferred_bpp, &intel_fb_helper_funcs);
644661

645662
ret = drm_client_init(dev, &ifbdev->helper.client, "intel-fbdev",
646663
&intel_fbdev_client_funcs);

0 commit comments

Comments
 (0)