Skip to contentSkip to conversation

drm: Deduplicate fb format information

PATCH Superseded [email protected] 3 participants 52 messages Nov 17, 2016

Subsystems (36)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover drm: Deduplicate fb format information

From: Ville Syrjälä <[email protected]>

This series aims to remove the duplicated format information stored under drm_framebuffer (depth,bits_per_pixel,pixel_format), and instead we just use the drm_format_info structure. And we store a pointer to the approriate drm_format_info under drm_framebuffer so that we don't have to do expensive linear searches through the big array.

Quite of bit of this was cocci magic, and I've tried to keep the cocci patches pure of manual tinkering in case someone needs to rerun them. I had some issues with cocci behaving like an idiot, so I've included a bunch of hand rolled patches up front to make life easier for it.

I've smoke tested this on i915, and compile tested on everything else (I hope).

Entire series available here:
git://github.com/vsyrjala/linux.git fb_format_dedup

Cc Alex Deucher <[email protected]>
Cc Alexey Brodkin <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Brian Starkey <[email protected]>
Cc "Christian König" <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Gerd Hoffmann <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc Mali DP Maintainers <[email protected]>
Cc Patrik Jakobsson <[email protected]>
Cc Paulo Zanoni <[email protected]>
Cc Sinclair Yeh <[email protected]>
Cc Thomas Hellstrom <[email protected]>

Ville Syrjälä (32):
drm/i915: Add local 'fb' variables
drm/radeon: Add local 'fb' variables
drm/radeon: Use DIV_ROUND_UP()
drm/mgag200: Add local 'fb' variable
drm/ast: Add local 'fb' variables
drm/gma500: Add some local 'fb' variables drm/cirrus: Add some local 'fb' variables drm/arcpgu: Add local 'fb' variables
drm/arm: Add local 'fb' variables
drm/nouveau: Fix crtc->primary->fb vs. drm_fb fail drm/nouveau: Add local 'fb' variables
drm/vmwgfx: Populate fb->dev before drm_framebuffer_init()
drm: Pass 'dev' to drm_helper_mode_fill_fb_struct() drm/vmwgfx: Populate fb->pixel_format
drm/qxl: Call drm_helper_mode_fill_fb_struct() before
drm_framebuffer_init()
drm/virtio: Call drm_helper_mode_fill_fb_struct() before
drm_framebuffer_init()
drm/i915: Set fb->dev early on for inherited fbs
drm: Populate fb->dev from drm_helper_mode_fill_fb_struct()
drm: Store a pointer to drm_format_info under drm_framebuffer drm/vmwgfx: Populate fb->format correctly
drm/i915: Populate fb->format early for inherited fbs drm/atomic: Replace drm_format_num_planes() with

    fb->format->num_planes

drm/fb_cma_helper: Replace drm_format_info() with fb->format drm/nouveau: Use fb->format rather than drm_format_info() drm/i915: Store a pointer to the pixel format info for fbc drm/i915: Replace drm_format_plane_cpp() with fb->format->cpp[] drm/i915: Replace drm_format_num_planes() with fb->format->num_planes
drm: Add drm_framebuffer_plane_{width,height}()
drm/i915: Use drm_framebuffer_plane_{width,height}() where possible
drm: Nuke fb->depth
drm: Nuke fb->bits_per_pixel
drm: Nuke fb->pixel_format

 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c     |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c          |  4 +-
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c          |  6 +-
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c          |  6 +-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c           |  6 +-
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c           |  6 +-
 drivers/gpu/drm/arc/arcpgu_crtc.c               |  3 +-
 drivers/gpu/drm/arm/hdlcd_crtc.c                | 18 +++---
 drivers/gpu/drm/arm/malidp_planes.c             | 10 ++--
 drivers/gpu/drm/armada/armada_crtc.c            |  6 +-
 drivers/gpu/drm/armada/armada_fb.c              |  2 +-
 drivers/gpu/drm/armada/armada_fbdev.c           |  5 +-
 drivers/gpu/drm/armada/armada_overlay.c         |  2 +-
 drivers/gpu/drm/ast/ast_fb.c                    |  4 +-
 drivers/gpu/drm/ast/ast_main.c                  |  2 +-
 drivers/gpu/drm/ast/ast_mode.c                  | 16 +++--
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 22 +++----
 drivers/gpu/drm/bochs/bochs_fbdev.c             |  2 +-
 drivers/gpu/drm/bochs/bochs_mm.c                |  2 +-
 drivers/gpu/drm/cirrus/cirrus_fbdev.c           |  6 +-
 drivers/gpu/drm/cirrus/cirrus_main.c            |  2 +-
 drivers/gpu/drm/cirrus/cirrus_mode.c            |  9 +--
 drivers/gpu/drm/drm_atomic.c                    |  8 +--
 drivers/gpu/drm/drm_crtc.c                      |  4 +-
 drivers/gpu/drm/drm_crtc_helper.c               |  4 +-
 drivers/gpu/drm/drm_fb_cma_helper.c             | 11 ++--
 drivers/gpu/drm/drm_fb_helper.c                 | 10 ++--
 drivers/gpu/drm/drm_framebuffer.c               | 53 ++++++++++++++++-
 drivers/gpu/drm/drm_modeset_helper.c            | 11 ++--
 drivers/gpu/drm/drm_plane.c                     |  6 +-
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c   |  6 +-
 drivers/gpu/drm/exynos/exynos7_drm_decon.c      |  8 +--
 drivers/gpu/drm/exynos/exynos_drm_fb.c          |  2 +-
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c       |  6 +-
 drivers/gpu/drm/exynos/exynos_drm_fimd.c        |  4 +-
 drivers/gpu/drm/exynos/exynos_mixer.c           | 12 ++--
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c     |  4 +-
 drivers/gpu/drm/gma500/accel_2d.c               |  2 +-
 drivers/gpu/drm/gma500/framebuffer.c            |  6 +-
 drivers/gpu/drm/gma500/gma_display.c            | 13 +++--
 drivers/gpu/drm/gma500/mdfld_intel_display.c    | 17 +++---
 drivers/gpu/drm/gma500/oaktrail_crtc.c          | 13 +++--
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c |  6 +-
 drivers/gpu/drm/i915/i915_debugfs.c             | 11 ++--
 drivers/gpu/drm/i915/i915_drv.h                 |  4 +-
 drivers/gpu/drm/i915/intel_atomic_plane.c       |  4 +-
 drivers/gpu/drm/i915/intel_display.c            | 78 +++++++++++++------------
 drivers/gpu/drm/i915/intel_fbc.c                | 14 ++---
 drivers/gpu/drm/i915/intel_fbdev.c              | 10 ++--
 drivers/gpu/drm/i915/intel_overlay.c            | 26 ++++-----
 drivers/gpu/drm/i915/intel_pm.c                 | 52 ++++++++---------
 drivers/gpu/drm/i915/intel_sprite.c             | 14 ++---
 drivers/gpu/drm/imx/ipuv3-plane.c               | 40 ++++++-------
 drivers/gpu/drm/mediatek/mtk_drm_fb.c           |  2 +-
 drivers/gpu/drm/mediatek/mtk_drm_plane.c        |  2 +-
 drivers/gpu/drm/mgag200/mgag200_fb.c            |  4 +-
 drivers/gpu/drm/mgag200/mgag200_main.c          |  2 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c          | 23 ++++----
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c       |  2 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c       |  4 +-
 drivers/gpu/drm/msm/msm_fb.c                    | 12 ++--
 drivers/gpu/drm/msm/msm_fbdev.c                 |  2 +-
 drivers/gpu/drm/nouveau/dispnv04/crtc.c         | 17 +++---
 drivers/gpu/drm/nouveau/dispnv04/dfp.c          |  3 +-
 drivers/gpu/drm/nouveau/dispnv04/overlay.c      |  8 +--
 drivers/gpu/drm/nouveau/nouveau_display.c       |  4 +-
 drivers/gpu/drm/nouveau/nouveau_fbcon.c         |  3 +-
 drivers/gpu/drm/nouveau/nv50_display.c          | 14 ++---
 drivers/gpu/drm/omapdrm/omap_fb.c               | 12 ++--
 drivers/gpu/drm/omapdrm/omap_fbdev.c            |  2 +-
 drivers/gpu/drm/qxl/qxl_display.c               |  2 +-
 drivers/gpu/drm/qxl/qxl_draw.c                  |  2 +-
 drivers/gpu/drm/qxl/qxl_fb.c                    |  5 +-
 drivers/gpu/drm/radeon/atombios_crtc.c          | 19 +++---
 drivers/gpu/drm/radeon/r100.c                   | 10 +++-
 drivers/gpu/drm/radeon/radeon_display.c         |  8 +--
 drivers/gpu/drm/radeon/radeon_fb.c              |  4 +-
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c     | 16 ++---
 drivers/gpu/drm/rcar-du/rcar_du_plane.c         |  4 +-
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c           |  4 +-
 drivers/gpu/drm/rockchip/rockchip_drm_fb.c      |  2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c   |  5 +-
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c     | 22 +++----
 drivers/gpu/drm/shmobile/shmob_drm_crtc.c       |  6 +-
 drivers/gpu/drm/shmobile/shmob_drm_plane.c      |  4 +-
 drivers/gpu/drm/sti/sti_gdp.c                   | 10 ++--
 drivers/gpu/drm/sti/sti_hqvdp.c                 |  2 +-
 drivers/gpu/drm/sun4i/sun4i_backend.c           |  5 +-
 drivers/gpu/drm/tegra/dc.c                      |  8 +--
 drivers/gpu/drm/tegra/drm.c                     |  5 +-
 drivers/gpu/drm/tegra/fb.c                      |  6 +-
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c            |  4 +-
 drivers/gpu/drm/tilcdc/tilcdc_plane.c           |  4 +-
 drivers/gpu/drm/udl/udl_fb.c                    |  6 +-
 drivers/gpu/drm/vc4/vc4_plane.c                 |  6 +-
 drivers/gpu/drm/virtio/virtgpu_display.c        |  3 +-
 drivers/gpu/drm/virtio/virtgpu_fb.c             |  4 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c              | 13 +++--
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c             | 29 +++++++--
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c             |  5 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c            |  4 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c            |  2 +-
 drivers/gpu/drm/zte/zx_plane.c                  |  2 +-
 include/drm/drm_framebuffer.h                   | 27 ++++-----
 include/drm/drm_modeset_helper.h                |  3 +-
 106 files changed, 532 insertions(+), 447 deletions(-)
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 1/32 drm/i915: Add local 'fb' variables

From: Ville Syrjälä <[email protected]>

Add a local 'fb' variable to a few places to get rid of the 'crtc->primary->fb' stuff. Looks neater and helps me with my poor coccinelle skills later.

While at it switch over to using the pixel format rather than depth+bpp.

---
 drivers/gpu/drm/i915/intel_overlay.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_overlay.c +12 -14
index fd0e4dac7cc1..ce3667c18e18 100644
@@ -658,6 +658,8 @@ static bool update_scaling_factors(struct intel_overlay *overlay,
 static void update_colorkey(struct intel_overlay *overlay,
 			    struct overlay_registers __iomem *regs)
 {
+	const struct drm_framebuffer *fb =
+		overlay->crtc->base.primary->fb;
 	u32 key = overlay->color_key;
 	u32 flags;
 
@@ -665,24 +667,20 @@ static void update_colorkey(struct intel_overlay *overlay,
 	if (overlay->color_key_enabled)
 		flags |= DST_KEY_ENABLE;
 
-	switch (overlay->crtc->base.primary->fb->bits_per_pixel) {
-	case 8:
+	switch (fb->pixel_format) {
+	case DRM_FORMAT_C8:
 		key = 0;
 		flags |= CLK_RGB8I_MASK;
 		break;
-
-	case 16:
-		if (overlay->crtc->base.primary->fb->depth == 15) {
-			key = RGB15_TO_COLORKEY(key);
-			flags |= CLK_RGB15_MASK;
-		} else {
-			key = RGB16_TO_COLORKEY(key);
-			flags |= CLK_RGB16_MASK;
-		}
+	case DRM_FORMAT_XRGB1555:
+		key = RGB15_TO_COLORKEY(key);
+		flags |= CLK_RGB15_MASK;
 		break;
-
-	case 24:
-	case 32:
+	case DRM_FORMAT_RGB565:
+		key = RGB16_TO_COLORKEY(key);
+		flags |= CLK_RGB16_MASK;
+		break;
+	default:
 		flags |= CLK_RGB24_MASK;
 		break;
 	}
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 2/32 drm/radeon: Add local 'fb' variables

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Add a local 'fb' variable to a few places to get rid of the 'crtc->primary->fb' stuff. Looks neater and helps me with my poor coccinelle skills later.

Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>
---
 drivers/gpu/drm/radeon/r100.c               | 10 ++++++++--
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c |  3 ++-
 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/r100.c +8 -2
index f5e84f4b58e6..984b35f43554 100644
@@ -3225,13 +3225,19 @@ void r100_bandwidth_update(struct radeon_device *rdev)
 	radeon_update_display_priority(rdev);
 
 	if (rdev->mode_info.crtcs[0]->base.enabled) {
+		const struct drm_framebuffer *fb =
+			rdev->mode_info.crtcs[0]->base.primary->fb;
+
 		mode1 = &rdev->mode_info.crtcs[0]->base.mode;
-		pixel_bytes1 = rdev->mode_info.crtcs[0]->base.primary->fb->bits_per_pixel / 8;
+		pixel_bytes1 = fb->bits_per_pixel / 8;
 	}
 	if (!(rdev->flags & RADEON_SINGLE_CRTC)) {
 		if (rdev->mode_info.crtcs[1]->base.enabled) {
+			const struct drm_framebuffer *fb =
+				rdev->mode_info.crtcs[1]->base.primary->fb;
+
 			mode2 = &rdev->mode_info.crtcs[1]->base.mode;
-			pixel_bytes2 = rdev->mode_info.crtcs[1]->base.primary->fb->bits_per_pixel / 8;
+			pixel_bytes2 = fb->bits_per_pixel / 8;
 		}
 	}
 
drivers/gpu/drm/radeon/radeon_legacy_crtc.c +2 -1
index d0de4022fff9..bb5346812de4 100644
@@ -579,6 +579,7 @@ static bool radeon_set_crtc_timing(struct drm_crtc *crtc, struct drm_display_mod
 	struct drm_device *dev = crtc->dev;
 	struct radeon_device *rdev = dev->dev_private;
 	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
+	const struct drm_framebuffer *fb = crtc->primary->fb;
 	struct drm_encoder *encoder;
 	int format;
 	int hsync_start;
@@ -602,7 +603,7 @@ static bool radeon_set_crtc_timing(struct drm_crtc *crtc, struct drm_display_mod
 		}
 	}
 
-	switch (crtc->primary->fb->bits_per_pixel) {
+	switch (fb->bits_per_pixel) {
 	case 8:
 		format = 2;
 		break;
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 2/32
#3 lore raw

Re: [PATCH 02/32] drm/radeon: Add local 'fb' variables

Quoted 9 lines · On Thu, Nov 17, 2016 at 11:14 AM, <[email protected]> wrote:

From: Ville Syrjälä <[email protected]>

Add a local 'fb' variable to a few places to get rid of the 'crtc->primary->fb' stuff. Looks neater and helps me with my poor coccinelle skills later.

Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>
Quoted 55 lines
---
 drivers/gpu/drm/radeon/r100.c               | 10 ++++++++--
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c |  3 ++-
 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/r100.c +8 -2
index f5e84f4b58e6..984b35f43554 100644
@@ -3225,13 +3225,19 @@ void r100_bandwidth_update(struct radeon_device *rdev)
        radeon_update_display_priority(rdev);
 
        if (rdev->mode_info.crtcs[0]->base.enabled) {
+               const struct drm_framebuffer *fb =
+                       rdev->mode_info.crtcs[0]->base.primary->fb;
+
                mode1 = &rdev->mode_info.crtcs[0]->base.mode;
-               pixel_bytes1 = rdev->mode_info.crtcs[0]->base.primary->fb->bits_per_pixel / 8;
+               pixel_bytes1 = fb->bits_per_pixel / 8;
        }
        if (!(rdev->flags & RADEON_SINGLE_CRTC)) {
                if (rdev->mode_info.crtcs[1]->base.enabled) {
+                       const struct drm_framebuffer *fb =
+                               rdev->mode_info.crtcs[1]->base.primary->fb;
+
                        mode2 = &rdev->mode_info.crtcs[1]->base.mode;
-                       pixel_bytes2 = rdev->mode_info.crtcs[1]->base.primary->fb->bits_per_pixel / 8;
+                       pixel_bytes2 = fb->bits_per_pixel / 8;
                }
        }
 
drivers/gpu/drm/radeon/radeon_legacy_crtc.c +2 -2
index d0de4022fff9..bb5346812de4 100644
@@ -579,6 +579,7 @@ static bool radeon_set_crtc_timing(struct drm_crtc *crtc, struct drm_display_mod
        struct drm_device *dev = crtc->dev;
        struct radeon_device *rdev = dev->dev_private;
        struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
+       const struct drm_framebuffer *fb = crtc->primary->fb;
        struct drm_encoder *encoder;
        int format;
        int hsync_start;
@@ -602,7 +603,7 @@ static bool radeon_set_crtc_timing(struct drm_crtc *crtc, struct drm_display_mod
                }
        }
 
-       switch (crtc->primary->fb->bits_per_pixel) {
+       switch (fb->bits_per_pixel) {
        case 8:
                format = 2;
                break;
--

2.7.4

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

PATCH 3/32 drm/radeon: Use DIV_ROUND_UP()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Use DIV_ROUND_UP() instead of hand rolling it. Just a drive-by change.

Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>
---
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/radeon_legacy_crtc.c +2 -3
index bb5346812de4..31c03e32a6b5 100644
@@ -477,9 +477,8 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
 	crtc_offset_cntl = 0;
 
 	pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
-	crtc_pitch  = (((pitch_pixels * target_fb->bits_per_pixel) +
-			((target_fb->bits_per_pixel * 8) - 1)) /
-		       (target_fb->bits_per_pixel * 8));
+	crtc_pitch = DIV_ROUND_UP(pitch_pixels * target_fb->bits_per_pixel,
+				  target_fb->bits_per_pixel * 8);
 	crtc_pitch |= crtc_pitch << 16;
 
 	crtc_offset_cntl |= RADEON_CRTC_GUI_TRIG_OFFSET_LEFT_EN;
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 3/32
#5 lore raw

Re: [PATCH 03/32] drm/radeon: Use DIV_ROUND_UP()

Quoted 7 lines · On Thu, Nov 17, 2016 at 11:14 AM, <[email protected]> wrote:

From: Ville Syrjälä <[email protected]>

Use DIV_ROUND_UP() instead of hand rolling it. Just a drive-by change.

Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>
Quoted 23 lines
---
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/radeon_legacy_crtc.c +2 -4
index bb5346812de4..31c03e32a6b5 100644
@@ -477,9 +477,8 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
        crtc_offset_cntl = 0;
 
        pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
-       crtc_pitch  = (((pitch_pixels * target_fb->bits_per_pixel) +
-                       ((target_fb->bits_per_pixel * 8) - 1)) /
-                      (target_fb->bits_per_pixel * 8));
+       crtc_pitch = DIV_ROUND_UP(pitch_pixels * target_fb->bits_per_pixel,
+                                 target_fb->bits_per_pixel * 8);
        crtc_pitch |= crtc_pitch << 16;
 
        crtc_offset_cntl |= RADEON_CRTC_GUI_TRIG_OFFSET_LEFT_EN;
--

2.7.4

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

PATCH 4/32 drm/mgag200: Add local 'fb' variable

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Add a local 'fb' variable to a few places to get rid of the 'crtc->primary->fb' stuff. Looks neater and helps me with my poor coccinelle skills later.

---
 drivers/gpu/drm/mgag200/mgag200_mode.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/mgag200/mgag200_mode.c +9 -8
index 6b21cb27e1cc..bdac288ab16d 100644
@@ -880,6 +880,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 {
 	struct drm_device *dev = crtc->dev;
 	struct mga_device *mdev = dev->dev_private;
+	const struct drm_framebuffer *fb = crtc->primary->fb;
 	int hdisplay, hsyncstart, hsyncend, htotal;
 	int vdisplay, vsyncstart, vsyncend, vtotal;
 	int pitch;
@@ -902,7 +903,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 		/* 0x48: */        0,    0,    0,    0,    0,    0,    0,    0
 	};
 
-	bppshift = mdev->bpp_shifts[(crtc->primary->fb->bits_per_pixel >> 3) - 1];
+	bppshift = mdev->bpp_shifts[(fb->bits_per_pixel >> 3) - 1];
 
 	switch (mdev->type) {
 	case G200_SE_A:
@@ -941,12 +942,12 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 		break;
 	}
 
-	switch (crtc->primary->fb->bits_per_pixel) {
+	switch (fb->bits_per_pixel) {
 	case 8:
 		dacvalue[MGA1064_MUL_CTL] = MGA1064_MUL_CTL_8bits;
 		break;
 	case 16:
-		if (crtc->primary->fb->depth == 15)
+		if (fb->depth == 15)
 			dacvalue[MGA1064_MUL_CTL] = MGA1064_MUL_CTL_15bits;
 		else
 			dacvalue[MGA1064_MUL_CTL] = MGA1064_MUL_CTL_16bits;
@@ -997,8 +998,8 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 	WREG_SEQ(3, 0);
 	WREG_SEQ(4, 0xe);
 
-	pitch = crtc->primary->fb->pitches[0] / (crtc->primary->fb->bits_per_pixel / 8);
-	if (crtc->primary->fb->bits_per_pixel == 24)
+	pitch = fb->pitches[0] / (fb->bits_per_pixel / 8);
+	if (fb->bits_per_pixel == 24)
 		pitch = (pitch * 3) >> (4 - bppshift);
 	else
 		pitch = pitch >> (4 - bppshift);
@@ -1075,7 +1076,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 		((vdisplay & 0xc00) >> 7) |
 		((vsyncstart & 0xc00) >> 5) |
 		((vdisplay & 0x400) >> 3);
-	if (crtc->primary->fb->bits_per_pixel == 24)
+	if (fb->bits_per_pixel == 24)
 		ext_vga[3] = (((1 << bppshift) * 3) - 1) | 0x80;
 	else
 		ext_vga[3] = ((1 << bppshift) - 1) | 0x80;
@@ -1138,9 +1139,9 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 			u32 bpp;
 			u32 mb;
 
-			if (crtc->primary->fb->bits_per_pixel > 16)
+			if (fb->bits_per_pixel > 16)
 				bpp = 32;
-			else if (crtc->primary->fb->bits_per_pixel > 8)
+			else if (fb->bits_per_pixel > 8)
 				bpp = 16;
 			else
 				bpp = 8;
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

PATCH 5/32 drm/ast: Add local 'fb' variables

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Add a local 'fb' variable to a few places to get rid of the 'crtc->primary->fb' stuff. Looks neater and helps me with my poor coccinelle skills later.

---
 drivers/gpu/drm/ast/ast_mode.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +10 -5
index 5957c3e659fe..deb3684ccaf8 100644
@@ -79,12 +79,13 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo
 				    struct ast_vbios_mode_info *vbios_mode)
 {
 	struct ast_private *ast = crtc->dev->dev_private;
+	const struct drm_framebuffer *fb = crtc->primary->fb;
 	u32 refresh_rate_index = 0, mode_id, color_index, refresh_rate;
 	u32 hborder, vborder;
 	bool check_sync;
 	struct ast_vbios_enhtable *best = NULL;
 
-	switch (crtc->primary->fb->bits_per_pixel) {
+	switch (fb->bits_per_pixel) {
 	case 8:
 		vbios_mode->std_table = &vbios_stdtable[VGAModeIndex];
 		color_index = VGAModeIndex - 1;
@@ -207,7 +208,7 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo
 		ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x91, 0x00);
 		if (vbios_mode->enh_table->flags & NewModeInfo) {
 			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x91, 0xa8);
-			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x92, crtc->primary->fb->bits_per_pixel);
+			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x92, fb->bits_per_pixel);
 			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x93, adjusted_mode->clock / 1000);
 			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x94, adjusted_mode->crtc_hdisplay);
 			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x95, adjusted_mode->crtc_hdisplay >> 8);
@@ -369,10 +370,11 @@ static void ast_set_crtc_reg(struct drm_crtc *crtc, struct drm_display_mode *mod
 static void ast_set_offset_reg(struct drm_crtc *crtc)
 {
 	struct ast_private *ast = crtc->dev->dev_private;
+	const struct drm_framebuffer *fb = crtc->primary->fb;
 
 	u16 offset;
 
-	offset = crtc->primary->fb->pitches[0] >> 3;
+	offset = fb->pitches[0] >> 3;
 	ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x13, (offset & 0xff));
 	ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xb0, (offset >> 8) & 0x3f);
 }
@@ -395,9 +397,10 @@ static void ast_set_ext_reg(struct drm_crtc *crtc, struct drm_display_mode *mode
 			     struct ast_vbios_mode_info *vbios_mode)
 {
 	struct ast_private *ast = crtc->dev->dev_private;
+	const struct drm_framebuffer *fb = crtc->primary->fb;
 	u8 jregA0 = 0, jregA3 = 0, jregA8 = 0;
 
-	switch (crtc->primary->fb->bits_per_pixel) {
+	switch (fb->bits_per_pixel) {
 	case 8:
 		jregA0 = 0x70;
 		jregA3 = 0x01;
@@ -452,7 +455,9 @@ static void ast_set_sync_reg(struct drm_device *dev, struct drm_display_mode *mo
 static bool ast_set_dac_reg(struct drm_crtc *crtc, struct drm_display_mode *mode,
 		     struct ast_vbios_mode_info *vbios_mode)
 {
-	switch (crtc->primary->fb->bits_per_pixel) {
+	const struct drm_framebuffer *fb = crtc->primary->fb;
+
+	switch (fb->bits_per_pixel) {
 	case 8:
 		break;
 	default:
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#8 lore raw

PATCH 6/32 drm/gma500: Add some local 'fb' variables

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Add a local 'fb' variable to a few places to get rid of the 'crtc->primary->fb' stuff. Looks neater and helps me with my poor coccinelle skills later.

Cc Patrik Jakobsson <[email protected]>
---
 drivers/gpu/drm/gma500/gma_display.c         | 13 +++++++------
 drivers/gpu/drm/gma500/mdfld_intel_display.c | 15 ++++++++-------
 drivers/gpu/drm/gma500/oaktrail_crtc.c       | 13 +++++++------
 3 files changed, 22 insertions(+), 19 deletions(-)
drivers/gpu/drm/gma500/gma_display.c +7 -6
index 1a1cf7a3b5ef..05b9a4ceb58d 100644
@@ -59,7 +59,8 @@ int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 	struct drm_device *dev = crtc->dev;
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
-	struct psb_framebuffer *psbfb = to_psb_fb(crtc->primary->fb);
+	struct drm_framebuffer *fb = crtc->primary->fb;
+	struct psb_framebuffer *psbfb = to_psb_fb(fb);
 	int pipe = gma_crtc->pipe;
 	const struct psb_offset *map = &dev_priv->regmap[pipe];
 	unsigned long start, offset;
@@ -70,7 +71,7 @@ int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 		return 0;
 
 	/* no fb bound */
-	if (!crtc->primary->fb) {
+	if (!fb) {
 		dev_err(dev->dev, "No FB bound\n");
 		goto gma_pipe_cleaner;
 	}
@@ -81,19 +82,19 @@ int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 	if (ret < 0)
 		goto gma_pipe_set_base_exit;
 	start = psbfb->gtt->offset;
-	offset = y * crtc->primary->fb->pitches[0] + x * (crtc->primary->fb->bits_per_pixel / 8);
+	offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
 
-	REG_WRITE(map->stride, crtc->primary->fb->pitches[0]);
+	REG_WRITE(map->stride, fb->pitches[0]);
 
 	dspcntr = REG_READ(map->cntr);
 	dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
 
-	switch (crtc->primary->fb->bits_per_pixel) {
+	switch (fb->bits_per_pixel) {
 	case 8:
 		dspcntr |= DISPPLANE_8BPP;
 		break;
 	case 16:
-		if (crtc->primary->fb->depth == 15)
+		if (fb->depth == 15)
 			dspcntr |= DISPPLANE_15_16BPP;
 		else
 			dspcntr |= DISPPLANE_16BPP;
drivers/gpu/drm/gma500/mdfld_intel_display.c +8 -7
index 92e3f93ee682..e80895285e94 100644
@@ -165,8 +165,9 @@ static int mdfld__intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_psb_private *dev_priv = dev->dev_private;
+	struct drm_framebuffer *fb = crtc->primary->fb;
 	struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
-	struct psb_framebuffer *psbfb = to_psb_fb(crtc->primary->fb);
+	struct psb_framebuffer *psbfb = to_psb_fb(fb);
 	int pipe = gma_crtc->pipe;
 	const struct psb_offset *map = &dev_priv->regmap[pipe];
 	unsigned long start, offset;
@@ -178,12 +179,12 @@ static int mdfld__intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 	dev_dbg(dev->dev, "pipe = 0x%x.\n", pipe);
 
 	/* no fb bound */
-	if (!crtc->primary->fb) {
+	if (!fb) {
 		dev_dbg(dev->dev, "No FB bound\n");
 		return 0;
 	}
 
-	ret = check_fb(crtc->primary->fb);
+	ret = check_fb(fb);
 	if (ret)
 		return ret;
 
@@ -196,18 +197,18 @@ static int mdfld__intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 		return 0;
 
 	start = psbfb->gtt->offset;
-	offset = y * crtc->primary->fb->pitches[0] + x * (crtc->primary->fb->bits_per_pixel / 8);
+	offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
 
-	REG_WRITE(map->stride, crtc->primary->fb->pitches[0]);
+	REG_WRITE(map->stride, fb->pitches[0]);
 	dspcntr = REG_READ(map->cntr);
 	dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
 
-	switch (crtc->primary->fb->bits_per_pixel) {
+	switch (fb->bits_per_pixel) {
 	case 8:
 		dspcntr |= DISPPLANE_8BPP;
 		break;
 	case 16:
-		if (crtc->primary->fb->depth == 15)
+		if (fb->depth == 15)
 			dspcntr |= DISPPLANE_15_16BPP;
 		else
 			dspcntr |= DISPPLANE_16BPP;
drivers/gpu/drm/gma500/oaktrail_crtc.c +7 -6
index da9fd34b9550..a51896544d91 100644
@@ -599,7 +599,8 @@ static int oaktrail_pipe_set_base(struct drm_crtc *crtc,
 	struct drm_device *dev = crtc->dev;
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
-	struct psb_framebuffer *psbfb = to_psb_fb(crtc->primary->fb);
+	struct drm_framebuffer *fb = crtc->primary->fb;
+	struct psb_framebuffer *psbfb = to_psb_fb(fb);
 	int pipe = gma_crtc->pipe;
 	const struct psb_offset *map = &dev_priv->regmap[pipe];
 	unsigned long start, offset;
@@ -608,7 +609,7 @@ static int oaktrail_pipe_set_base(struct drm_crtc *crtc,
 	int ret = 0;
 
 	/* no fb bound */
-	if (!crtc->primary->fb) {
+	if (!fb) {
 		dev_dbg(dev->dev, "No FB bound\n");
 		return 0;
 	}
@@ -617,19 +618,19 @@ static int oaktrail_pipe_set_base(struct drm_crtc *crtc,
 		return 0;
 
 	start = psbfb->gtt->offset;
-	offset = y * crtc->primary->fb->pitches[0] + x * (crtc->primary->fb->bits_per_pixel / 8);
+	offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
 
-	REG_WRITE(map->stride, crtc->primary->fb->pitches[0]);
+	REG_WRITE(map->stride, fb->pitches[0]);
 
 	dspcntr = REG_READ(map->cntr);
 	dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
 
-	switch (crtc->primary->fb->bits_per_pixel) {
+	switch (fb->bits_per_pixel) {
 	case 8:
 		dspcntr |= DISPPLANE_8BPP;
 		break;
 	case 16:
-		if (crtc->primary->fb->depth == 15)
+		if (fb->depth == 15)
 			dspcntr |= DISPPLANE_15_16BPP;
 		else
 			dspcntr |= DISPPLANE_16BPP;
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

PATCH 7/32 drm/cirrus: Add some local 'fb' variables

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Add a local 'fb' variable to a few places to get rid of the 'crtc->primary->fb' stuff. Looks neater and helps me with my poor coccinelle skills later.

---
 drivers/gpu/drm/cirrus/cirrus_mode.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/cirrus/cirrus_mode.c +5 -4
index 17c915d9a03e..f2297acae235 100644
@@ -185,6 +185,7 @@ static int cirrus_crtc_mode_set(struct drm_crtc *crtc,
 {
 	struct drm_device *dev = crtc->dev;
 	struct cirrus_device *cdev = dev->dev_private;
+	const struct drm_framebuffer *fb = crtc->primary->fb;
 	int hsyncstart, hsyncend, htotal, hdispend;
 	int vtotal, vdispend;
 	int tmp;
@@ -257,7 +258,7 @@ static int cirrus_crtc_mode_set(struct drm_crtc *crtc,
 	sr07 = RREG8(SEQ_DATA);
 	sr07 &= 0xe0;
 	hdr = 0;
-	switch (crtc->primary->fb->bits_per_pixel) {
+	switch (fb->bits_per_pixel) {
 	case 8:
 		sr07 |= 0x11;
 		break;
@@ -280,13 +281,13 @@ static int cirrus_crtc_mode_set(struct drm_crtc *crtc,
 	WREG_SEQ(0x7, sr07);
 
 	/* Program the pitch */
-	tmp = crtc->primary->fb->pitches[0] / 8;
+	tmp = fb->pitches[0] / 8;
 	WREG_CRT(VGA_CRTC_OFFSET, tmp);
 
 	/* Enable extended blanking and pitch bits, and enable full memory */
 	tmp = 0x22;
-	tmp |= (crtc->primary->fb->pitches[0] >> 7) & 0x10;
-	tmp |= (crtc->primary->fb->pitches[0] >> 6) & 0x40;
+	tmp |= (fb->pitches[0] >> 7) & 0x10;
+	tmp |= (fb->pitches[0] >> 6) & 0x40;
 	WREG_CRT(0x1b, tmp);
 
 	/* Enable high-colour modes */
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw

PATCH 8/32 drm/arcpgu: Add local 'fb' variables

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Add a local 'fb' variable to a few places to get rid of the 'crtc->primary->fb' stuff. Looks neater and helps me with my ppor coccinelle skills later.

---
 drivers/gpu/drm/arc/arcpgu_crtc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/arc/arcpgu_crtc.c +2 -1
index 7130b044b004..5c26c5f126a3 100644
@@ -35,7 +35,8 @@ static struct simplefb_format supported_formats[] = {
 static void arc_pgu_set_pxl_fmt(struct drm_crtc *crtc)
 {
 	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
-	uint32_t pixel_format = crtc->primary->state->fb->pixel_format;
+	const struct drm_framebuffer *fb = crtc->primary->state->fb;
+	uint32_t pixel_format = fb->pixel_format;
 	struct simplefb_format *format = NULL;
 	int i;
 
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#11 lore raw

PATCH 9/32 drm/arm: Add local 'fb' variables

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Add a local 'fb' variable to a few places to get rid of the 'crtc->primary->fb' stuff. Looks neater and helps me with my ppor coccinelle skills later.

In some places the local variable was already there, just not used consistently.

Cc Liviu Dudau <[email protected]>
Cc Brian Starkey <[email protected]>
Cc Mali DP Maintainers <[email protected]>
---
 drivers/gpu/drm/arm/hdlcd_crtc.c    | 18 ++++++++++--------
 drivers/gpu/drm/arm/malidp_planes.c |  6 +++---
 2 files changed, 13 insertions(+), 11 deletions(-)
drivers/gpu/drm/arm/hdlcd_crtc.c +10 -8
index bbaa55add2d2..8a0fee03aa39 100644
@@ -60,11 +60,12 @@ static int hdlcd_set_pxl_fmt(struct drm_crtc *crtc)
 {
 	unsigned int btpp;
 	struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc);
+	const struct drm_framebuffer *fb = crtc->primary->state->fb;
 	uint32_t pixel_format;
 	struct simplefb_format *format = NULL;
 	int i;
 
-	pixel_format = crtc->primary->state->fb->pixel_format;
+	pixel_format = fb->pixel_format;
 
 	for (i = 0; i < ARRAY_SIZE(supported_formats); i++) {
 		if (supported_formats[i].fourcc == pixel_format)
@@ -221,27 +222,28 @@ static int hdlcd_plane_atomic_check(struct drm_plane *plane,
 static void hdlcd_plane_atomic_update(struct drm_plane *plane,
 				      struct drm_plane_state *state)
 {
+	struct drm_framebuffer *fb = plane->state->fb;
 	struct hdlcd_drm_private *hdlcd;
 	struct drm_gem_cma_object *gem;
 	u32 src_w, src_h, dest_w, dest_h;
 	dma_addr_t scanout_start;
 
-	if (!plane->state->fb)
+	if (!fb)
 		return;
 
 	src_w = plane->state->src_w >> 16;
 	src_h = plane->state->src_h >> 16;
 	dest_w = plane->state->crtc_w;
 	dest_h = plane->state->crtc_h;
-	gem = drm_fb_cma_get_gem_obj(plane->state->fb, 0);
-	scanout_start = gem->paddr + plane->state->fb->offsets[0] +
-		plane->state->crtc_y * plane->state->fb->pitches[0] +
+	gem = drm_fb_cma_get_gem_obj(fb, 0);
+	scanout_start = gem->paddr + fb->offsets[0] +
+		plane->state->crtc_y * fb->pitches[0] +
 		plane->state->crtc_x *
-		drm_format_plane_cpp(plane->state->fb->pixel_format, 0);
+		drm_format_plane_cpp(fb->pixel_format, 0);
 
 	hdlcd = plane->dev->dev_private;
-	hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_LENGTH, plane->state->fb->pitches[0]);
-	hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_PITCH, plane->state->fb->pitches[0]);
+	hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_LENGTH, fb->pitches[0]);
+	hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_PITCH, fb->pitches[0]);
 	hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_COUNT, dest_h - 1);
 	hdlcd_write(hdlcd, HDLCD_REG_FB_BASE, scanout_start);
 }
drivers/gpu/drm/arm/malidp_planes.c +3 -3
index 63eec8f37cfc..ee7f7663a307 100644
@@ -137,8 +137,8 @@ static int malidp_de_plane_check(struct drm_plane *plane,
 
 	/* packed RGB888 / BGR888 can't be rotated or flipped */
 	if (state->rotation != DRM_ROTATE_0 &&
-	    (state->fb->pixel_format == DRM_FORMAT_RGB888 ||
-	     state->fb->pixel_format == DRM_FORMAT_BGR888))
+	    (fb->pixel_format == DRM_FORMAT_RGB888 ||
+	     fb->pixel_format == DRM_FORMAT_BGR888))
 		return -EINVAL;
 
 	ms->rotmem_size = 0;
@@ -147,7 +147,7 @@ static int malidp_de_plane_check(struct drm_plane *plane,
 
 		val = mp->hwdev->rotmem_required(mp->hwdev, state->crtc_h,
 						 state->crtc_w,
-						 state->fb->pixel_format);
+						 fb->pixel_format);
 		if (val < 0)
 			return val;
 
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#12 lore raw

PATCH 10/32 drm/nouveau: Fix crtc->primary->fb vs. drm_fb fail

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

So it looks like the code is trying to pick between the passed in fb and crtc->primary->fb based on that funky 'bool atomic'. But later it will mix uses of both drm_fb (which was picked by the aforementioned logic) and crtc->primary->fb. So looks like a bug to me. Let's make it use drm_fb only.

---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/dispnv04/crtc.c +2 -2
index 59d1d1c5de5f..7c6c66f177df 100644
@@ -854,9 +854,9 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc,
 
 	/* Update the framebuffer format. */
 	regp->CRTC[NV_CIO_CRE_PIXEL_INDEX] &= ~3;
-	regp->CRTC[NV_CIO_CRE_PIXEL_INDEX] |= (crtc->primary->fb->depth + 1) / 8;
+	regp->CRTC[NV_CIO_CRE_PIXEL_INDEX] |= (drm_fb->depth + 1) / 8;
 	regp->ramdac_gen_ctrl &= ~NV_PRAMDAC_GENERAL_CONTROL_ALT_MODE_SEL;
-	if (crtc->primary->fb->depth == 16)
+	if (drm_fb->depth == 16)
 		regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_ALT_MODE_SEL;
 	crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_PIXEL_INDEX);
 	NVWriteRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_GENERAL_CONTROL,
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw

PATCH 11/32 drm/nouveau: Add local 'fb' variables

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Add a local 'fb' variable to a few places to get rid of the 'crtc->primary->fb' stuff. Looks neater and helps me with my poor coccinelle skills later.

---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 5 +++--
 drivers/gpu/drm/nouveau/dispnv04/dfp.c  | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/dispnv04/crtc.c +3 -2
index 7c6c66f177df..8286b8ffe109 100644
@@ -460,6 +460,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
 	struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
 	struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index];
 	struct nv04_crtc_reg *savep = &nv04_display(dev)->saved_reg.crtc_reg[nv_crtc->index];
+	const struct drm_framebuffer *fb = crtc->primary->fb;
 	struct drm_encoder *encoder;
 	bool lvds_output = false, tmds_output = false, tv_output = false,
 		off_chip_digital = false;
@@ -569,7 +570,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
 		regp->CRTC[NV_CIO_CRE_86] = 0x1;
 	}
 
-	regp->CRTC[NV_CIO_CRE_PIXEL_INDEX] = (crtc->primary->fb->depth + 1) / 8;
+	regp->CRTC[NV_CIO_CRE_PIXEL_INDEX] = (fb->depth + 1) / 8;
 	/* Enable slaved mode (called MODE_TV in nv4ref.h) */
 	if (lvds_output || tmds_output || tv_output)
 		regp->CRTC[NV_CIO_CRE_PIXEL_INDEX] |= (1 << 7);
@@ -583,7 +584,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
 	regp->ramdac_gen_ctrl = NV_PRAMDAC_GENERAL_CONTROL_BPC_8BITS |
 				NV_PRAMDAC_GENERAL_CONTROL_VGA_STATE_SEL |
 				NV_PRAMDAC_GENERAL_CONTROL_PIXMIX_ON;
-	if (crtc->primary->fb->depth == 16)
+	if (fb->depth == 16)
 		regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_ALT_MODE_SEL;
 	if (drm->device.info.chipset >= 0x11)
 		regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_PIPE_LONG;
drivers/gpu/drm/nouveau/dispnv04/dfp.c +2 -1
index c2947ef7d4fc..945607b3cd41 100644
@@ -290,6 +290,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder,
 	struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
 	struct drm_display_mode *output_mode = &nv_encoder->mode;
 	struct drm_connector *connector = &nv_connector->base;
+	const struct drm_framebuffer *fb = encoder->crtc->primary->fb;
 	uint32_t mode_ratio, panel_ratio;
 
 	NV_DEBUG(drm, "Output mode on CRTC %d:\n", nv_crtc->index);
@@ -415,7 +416,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder,
 	/* Output property. */
 	if ((nv_connector->dithering_mode == DITHERING_MODE_ON) ||
 	    (nv_connector->dithering_mode == DITHERING_MODE_AUTO &&
-	     encoder->crtc->primary->fb->depth > connector->display_info.bpc * 3)) {
+	     fb->depth > connector->display_info.bpc * 3)) {
 		if (drm->device.info.chipset == 0x11)
 			regp->dither = savep->dither | 0x00010000;
 		else {
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#14 lore raw

PATCH 12/32 drm/vmwgfx: Populate fb->dev before drm_framebuffer_init()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

drm_framebuffer_init() will start to check that fb->dev is already populated, so let's to that manually since vmwgfx isn't using drm_helper_mode_fill_fb_struct().

---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2 -0
index e3f68cc9bb4b..7d92ab56961b 100644
@@ -581,6 +581,7 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
 		goto out_err1;
 	}
 
+	vfbs->base.base.dev = dev;
 	/* XXX get the first 3 from the surface info */
 	vfbs->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbs->base.base.pitches[0] = mode_cmd->pitch;
@@ -875,6 +876,7 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
 		goto out_err1;
 	}
 
+	vfbd->base.base.dev = dev;
 	vfbd->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbd->base.base.pitches[0] = mode_cmd->pitch;
 	vfbd->base.base.depth = mode_cmd->depth;
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#15 lore raw

PATCH 13/32 drm: Pass 'dev' to drm_helper_mode_fill_fb_struct()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Pass the drm_device to drm_helper_mode_fill_fb_struct() so that we can populate fb->dev early. Will make it easier to use the fb before we register it.

@@
identifier fb, mode_cmd;
@@
void drm_helper_mode_fill_fb_struct(
+ struct drm_device *dev,
struct drm_framebuffer *fb, const struct drm_mode_fb_cmd2 *mode_cmd );

@@
identifier fb, mode_cmd;
@@
void drm_helper_mode_fill_fb_struct(
+ struct drm_device *dev,
struct drm_framebuffer *fb, const struct drm_mode_fb_cmd2 *mode_cmd )
{ ... }

@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,

				E1, E2);

...
}

@@
expression E1, E2;
@@
drm_helper_mode_fill_fb_struct(
+ dev,

				E1, E2);
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 +-
 drivers/gpu/drm/armada/armada_fb.c          | 2 +-
 drivers/gpu/drm/ast/ast_main.c              | 2 +-
 drivers/gpu/drm/bochs/bochs_mm.c            | 2 +-
 drivers/gpu/drm/cirrus/cirrus_main.c        | 2 +-
 drivers/gpu/drm/drm_fb_cma_helper.c         | 2 +-
 drivers/gpu/drm/drm_modeset_helper.c        | 3 ++-
 drivers/gpu/drm/exynos/exynos_drm_fb.c      | 2 +-
 drivers/gpu/drm/gma500/framebuffer.c        | 2 +-
 drivers/gpu/drm/i915/intel_display.c        | 2 +-
 drivers/gpu/drm/mediatek/mtk_drm_fb.c       | 2 +-
 drivers/gpu/drm/mgag200/mgag200_main.c      | 2 +-
 drivers/gpu/drm/msm/msm_fb.c                | 2 +-
 drivers/gpu/drm/nouveau/nouveau_display.c   | 2 +-
 drivers/gpu/drm/omapdrm/omap_fb.c           | 2 +-
 drivers/gpu/drm/qxl/qxl_display.c           | 2 +-
 drivers/gpu/drm/radeon/radeon_display.c     | 2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_fb.c  | 2 +-
 drivers/gpu/drm/tegra/fb.c                  | 2 +-
 drivers/gpu/drm/udl/udl_fb.c                | 2 +-
 drivers/gpu/drm/virtio/virtgpu_display.c    | 2 +-
 include/drm/drm_modeset_helper.h            | 3 ++-
 22 files changed, 24 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -1
index 741144fcc7bc..d492cf84ddc1 100644
@@ -508,7 +508,7 @@ amdgpu_framebuffer_init(struct drm_device *dev,
 {
 	int ret;
 	rfb->obj = obj;
-	drm_helper_mode_fill_fb_struct(&rfb->base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd);
 	ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
 	if (ret) {
 		rfb->obj = NULL;
drivers/gpu/drm/armada/armada_fb.c +1 -1
index f03c212b754d..2a7eb6817c36 100644
@@ -81,7 +81,7 @@ struct armada_framebuffer *armada_framebuffer_create(struct drm_device *dev,
 	dfb->mod = config;
 	dfb->obj = obj;
 
-	drm_helper_mode_fill_fb_struct(&dfb->fb, mode);
+	drm_helper_mode_fill_fb_struct(dev, &dfb->fb, mode);
 
 	ret = drm_framebuffer_init(dev, &dfb->fb, &armada_fb_funcs);
 	if (ret) {
drivers/gpu/drm/ast/ast_main.c +1 -1
index 904beaa932d0..d85af0ff2653 100644
@@ -313,7 +313,7 @@ int ast_framebuffer_init(struct drm_device *dev,
 {
 	int ret;
 
-	drm_helper_mode_fill_fb_struct(&ast_fb->base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &ast_fb->base, mode_cmd);
 	ast_fb->obj = obj;
 	ret = drm_framebuffer_init(dev, &ast_fb->base, &ast_fb_funcs);
 	if (ret) {
drivers/gpu/drm/bochs/bochs_mm.c +1 -1
index 099a3c688c26..ceb1fecf02dd 100644
@@ -484,7 +484,7 @@ int bochs_framebuffer_init(struct drm_device *dev,
 {
 	int ret;
 
-	drm_helper_mode_fill_fb_struct(&gfb->base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &gfb->base, mode_cmd);
 	gfb->obj = obj;
 	ret = drm_framebuffer_init(dev, &gfb->base, &bochs_fb_funcs);
 	if (ret) {
drivers/gpu/drm/cirrus/cirrus_main.c +1 -1
index 2c3c0d4072ce..52d901fa8687 100644
@@ -34,7 +34,7 @@ int cirrus_framebuffer_init(struct drm_device *dev,
 {
 	int ret;
 
-	drm_helper_mode_fill_fb_struct(&gfb->base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &gfb->base, mode_cmd);
 	gfb->obj = obj;
 	ret = drm_framebuffer_init(dev, &gfb->base, &cirrus_fb_funcs);
 	if (ret) {
drivers/gpu/drm/drm_fb_cma_helper.c +1 -1
index 81b3558302b5..570f5c6063f3 100644
@@ -147,7 +147,7 @@ static struct drm_fb_cma *drm_fb_cma_alloc(struct drm_device *dev,
 	if (!fb_cma)
 		return ERR_PTR(-ENOMEM);
 
-	drm_helper_mode_fill_fb_struct(&fb_cma->fb, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &fb_cma->fb, mode_cmd);
 
 	for (i = 0; i < num_planes; i++)
 		fb_cma->obj[i] = obj[i];
drivers/gpu/drm/drm_modeset_helper.c +2 -1
index cc232ac6c950..285ffcba0fe8 100644
@@ -68,7 +68,8 @@ EXPORT_SYMBOL(drm_helper_move_panel_connectors_to_head);
  * This helper can be used in a drivers fb_create callback to pre-fill the fb's
  * metadata fields.
  */
-void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
+void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
+				    struct drm_framebuffer *fb,
 				    const struct drm_mode_fb_cmd2 *mode_cmd)
 {
 	const struct drm_format_info *info;
drivers/gpu/drm/exynos/exynos_drm_fb.c +1 -1
index 23cce0a3f5fc..68d414227533 100644
@@ -126,7 +126,7 @@ exynos_drm_framebuffer_init(struct drm_device *dev,
 						+ mode_cmd->offsets[i];
 	}
 
-	drm_helper_mode_fill_fb_struct(&exynos_fb->fb, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &exynos_fb->fb, mode_cmd);
 
 	ret = drm_framebuffer_init(dev, &exynos_fb->fb, &exynos_drm_fb_funcs);
 	if (ret < 0) {
drivers/gpu/drm/gma500/framebuffer.c +1 -1
index 4071b2d1e8cf..6d89ed760941 100644
@@ -244,7 +244,7 @@ static int psb_framebuffer_init(struct drm_device *dev,
 	if (mode_cmd->pitches[0] & 63)
 		return -EINVAL;
 
-	drm_helper_mode_fill_fb_struct(&fb->base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &fb->base, mode_cmd);
 	fb->gtt = gt;
 	ret = drm_framebuffer_init(dev, &fb->base, &psb_fb_funcs);
 	if (ret) {
drivers/gpu/drm/i915/intel_display.c +1 -1
index bd2c99e2e523..12af936a402d 100644
@@ -15880,7 +15880,7 @@ static int intel_framebuffer_init(struct drm_device *dev,
 	if (mode_cmd->offsets[0] != 0)
 		return -EINVAL;
 
-	drm_helper_mode_fill_fb_struct(&intel_fb->base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &intel_fb->base, mode_cmd);
 	intel_fb->obj = obj;
 
 	ret = intel_fill_fb_info(dev_priv, &intel_fb->base);
drivers/gpu/drm/mediatek/mtk_drm_fb.c +1 -1
index 147df85399ab..d4246c9dceae 100644
@@ -82,7 +82,7 @@ static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct drm_device *dev,
 	if (!mtk_fb)
 		return ERR_PTR(-ENOMEM);
 
-	drm_helper_mode_fill_fb_struct(&mtk_fb->base, mode);
+	drm_helper_mode_fill_fb_struct(dev, &mtk_fb->base, mode);
 
 	mtk_fb->gem_obj = obj;
 
drivers/gpu/drm/mgag200/mgag200_main.c +1 -1
index e79cbc25ae3c..95d628b9457e 100644
@@ -34,7 +34,7 @@ int mgag200_framebuffer_init(struct drm_device *dev,
 {
 	int ret;
 	
-	drm_helper_mode_fill_fb_struct(&gfb->base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &gfb->base, mode_cmd);
 	gfb->obj = obj;
 	ret = drm_framebuffer_init(dev, &gfb->base, &mga_fb_funcs);
 	if (ret) {
drivers/gpu/drm/msm/msm_fb.c +1 -1
index 95cf8fe72ee5..9614ed405808 100644
@@ -217,7 +217,7 @@ struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
 		msm_fb->planes[i] = bos[i];
 	}
 
-	drm_helper_mode_fill_fb_struct(fb, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
 
 	ret = drm_framebuffer_init(dev, fb, &msm_framebuffer_funcs);
 	if (ret) {
drivers/gpu/drm/nouveau/nouveau_display.c +1 -1
index 5698687bc197..a46d893aaafa 100644
@@ -258,7 +258,7 @@ nouveau_framebuffer_new(struct drm_device *dev,
 	if (!(fb = *pfb = kzalloc(sizeof(*fb), GFP_KERNEL)))
 		return -ENOMEM;
 
-	drm_helper_mode_fill_fb_struct(&fb->base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &fb->base, mode_cmd);
 	fb->nvbo = nvbo;
 
 	ret = drm_framebuffer_init(dev, &fb->base, &nouveau_framebuffer_funcs);
drivers/gpu/drm/omapdrm/omap_fb.c +1 -1
index 5f3337f1e9aa..9875c99be009 100644
@@ -457,7 +457,7 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
 		plane->paddr  = 0;
 	}
 
-	drm_helper_mode_fill_fb_struct(fb, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
 
 	ret = drm_framebuffer_init(dev, fb, &omap_framebuffer_funcs);
 	if (ret) {
drivers/gpu/drm/qxl/qxl_display.c +1 -1
index a61c0d460ec2..bcbad877ce4f 100644
@@ -584,7 +584,7 @@ qxl_framebuffer_init(struct drm_device *dev,
 		qfb->obj = NULL;
 		return ret;
 	}
-	drm_helper_mode_fill_fb_struct(&qfb->base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &qfb->base, mode_cmd);
 	return 0;
 }
 
drivers/gpu/drm/radeon/radeon_display.c +1 -1
index e7409e8a9f87..6285355eb5d5 100644
@@ -1327,7 +1327,7 @@ radeon_framebuffer_init(struct drm_device *dev,
 {
 	int ret;
 	rfb->obj = obj;
-	drm_helper_mode_fill_fb_struct(&rfb->base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd);
 	ret = drm_framebuffer_init(dev, &rfb->base, &radeon_fb_funcs);
 	if (ret) {
 		rfb->obj = NULL;
drivers/gpu/drm/rockchip/rockchip_drm_fb.c +1 -1
index 0f6eda023bd0..d5e1f8627d38 100644
@@ -92,7 +92,7 @@ rockchip_fb_alloc(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cm
 	if (!rockchip_fb)
 		return ERR_PTR(-ENOMEM);
 
-	drm_helper_mode_fill_fb_struct(&rockchip_fb->fb, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &rockchip_fb->fb, mode_cmd);
 
 	for (i = 0; i < num_planes; i++)
 		rockchip_fb->obj[i] = obj[i];
drivers/gpu/drm/tegra/fb.c +1 -1
index e4a5ab0a9677..a0096493f51c 100644
@@ -114,7 +114,7 @@ static struct tegra_fb *tegra_fb_alloc(struct drm_device *drm,
 
 	fb->num_planes = num_planes;
 
-	drm_helper_mode_fill_fb_struct(&fb->base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(drm, &fb->base, mode_cmd);
 
 	for (i = 0; i < fb->num_planes; i++)
 		fb->planes[i] = planes[i];
drivers/gpu/drm/udl/udl_fb.c +1 -1
index 167f42c67c7c..fefd87f422ec 100644
@@ -330,7 +330,7 @@ udl_framebuffer_init(struct drm_device *dev,
 	int ret;
 
 	ufb->obj = obj;
-	drm_helper_mode_fill_fb_struct(&ufb->base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &ufb->base, mode_cmd);
 	ret = drm_framebuffer_init(dev, &ufb->base, &udlfb_funcs);
 	return ret;
 }
drivers/gpu/drm/virtio/virtgpu_display.c +1 -1
index 58048709c34e..8b80fdd0e0a8 100644
@@ -93,7 +93,7 @@ virtio_gpu_framebuffer_init(struct drm_device *dev,
 		vgfb->obj = NULL;
 		return ret;
 	}
-	drm_helper_mode_fill_fb_struct(&vgfb->base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &vgfb->base, mode_cmd);
 
 	spin_lock_init(&vgfb->dirty_lock);
 	vgfb->x1 = vgfb->y1 = INT_MAX;
include/drm/drm_modeset_helper.h +2 -1
index b8051d5abe10..cb0ec92e11e6 100644
@@ -27,7 +27,8 @@
 
 void drm_helper_move_panel_connectors_to_head(struct drm_device *);
 
-void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
+void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
+				    struct drm_framebuffer *fb,
 				    const struct drm_mode_fb_cmd2 *mode_cmd);
 
 int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 13/32
#16 lore raw

Re: [PATCH 13/32] drm: Pass 'dev' to drm_helper_mode_fill_fb_struct()

Hi Ville,

Thank you for the patch.

Quoted 36 lines · On Thursday 17 Nov 2016 18:14:12 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Pass the drm_device to drm_helper_mode_fill_fb_struct() so that we can populate fb->dev early. Will make it easier to use the fb before we register it.

@@
identifier fb, mode_cmd;
@@
void drm_helper_mode_fill_fb_struct(

(quoted diff) +1 -0
+				     struct drm_device *dev,

struct drm_framebuffer *fb, const struct drm_mode_fb_cmd2 *mode_cmd );

@@
identifier fb, mode_cmd;
@@
void drm_helper_mode_fill_fb_struct(

(quoted diff) +1 -0
+				     struct drm_device *dev,

struct drm_framebuffer *fb, const struct drm_mode_fb_cmd2 *mode_cmd )
{ ... }

@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(

(quoted diff) +1 -0
+				dev,
				E1, E2);
Quoted 2 lines

...
}

Just for the tegra driver :-)

Quoted 8 lines

@@
expression E1, E2;
@@
drm_helper_mode_fill_fb_struct(

(quoted diff) +1 -0
+				dev,
				E1, E2);
Quoted 24 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 +-
 drivers/gpu/drm/armada/armada_fb.c          | 2 +-
 drivers/gpu/drm/ast/ast_main.c              | 2 +-
 drivers/gpu/drm/bochs/bochs_mm.c            | 2 +-
 drivers/gpu/drm/cirrus/cirrus_main.c        | 2 +-
 drivers/gpu/drm/drm_fb_cma_helper.c         | 2 +-
 drivers/gpu/drm/drm_modeset_helper.c        | 3 ++-
 drivers/gpu/drm/exynos/exynos_drm_fb.c      | 2 +-
 drivers/gpu/drm/gma500/framebuffer.c        | 2 +-
 drivers/gpu/drm/i915/intel_display.c        | 2 +-
 drivers/gpu/drm/mediatek/mtk_drm_fb.c       | 2 +-
 drivers/gpu/drm/mgag200/mgag200_main.c      | 2 +-
 drivers/gpu/drm/msm/msm_fb.c                | 2 +-
 drivers/gpu/drm/nouveau/nouveau_display.c   | 2 +-
 drivers/gpu/drm/omapdrm/omap_fb.c           | 2 +-
 drivers/gpu/drm/qxl/qxl_display.c           | 2 +-
 drivers/gpu/drm/radeon/radeon_display.c     | 2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_fb.c  | 2 +-
 drivers/gpu/drm/tegra/fb.c                  | 2 +-
 drivers/gpu/drm/udl/udl_fb.c                | 2 +-
 drivers/gpu/drm/virtio/virtgpu_display.c    | 2 +-
 include/drm/drm_modeset_helper.h            | 3 ++-
 22 files changed, 24 insertions(+), 22 deletions(-)
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#17 lore raw

PATCH 14/32 drm/vmwgfx: Populate fb->pixel_format

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Stuff something semi-reasonable into fb->pixel_format. I had to guess as to which formats we should pick. Did I guess correctly?

We can't quite use drm_mode_legacy_fb_format() due to the ARGB1555 vs. XRGB155 mess. However use of 'A' formats should imply per-pixel alpha blending as far as KMS is concerned so I'm not at all sure we want to have any 'A' formats exposed as opposed to just 'X' formats. OTOH vmvgfx doesn't do planes, and so the core won't enforce that these formats match any list of supported formats, so the choice shouldn't be super important at this point.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +22 -1
index 7d92ab56961b..5788913ca8f9 100644
@@ -524,6 +524,7 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
 	struct drm_device *dev = dev_priv->dev;
 	struct vmw_framebuffer_surface *vfbs;
 	enum SVGA3dSurfaceFormat format;
+	u32 pixel_format;
 	int ret;
 
 	/* 3D is only supported on HWv8 and newer hosts */
@@ -548,17 +549,22 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
 		return -EINVAL;
 	}
 
+	/* FIXME 'A' format implies per-pixel alpha blending for KMS */
 	switch (mode_cmd->depth) {
 	case 32:
+		pixel_format = DRM_FORMAT_ARGB8888;
 		format = SVGA3D_A8R8G8B8;
 		break;
 	case 24:
+		pixel_format = DRM_FORMAT_XRGB8888;
 		format = SVGA3D_X8R8G8B8;
 		break;
 	case 16:
+		pixel_format = DRM_FORMAT_RGB565;
 		format = SVGA3D_R5G6B5;
 		break;
 	case 15:
+		pixel_format = DRM_FORMAT_ARGB1555;
 		format = SVGA3D_A1R5G5B5;
 		break;
 	default:
@@ -582,7 +588,8 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
 	}
 
 	vfbs->base.base.dev = dev;
-	/* XXX get the first 3 from the surface info */
+	/* XXX get the first 4 from the surface info */
+	vfbs->base.base.pixel_format = pixel_format;
 	vfbs->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbs->base.base.pitches[0] = mode_cmd->pitch;
 	vfbs->base.base.depth = mode_cmd->depth;
@@ -834,6 +841,7 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
 	struct drm_device *dev = dev_priv->dev;
 	struct vmw_framebuffer_dmabuf *vfbd;
 	unsigned int requested_size;
+	u32 pixel_format;
 	int ret;
 
 	requested_size = mode_cmd->height * mode_cmd->pitch;
@@ -852,6 +860,12 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
 			if (mode_cmd->bpp == 32)
 				break;
 
+			/* FIXME 'A' format implies per-pixel alpha blending for KMS */
+			if (mode_cmd->depth == 32)
+				pixel_format = DRM_FORMAT_ARGB8888;
+			else
+				pixel_format = DRM_FORMAT_XRGB8888;
+
 			DRM_ERROR("Invalid color depth/bbp: %d %d\n",
 				  mode_cmd->depth, mode_cmd->bpp);
 			return -EINVAL;
@@ -861,6 +875,12 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
 			if (mode_cmd->bpp == 16)
 				break;
 
+			/* FIXME 'A' format implies per-pixel alpha blending for KMS */
+			if (mode_cmd->depth == 16)
+				pixel_format = DRM_FORMAT_RGB565;
+			else
+				pixel_format = DRM_FORMAT_ARGB1555;
+
 			DRM_ERROR("Invalid color depth/bbp: %d %d\n",
 				  mode_cmd->depth, mode_cmd->bpp);
 			return -EINVAL;
@@ -877,6 +897,7 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
 	}
 
 	vfbd->base.base.dev = dev;
+	vfbd->base.base.pixel_format = pixel_format;
 	vfbd->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbd->base.base.pitches[0] = mode_cmd->pitch;
 	vfbd->base.base.depth = mode_cmd->depth;
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#18 lore raw

Re: [PATCH 14/32] drm/vmwgfx: Populate fb->pixel_format

Hi Ville,

Thank you for the patch.

Quoted 5 lines · On Thursday 17 Nov 2016 18:14:13 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Stuff something semi-reasonable into fb->pixel_format. I had to guess as to which formats we should pick. Did I guess correctly?

Quoted 7 lines

We can't quite use drm_mode_legacy_fb_format() due to the ARGB1555 vs. XRGB155 mess. However use of 'A' formats should imply per-pixel alpha blending as far as KMS is concerned so I'm not at all sure we want to have any 'A' formats exposed as opposed to just 'X' formats. OTOH vmvgfx doesn't do planes, and so the core won't enforce that these formats match any list of supported formats, so the choice shouldn't be super important at this point.

The vmgfx driver should really be converted to using struct drm_mode_fb_cmd2 through the whole code instead of converting struct drm_mode_fb_cmd2 to struct drm_mode_fb_cmd in vmw_kms_fb_create(). I gave it a go a few months back but the structure is passed around so many functions that conversion requires more knowledge about the driver than I have. I don't expect you to fix that, but it would be nice if Sinclair or Thomas could give it a go.

Quoted 63 lines
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 7d92ab56961b..5788913ca8f9 100644

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +9 -1
@@ -524,6 +524,7 @@ static int vmw_kms_new_framebuffer_surface(struct
 vmw_private *dev_priv, struct drm_device *dev = dev_priv->dev;
 	struct vmw_framebuffer_surface *vfbs;
 	enum SVGA3dSurfaceFormat format;
+	u32 pixel_format;
 	int ret;
 
 	/* 3D is only supported on HWv8 and newer hosts */
@@ -548,17 +549,22 @@ static int vmw_kms_new_framebuffer_surface(struct
 vmw_private *dev_priv, return -EINVAL;
 	}
 
+	/* FIXME 'A' format implies per-pixel alpha blending for KMS */
 	switch (mode_cmd->depth) {
 	case 32:
+		pixel_format = DRM_FORMAT_ARGB8888;
 		format = SVGA3D_A8R8G8B8;
 		break;
 	case 24:
+		pixel_format = DRM_FORMAT_XRGB8888;
 		format = SVGA3D_X8R8G8B8;
 		break;
 	case 16:
+		pixel_format = DRM_FORMAT_RGB565;
 		format = SVGA3D_R5G6B5;
 		break;
 	case 15:
+		pixel_format = DRM_FORMAT_ARGB1555;
 		format = SVGA3D_A1R5G5B5;
 		break;
 	default:
@@ -582,7 +588,8 @@ static int vmw_kms_new_framebuffer_surface(struct
 vmw_private *dev_priv, }
 
 	vfbs->base.base.dev = dev;
-	/* XXX get the first 3 from the surface info */
+	/* XXX get the first 4 from the surface info */
+	vfbs->base.base.pixel_format = pixel_format;
 	vfbs->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbs->base.base.pitches[0] = mode_cmd->pitch;
 	vfbs->base.base.depth = mode_cmd->depth;
@@ -834,6 +841,7 @@ static int vmw_kms_new_framebuffer_dmabuf(struct
 vmw_private *dev_priv, struct drm_device *dev = dev_priv->dev;
 	struct vmw_framebuffer_dmabuf *vfbd;
 	unsigned int requested_size;
+	u32 pixel_format;
 	int ret;
 
 	requested_size = mode_cmd->height * mode_cmd->pitch;

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c static int vmw_kms_new_framebuffer_dmabuf(struct · line 863

Quoted 4 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +1 -0
@@ -852,6 +860,12 @@ static int vmw_kms_new_framebuffer_dmabuf(struct
 vmw_private *dev_priv, if (mode_cmd->bpp == 32)
 				break;
 
+			/* FIXME 'A' format implies per-pixel alpha blending 

for KMS */

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c static int vmw_kms_new_framebuffer_dmabuf(struct · line 878

Quoted 13 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +6 -0
+			if (mode_cmd->depth == 32)
+				pixel_format = DRM_FORMAT_ARGB8888;
+			else
+				pixel_format = DRM_FORMAT_XRGB8888;
+
 			DRM_ERROR("Invalid color depth/bbp: %d %d\n",
 				  mode_cmd->depth, mode_cmd->bpp);
 			return -EINVAL;
@@ -861,6 +875,12 @@ static int vmw_kms_new_framebuffer_dmabuf(struct
 vmw_private *dev_priv, if (mode_cmd->bpp == 16)
 				break;
 
+			/* FIXME 'A' format implies per-pixel alpha blending 

for KMS */

Quoted 16 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +6 -0
+			if (mode_cmd->depth == 16)
+				pixel_format = DRM_FORMAT_RGB565;
+			else
+				pixel_format = DRM_FORMAT_ARGB1555;
+
 			DRM_ERROR("Invalid color depth/bbp: %d %d\n",
 				  mode_cmd->depth, mode_cmd->bpp);
 			return -EINVAL;
@@ -877,6 +897,7 @@ static int vmw_kms_new_framebuffer_dmabuf(struct
 vmw_private *dev_priv, }
 
 	vfbd->base.base.dev = dev;
+	vfbd->base.base.pixel_format = pixel_format;
 	vfbd->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbd->base.base.pitches[0] = mode_cmd->pitch;
 	vfbd->base.base.depth = mode_cmd->depth;
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#19 lore raw

Re: [PATCH 14/32] drm/vmwgfx: Populate fb->pixel_format

Quoted 18 lines · Laurent Pinchart

Hi Ville,

Thank you for the patch.

Quoted 5 lines · On Thursday 17 Nov 2016 18:14:13 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Stuff something semi-reasonable into fb->pixel_format. I had to guess as to which formats we should pick. Did I guess correctly?

Quoted 7 lines

We can't quite use drm_mode_legacy_fb_format() due to the ARGB1555 vs. XRGB155 mess. However use of 'A' formats should imply per-pixel alpha blending as far as KMS is concerned so I'm not at all sure we want to have any 'A' formats exposed as opposed to just 'X' formats. OTOH vmvgfx doesn't do planes, and so the core won't enforce that these formats match any list of supported formats, so the choice shouldn't be super important at this point.

Quoted 6 lines

The vmgfx driver should really be converted to using struct drm_mode_fb_cmd2 through the whole code instead of converting struct drm_mode_fb_cmd2 to struct drm_mode_fb_cmd in vmw_kms_fb_create(). I gave it a go a few months back but the structure is passed around so many functions that conversion requires more knowledge about the driver than I have. I don't expect you to fix that, but it would be nice if Sinclair or Thomas could give it a go.

Indeed. Would be nice to bring all drivers into the fold. I didn't want to start down this particular hole with the series already too big as is.

Quoted 104 lines
Quoted 64 lines
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 7d92ab56961b..5788913ca8f9 100644

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +9 -1
@@ -524,6 +524,7 @@ static int vmw_kms_new_framebuffer_surface(struct
 vmw_private *dev_priv, struct drm_device *dev = dev_priv->dev;
 	struct vmw_framebuffer_surface *vfbs;
 	enum SVGA3dSurfaceFormat format;
+	u32 pixel_format;
 	int ret;
 
 	/* 3D is only supported on HWv8 and newer hosts */
@@ -548,17 +549,22 @@ static int vmw_kms_new_framebuffer_surface(struct
 vmw_private *dev_priv, return -EINVAL;
 	}
 
+	/* FIXME 'A' format implies per-pixel alpha blending for KMS */
 	switch (mode_cmd->depth) {
 	case 32:
+		pixel_format = DRM_FORMAT_ARGB8888;
 		format = SVGA3D_A8R8G8B8;
 		break;
 	case 24:
+		pixel_format = DRM_FORMAT_XRGB8888;
 		format = SVGA3D_X8R8G8B8;
 		break;
 	case 16:
+		pixel_format = DRM_FORMAT_RGB565;
 		format = SVGA3D_R5G6B5;
 		break;
 	case 15:
+		pixel_format = DRM_FORMAT_ARGB1555;
 		format = SVGA3D_A1R5G5B5;
 		break;
 	default:
@@ -582,7 +588,8 @@ static int vmw_kms_new_framebuffer_surface(struct
 vmw_private *dev_priv, }
 
 	vfbs->base.base.dev = dev;
-	/* XXX get the first 3 from the surface info */
+	/* XXX get the first 4 from the surface info */
+	vfbs->base.base.pixel_format = pixel_format;
 	vfbs->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbs->base.base.pitches[0] = mode_cmd->pitch;
 	vfbs->base.base.depth = mode_cmd->depth;
@@ -834,6 +841,7 @@ static int vmw_kms_new_framebuffer_dmabuf(struct
 vmw_private *dev_priv, struct drm_device *dev = dev_priv->dev;
 	struct vmw_framebuffer_dmabuf *vfbd;
 	unsigned int requested_size;
+	u32 pixel_format;
 	int ret;
 
 	requested_size = mode_cmd->height * mode_cmd->pitch;

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c static int vmw_kms_new_framebuffer_dmabuf(struct · line 863

Quoted 4 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +1 -0
@@ -852,6 +860,12 @@ static int vmw_kms_new_framebuffer_dmabuf(struct
 vmw_private *dev_priv, if (mode_cmd->bpp == 32)
 				break;
 
+			/* FIXME 'A' format implies per-pixel alpha blending 

for KMS */

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c static int vmw_kms_new_framebuffer_dmabuf(struct · line 878

Quoted 13 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +6 -0
+			if (mode_cmd->depth == 32)
+				pixel_format = DRM_FORMAT_ARGB8888;
+			else
+				pixel_format = DRM_FORMAT_XRGB8888;
+
 			DRM_ERROR("Invalid color depth/bbp: %d %d\n",
 				  mode_cmd->depth, mode_cmd->bpp);
 			return -EINVAL;
@@ -861,6 +875,12 @@ static int vmw_kms_new_framebuffer_dmabuf(struct
 vmw_private *dev_priv, if (mode_cmd->bpp == 16)
 				break;
 
+			/* FIXME 'A' format implies per-pixel alpha blending 

for KMS */

Quoted 16 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +6 -0
+			if (mode_cmd->depth == 16)
+				pixel_format = DRM_FORMAT_RGB565;
+			else
+				pixel_format = DRM_FORMAT_ARGB1555;
+
 			DRM_ERROR("Invalid color depth/bbp: %d %d\n",
 				  mode_cmd->depth, mode_cmd->bpp);
 			return -EINVAL;
@@ -877,6 +897,7 @@ static int vmw_kms_new_framebuffer_dmabuf(struct
 vmw_private *dev_priv, }
 
 	vfbd->base.base.dev = dev;
+	vfbd->base.base.pixel_format = pixel_format;
 	vfbd->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbd->base.base.pitches[0] = mode_cmd->pitch;
 	vfbd->base.base.depth = mode_cmd->depth;
Signature · 3 lines
Regards,

Laurent Pinchart
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#20 lore raw

PATCH 15/32 drm/qxl: Call drm_helper_mode_fill_fb_struct() before drm_framebuffer_init()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

We want framebuffers to be mostly useable already before drm_framebuffer_init() is called, and so we will start demanding that all the interesting format/size/etc. information be filled in before drm_framebuffer_init(). drm_helper_mode_fill_fb_struct() will do that for us, so let's make sure it gets called before drm_framebuffer_init().

---
 drivers/gpu/drm/qxl/qxl_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_display.c +1 -1
index bcbad877ce4f..9e2c92b9d12e 100644
@@ -579,12 +579,12 @@ qxl_framebuffer_init(struct drm_device *dev,
 	int ret;
 
 	qfb->obj = obj;
+	drm_helper_mode_fill_fb_struct(dev, &qfb->base, mode_cmd);
 	ret = drm_framebuffer_init(dev, &qfb->base, funcs);
 	if (ret) {
 		qfb->obj = NULL;
 		return ret;
 	}
-	drm_helper_mode_fill_fb_struct(dev, &qfb->base, mode_cmd);
 	return 0;
 }
 
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#21 lore raw

PATCH 16/32 drm/virtio: Call drm_helper_mode_fill_fb_struct() before drm_framebuffer_init()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

We want framebuffers to be mostly useable already before drm_framebuffer_init() get called, and so we will start demanding that all the interesting format/size/etc. information be filled in before drm_framebuffer_init(). drm_helper_mode_fill_fb_struct() will do that for us, so let's make sure it gets called before drm_framebuffer_init().

Cc Dave Airlie <[email protected]>
Cc Gerd Hoffmann <[email protected]>
---
 drivers/gpu/drm/virtio/virtgpu_display.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_display.c +2 -1
index 8b80fdd0e0a8..fad5a1cc5903 100644
@@ -88,12 +88,13 @@ virtio_gpu_framebuffer_init(struct drm_device *dev,
 
 	bo = gem_to_virtio_gpu_obj(obj);
 
+	drm_helper_mode_fill_fb_struct(dev, &vgfb->base, mode_cmd);
+
 	ret = drm_framebuffer_init(dev, &vgfb->base, &virtio_gpu_fb_funcs);
 	if (ret) {
 		vgfb->obj = NULL;
 		return ret;
 	}
-	drm_helper_mode_fill_fb_struct(dev, &vgfb->base, mode_cmd);
 
 	spin_lock_init(&vgfb->dirty_lock);
 	vgfb->x1 = vgfb->y1 = INT_MAX;
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#22 lore raw

PATCH 17/32 drm/i915: Set fb->dev early on for inherited fbs

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

We want the fbs inherited from the BIOS to be more or less fully working prior to actually registering them. This will allow us to just pass the fb to various helper function instead of having to pass all the different parameters separately.

---
 drivers/gpu/drm/i915/intel_display.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_display.c +6 -0
index 12af936a402d..74a638c8de61 100644
@@ -8704,6 +8704,8 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
 
 	fb = &intel_fb->base;
 
+	fb->dev = dev;
+
 	if (INTEL_GEN(dev_priv) >= 4) {
 		if (val & DISPPLANE_TILED) {
 			plane_config->tiling = I915_TILING_X;
@@ -9734,6 +9736,8 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
 
 	fb = &intel_fb->base;
 
+	fb->dev = dev;
+
 	val = I915_READ(PLANE_CTL(pipe, 0));
 	if (!(val & PLANE_CTL_ENABLE))
 		goto error;
@@ -9846,6 +9850,8 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
 
 	fb = &intel_fb->base;
 
+	fb->dev = dev;
+
 	if (INTEL_GEN(dev_priv) >= 4) {
 		if (val & DISPPLANE_TILED) {
 			plane_config->tiling = I915_TILING_X;
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#23 lore raw

PATCH 18/32 drm: Populate fb->dev from drm_helper_mode_fill_fb_struct()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Populating fb->dev before drm_framebuffer_init() allows us to use fb->dev already while validating the framebuffer. Let's have drm_helper_mode_fill_fb_struct() do that for us.

Also make drm_framebuffer_init() warn us if a different device pointer is passed to it than was passed to drm_helper_mode_fill_fb_struct().

---
 drivers/gpu/drm/drm_framebuffer.c    | 3 ++-
 drivers/gpu/drm/drm_modeset_helper.c | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_framebuffer.c +2 -1
index cbf0c893f426..527220c08f9b 100644
@@ -632,7 +632,8 @@ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
 	int ret;
 
 	INIT_LIST_HEAD(&fb->filp_head);
-	fb->dev = dev;
+	if (WARN_ON_ONCE(fb->dev != dev))
+		fb->dev = dev;
 	fb->funcs = funcs;
 
 	ret = drm_mode_object_get_reg(dev, &fb->base, DRM_MODE_OBJECT_FB,
drivers/gpu/drm/drm_modeset_helper.c +1 -0
index 285ffcba0fe8..57a319e3f780 100644
@@ -90,6 +90,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
 		fb->bits_per_pixel = info->cpp[0] * 8;
 	}
 
+	fb->dev = dev;
 	fb->width = mode_cmd->width;
 	fb->height = mode_cmd->height;
 	for (i = 0; i < 4; i++) {
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 18/32
#24 lore raw

Re: [PATCH 18/32] drm: Populate fb->dev from drm_helper_mode_fill_fb_struct()

Hi Ville,

Thank you for the patch.

Quoted 11 lines · On Thursday 17 Nov 2016 18:14:17 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Populating fb->dev before drm_framebuffer_init() allows us to use fb->dev already while validating the framebuffer. Let's have drm_helper_mode_fill_fb_struct() do that for us.

Also make drm_framebuffer_init() warn us if a different device pointer is passed to it than was passed to drm_helper_mode_fill_fb_struct().

Quoted 32 lines
---
 drivers/gpu/drm/drm_framebuffer.c    | 3 ++-
 drivers/gpu/drm/drm_modeset_helper.c | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_framebuffer.c index cbf0c893f426..527220c08f9b 100644

drivers/gpu/drm/drm_framebuffer.c +2 -1
@@ -632,7 +632,8 @@ int drm_framebuffer_init(struct drm_device *dev, struct
 drm_framebuffer *fb, int ret;
 
 	INIT_LIST_HEAD(&fb->filp_head);
-	fb->dev = dev;
+	if (WARN_ON_ONCE(fb->dev != dev))
+		fb->dev = dev;
 	fb->funcs = funcs;
 
 	ret = drm_mode_object_get_reg(dev, &fb->base, DRM_MODE_OBJECT_FB,
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_modeset_helper.c index 285ffcba0fe8..57a319e3f780 100644

drivers/gpu/drm/drm_modeset_helper.c +1 -0
@@ -90,6 +90,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device
 *dev, fb->bits_per_pixel = info->cpp[0] * 8;
 	}
 
+	fb->dev = dev;
 	fb->width = mode_cmd->width;
 	fb->height = mode_cmd->height;
 	for (i = 0; i < 4; i++) {
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#25 lore raw

PATCH 19/32 drm: Store a pointer to drm_format_info under drm_framebuffer

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

To avoid having to look up the format information struct every time, let's just store a pointer to it under drm_framebuffer.

---
 drivers/gpu/drm/drm_framebuffer.c    | 4 +++-
 drivers/gpu/drm/drm_modeset_helper.c | 1 +
 include/drm/drm_framebuffer.h        | 4 ++++
 3 files changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_framebuffer.c +3 -1
index 527220c08f9b..47478678d609 100644
@@ -632,8 +632,10 @@ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
 	int ret;
 
 	INIT_LIST_HEAD(&fb->filp_head);
-	if (WARN_ON_ONCE(fb->dev != dev))
+	if (WARN_ON_ONCE(fb->dev != dev)) {
 		fb->dev = dev;
+		fb->format = drm_format_info(fb->pixel_format);
+	}
 	fb->funcs = funcs;
 
 	ret = drm_mode_object_get_reg(dev, &fb->base, DRM_MODE_OBJECT_FB,
drivers/gpu/drm/drm_modeset_helper.c +1 -0
index 57a319e3f780..1aa5e3bcc8a1 100644
@@ -91,6 +91,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
 	}
 
 	fb->dev = dev;
+	fb->format = info;
 	fb->width = mode_cmd->width;
 	fb->height = mode_cmd->height;
 	for (i = 0; i < 4; i++) {
include/drm/drm_framebuffer.h +4 -0
index b3141a0e609b..741b3a994d1f 100644
@@ -122,6 +122,10 @@ struct drm_framebuffer {
 	 */
 	struct drm_mode_object base;
 	/**
+	 * @format: framebuffer format information
+	 */
+	const struct drm_format_info *format;
+	/**
 	 * @funcs: framebuffer vfunc table
 	 */
 	const struct drm_framebuffer_funcs *funcs;
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#26 lore raw

Re: [PATCH 19/32] drm: Store a pointer to drm_format_info under drm_framebuffer

Hi Ville,

Thank you for the patch.

Quoted 17 lines · On Thursday 17 Nov 2016 18:14:18 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

To avoid having to look up the format information struct every time, let's just store a pointer to it under drm_framebuffer.

---
 drivers/gpu/drm/drm_framebuffer.c    | 4 +++-
 drivers/gpu/drm/drm_modeset_helper.c | 1 +
 include/drm/drm_framebuffer.h        | 4 ++++
 3 files changed, 8 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_framebuffer.c index 527220c08f9b..47478678d609 100644

drivers/gpu/drm/drm_framebuffer.c int drm_framebuffer_init(struct drm_device *dev, struct · line 638

Quoted 8 lines
drivers/gpu/drm/drm_framebuffer.c +3 -1
@@ -632,8 +632,10 @@ int drm_framebuffer_init(struct drm_device *dev, struct
 drm_framebuffer *fb, int ret;
 
 	INIT_LIST_HEAD(&fb->filp_head);
-	if (WARN_ON_ONCE(fb->dev != dev))
+	if (WARN_ON_ONCE(fb->dev != dev)) {
 		fb->dev = dev;
+		fb->format = drm_format_info(fb->pixel_format);
+	}

With this drivers will start relying on fb->format. I believe we should commit to provide a non-NULL format info to avoid having to sprinkle NULL checks in all drivers. Should drm_framebuffer_init() return an error in that case ? Or do we guarantee already through another mean that the pixel format is valid and will always lead to a non-NULL format info here ?

Quoted 31 lines
drivers/gpu/drm/drm_framebuffer.c +0 -0
 	fb->funcs = funcs;
 
 	ret = drm_mode_object_get_reg(dev, &fb->base, DRM_MODE_OBJECT_FB,
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_modeset_helper.c index 57a319e3f780..1aa5e3bcc8a1 100644

drivers/gpu/drm/drm_modeset_helper.c +1 -0
@@ -91,6 +91,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device
 *dev, }
 
 	fb->dev = dev;
+	fb->format = info;
 	fb->width = mode_cmd->width;
 	fb->height = mode_cmd->height;
 	for (i = 0; i < 4; i++) {
include/drm/drm_framebuffer.h +4 -0
index b3141a0e609b..741b3a994d1f 100644
@@ -122,6 +122,10 @@ struct drm_framebuffer {
 	 */
 	struct drm_mode_object base;
 	/**
+	 * @format: framebuffer format information
+	 */
+	const struct drm_format_info *format;
+	/**
 	 * @funcs: framebuffer vfunc table
 	 */
 	const struct drm_framebuffer_funcs *funcs;
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#27 lore raw

Re: [PATCH 19/32] drm: Store a pointer to drm_format_info under drm_framebuffer

Quoted 24 lines · Laurent Pinchart

Hi Ville,

Thank you for the patch.

Quoted 19 lines · On Thursday 17 Nov 2016 18:14:18 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

To avoid having to look up the format information struct every time, let's just store a pointer to it under drm_framebuffer.

---
 drivers/gpu/drm/drm_framebuffer.c    | 4 +++-
 drivers/gpu/drm/drm_modeset_helper.c | 1 +
 include/drm/drm_framebuffer.h        | 4 ++++
 3 files changed, 8 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_framebuffer.c index 527220c08f9b..47478678d609 100644

drivers/gpu/drm/drm_framebuffer.c +0 -0
@@ -632,8 +632,10 @@ int drm_framebuffer_init(struct drm_device *dev, struct
 drm_framebuffer *fb, int ret;
 
Quoted 13 lines

drivers/gpu/drm/drm_framebuffer.c int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, · line 638

Quoted 6 lines
drivers/gpu/drm/drm_framebuffer.c +3 -1
 	INIT_LIST_HEAD(&fb->filp_head);
-	if (WARN_ON_ONCE(fb->dev != dev))
+	if (WARN_ON_ONCE(fb->dev != dev)) {
 		fb->dev = dev;
+		fb->format = drm_format_info(fb->pixel_format);
+	}

With this drivers will start relying on fb->format. I believe we should commit to provide a non-NULL format info to avoid having to sprinkle NULL checks in all drivers. Should drm_framebuffer_init() return an error in that case ? Or do we guarantee already through another mean that the pixel format is valid and will always lead to a non-NULL format info here ?

I think for normal cases we already reject the NULL format info. I am a little worried that I might have missed some special case where that might not hold. But I'm not sure what would be the best way to guard against it. I really don't want to sprinkle NULL checks everywhere, and in fact I didn't.

Quoted 37 lines
Quoted 32 lines
drivers/gpu/drm/drm_framebuffer.c +0 -0
 	fb->funcs = funcs;
 
 	ret = drm_mode_object_get_reg(dev, &fb->base, DRM_MODE_OBJECT_FB,
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_modeset_helper.c index 57a319e3f780..1aa5e3bcc8a1 100644

drivers/gpu/drm/drm_modeset_helper.c +1 -0
@@ -91,6 +91,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device
 *dev, }
 
 	fb->dev = dev;
+	fb->format = info;
 	fb->width = mode_cmd->width;
 	fb->height = mode_cmd->height;
 	for (i = 0; i < 4; i++) {
include/drm/drm_framebuffer.h +4 -0
index b3141a0e609b..741b3a994d1f 100644
@@ -122,6 +122,10 @@ struct drm_framebuffer {
 	 */
 	struct drm_mode_object base;
 	/**
+	 * @format: framebuffer format information
+	 */
+	const struct drm_format_info *format;
+	/**
 	 * @funcs: framebuffer vfunc table
 	 */
 	const struct drm_framebuffer_funcs *funcs;
Signature · 3 lines
Regards,

Laurent Pinchart
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#28 lore raw

Re: [PATCH 19/32] drm: Store a pointer to drm_format_info under drm_framebuffer

Quoted 39 lines · Ville Syrjälä
Quoted 24 lines · Laurent Pinchart

Hi Ville,

Thank you for the patch.

Quoted 19 lines · On Thursday 17 Nov 2016 18:14:18 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

To avoid having to look up the format information struct every time, let's just store a pointer to it under drm_framebuffer.

---
 drivers/gpu/drm/drm_framebuffer.c    | 4 +++-
 drivers/gpu/drm/drm_modeset_helper.c | 1 +
 include/drm/drm_framebuffer.h        | 4 ++++
 3 files changed, 8 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_framebuffer.c index 527220c08f9b..47478678d609 100644

drivers/gpu/drm/drm_framebuffer.c +0 -0
@@ -632,8 +632,10 @@ int drm_framebuffer_init(struct drm_device *dev, struct
 drm_framebuffer *fb, int ret;
 
Quoted 13 lines

drivers/gpu/drm/drm_framebuffer.c int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, · line 638

Quoted 6 lines
drivers/gpu/drm/drm_framebuffer.c +3 -1
 	INIT_LIST_HEAD(&fb->filp_head);
-	if (WARN_ON_ONCE(fb->dev != dev))
+	if (WARN_ON_ONCE(fb->dev != dev)) {
 		fb->dev = dev;
+		fb->format = drm_format_info(fb->pixel_format);
+	}

With this drivers will start relying on fb->format. I believe we should commit to provide a non-NULL format info to avoid having to sprinkle NULL checks in all drivers. Should drm_framebuffer_init() return an error in that case ? Or do we guarantee already through another mean that the pixel format is valid and will always lead to a non-NULL format info here ?

Quoted 5 lines

I think for normal cases we already reject the NULL format info. I am a little worried that I might have missed some special case where that might not hold. But I'm not sure what would be the best way to guard against it. I really don't want to sprinkle NULL checks everywhere, and in fact I didn't.

And by normal I mean the addfb/addfb2 ioctls. Those will go through framebuffer_check() which does:

info = __drm_format_info(...)

if (!info) {
	...
	return -EINVAL;
}

Well, you should know since you write the code ;)

So the more special cases of internally created fbs is where the danger lies I think.

I guess we could have drm_framebuffer_init() return a failure (also maybe in the fb->dev!=dev case?). That would at least protect all the uses after drm_framebuffer_init(). And I guess the uses before _init() are somewhat of a special case, and up to each driver to make sure that it knows what it's doing if it has uses like that.

Quoted 46 lines
Quoted 38 lines
Quoted 33 lines
drivers/gpu/drm/drm_framebuffer.c +0 -0
 	fb->funcs = funcs;
 
 	ret = drm_mode_object_get_reg(dev, &fb->base, DRM_MODE_OBJECT_FB,
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_modeset_helper.c index 57a319e3f780..1aa5e3bcc8a1 100644

drivers/gpu/drm/drm_modeset_helper.c +1 -0
@@ -91,6 +91,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device
 *dev, }
 
 	fb->dev = dev;
+	fb->format = info;
 	fb->width = mode_cmd->width;
 	fb->height = mode_cmd->height;
 	for (i = 0; i < 4; i++) {
include/drm/drm_framebuffer.h +4 -0
index b3141a0e609b..741b3a994d1f 100644
@@ -122,6 +122,10 @@ struct drm_framebuffer {
 	 */
 	struct drm_mode_object base;
 	/**
+	 * @format: framebuffer format information
+	 */
+	const struct drm_format_info *format;
+	/**
 	 * @funcs: framebuffer vfunc table
 	 */
 	const struct drm_framebuffer_funcs *funcs;
Signature · 3 lines
Regards,

Laurent Pinchart
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#29 lore raw

Re: [PATCH 19/32] drm: Store a pointer to drm_format_info under drm_framebuffer

Hi Ville,

Quoted 56 lines · On Thursday 17 Nov 2016 20:13:42 Ville Syrjälä wrote:
Quoted 38 lines · Ville Syrjälä
Quoted 24 lines · Laurent Pinchart
Quoted 23 lines · On Thursday 17 Nov 2016 18:14:18 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

To avoid having to look up the format information struct every time, let's just store a pointer to it under drm_framebuffer.

---

 drivers/gpu/drm/drm_framebuffer.c    | 4 +++-
 drivers/gpu/drm/drm_modeset_helper.c | 1 +
 include/drm/drm_framebuffer.h        | 4 ++++
 3 files changed, 8 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_framebuffer.c index 527220c08f9b..47478678d609 100644

drivers/gpu/drm/drm_framebuffer.c +0 -0
@@ -632,8 +632,10 @@ int drm_framebuffer_init(struct drm_device *dev,
 struct drm_framebuffer *fb, int ret;
 
 	INIT_LIST_HEAD(&fb->filp_head);
 
Quoted 12 lines

drivers/gpu/drm/drm_framebuffer.c int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, · line 638

Quoted 5 lines
drivers/gpu/drm/drm_framebuffer.c +3 -1
-	if (WARN_ON_ONCE(fb->dev != dev))
+	if (WARN_ON_ONCE(fb->dev != dev)) {
 		fb->dev = dev;
+		fb->format = drm_format_info(fb->pixel_format);
+	}

With this drivers will start relying on fb->format. I believe we should commit to provide a non-NULL format info to avoid having to sprinkle NULL checks in all drivers. Should drm_framebuffer_init() return an error in that case ? Or do we guarantee already through another mean that the pixel format is valid and will always lead to a non-NULL format info here ?

Quoted 5 lines

I think for normal cases we already reject the NULL format info. I am a little worried that I might have missed some special case where that might not hold. But I'm not sure what would be the best way to guard against it. I really don't want to sprinkle NULL checks everywhere, and in fact I didn't.

And by normal I mean the addfb/addfb2 ioctls. Those will go through framebuffer_check() which does:

info = __drm_format_info(...)

if (!info) {
	...
	return -EINVAL;
}

Well, you should know since you write the code ;)

Quoted 8 lines

So the more special cases of internally created fbs is where the danger lies I think.

I guess we could have drm_framebuffer_init() return a failure (also maybe in the fb->dev!=dev case?). That would at least protect all the uses after drm_framebuffer_init(). And I guess the uses before _init() are somewhat of a special case, and up to each driver to make sure that it knows what it's doing if it has uses like that.

That sounds good to me.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/drm_framebuffer.c +0 -0
 	fb->funcs = funcs;
 

ret = drm_mode_object_get_reg(dev, &fb->base, DRM_MODE_OBJECT_FB,

[snip]

Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#30 lore raw

PATCH 20/32 drm/vmwgfx: Populate fb->format correctly

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Populate the fb->format to point at the correct format information structure.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2 -0
index 5788913ca8f9..77f936e3056e 100644
@@ -589,6 +589,7 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
 
 	vfbs->base.base.dev = dev;
 	/* XXX get the first 4 from the surface info */
+	vfbs->base.base.format = drm_format_info(pixel_format);
 	vfbs->base.base.pixel_format = pixel_format;
 	vfbs->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbs->base.base.pitches[0] = mode_cmd->pitch;
@@ -897,6 +898,7 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
 	}
 
 	vfbd->base.base.dev = dev;
+	vfbd->base.base.format = drm_format_info(pixel_format);
 	vfbd->base.base.pixel_format = pixel_format;
 	vfbd->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbd->base.base.pitches[0] = mode_cmd->pitch;
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#31 lore raw

PATCH 21/32 drm/i915: Populate fb->format early for inherited fbs

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

MAke sure the framebuffer format info is available as early as possible for fbs we inherit from the BIOS. This will allow us to use the fb as if it was fully formed before we register it.

---
 drivers/gpu/drm/i915/intel_display.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/intel_display.c +3 -0
index 74a638c8de61..c45da6766fff 100644
@@ -8717,6 +8717,7 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
 	fourcc = i9xx_format_to_fourcc(pixel_format);
 	fb->pixel_format = fourcc;
 	fb->bits_per_pixel = drm_format_plane_cpp(fourcc, 0) * 8;
+	fb->format = drm_format_info(fourcc);
 
 	if (INTEL_GEN(dev_priv) >= 4) {
 		if (plane_config->tiling)
@@ -9748,6 +9749,7 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
 				      val & PLANE_CTL_ALPHA_MASK);
 	fb->pixel_format = fourcc;
 	fb->bits_per_pixel = drm_format_plane_cpp(fourcc, 0) * 8;
+	fb->format = drm_format_info(fourcc);
 
 	tiling = val & PLANE_CTL_TILED_MASK;
 	switch (tiling) {
@@ -9863,6 +9865,7 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
 	fourcc = i9xx_format_to_fourcc(pixel_format);
 	fb->pixel_format = fourcc;
 	fb->bits_per_pixel = drm_format_plane_cpp(fourcc, 0) * 8;
+	fb->format = drm_format_info(fourcc);
 
 	base = I915_READ(DSPSURF(pipe)) & 0xfffff000;
 	if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#32 lore raw

PATCH 22/32 drm/atomic: Replace drm_format_num_planes() with fb->format->num_planes

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Avoid the format info lookup and just use the pointer stored under drm_framebuffer.

---
 drivers/gpu/drm/drm_atomic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +1 -1
index 85466cc67819..cb6ab0106b0b 100644
@@ -960,7 +960,7 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,
 	drm_printf(p, "\tfb=%u\n", state->fb ? state->fb->base.id : 0);
 	if (state->fb) {
 		struct drm_framebuffer *fb = state->fb;
-		int i, n = drm_format_num_planes(fb->pixel_format);
+		int i, n = fb->format->num_planes;
 		struct drm_format_name_buf format_name;
 
 		drm_printf(p, "\t\tformat=%s\n",
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 22/32
#33 lore raw

Re: [PATCH 22/32] drm/atomic: Replace drm_format_num_planes() with fb->format->num_planes

Hi Ville,

Thank you for the patch.

Quoted 17 lines · On Thursday 17 Nov 2016 18:14:21 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Avoid the format info lookup and just use the pointer stored under drm_framebuffer.

---
 drivers/gpu/drm/drm_atomic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +0 -0
index 85466cc67819..cb6ab0106b0b 100644
@@ -960,7 +960,7 @@ static void drm_atomic_plane_print_state(struct

drm_printer *p, drm_printf(p, "\tfb=%u\n", state->fb ? state->fb->base.id :
0);

drivers/gpu/drm/drm_atomic.c static void drm_atomic_plane_print_state(struct drm_printer *p, · line 963

Quoted 4 lines
drivers/gpu/drm/drm_atomic.c +1 -1
 	if (state->fb) {
 		struct drm_framebuffer *fb = state->fb;
-		int i, n = drm_format_num_planes(fb->pixel_format);
+		int i, n = fb->format->num_planes;

Assuming you adress my concerns in patch 19/32,

Quoted 3 lines
drivers/gpu/drm/drm_atomic.c +0 -0
 		struct drm_format_name_buf format_name;
 
 		drm_printf(p, "\t\tformat=%s\n",
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#34 lore raw

PATCH 23/32 drm/fb_cma_helper: Replace drm_format_info() with fb->format

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Get the format information via the neat fb->format pointer rather than doing a linear search over all the format info structures.

---
 drivers/gpu/drm/drm_fb_cma_helper.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/drm_fb_cma_helper.c +1 -4
index 570f5c6063f3..0dc3f5bcbf48 100644
@@ -304,15 +304,12 @@ EXPORT_SYMBOL_GPL(drm_fb_cma_prepare_fb);
 static void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file *m)
 {
 	struct drm_fb_cma *fb_cma = to_fb_cma(fb);
-	const struct drm_format_info *info;
 	int i;
 
 	seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height,
 			(char *)&fb->pixel_format);
 
-	info = drm_format_info(fb->pixel_format);
-
-	for (i = 0; i < info->num_planes; i++) {
+	for (i = 0; i < fb->fomat->num_planes; i++) {
 		seq_printf(m, "   %d: offset=%d pitch=%d, obj: ",
 				i, fb->offsets[i], fb->pitches[i]);
 		drm_gem_cma_describe(fb_cma->obj[i], m);
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 23/32
#35 lore raw

Re: [PATCH 23/32] drm/fb_cma_helper: Replace drm_format_info() with fb->format

Hi Ville,

Thank you for the patch.

Quoted 6 lines · On Thursday 17 Nov 2016 18:14:22 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Get the format information via the neat fb->format pointer rather than doing a linear search over all the format info structures.

Quoted 26 lines
---
 drivers/gpu/drm/drm_fb_cma_helper.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_fb_cma_helper.c index 570f5c6063f3..0dc3f5bcbf48 100644

drivers/gpu/drm/drm_fb_cma_helper.c +1 -4
@@ -304,15 +304,12 @@ EXPORT_SYMBOL_GPL(drm_fb_cma_prepare_fb);
 static void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file
 *m) {
 	struct drm_fb_cma *fb_cma = to_fb_cma(fb);
-	const struct drm_format_info *info;
 	int i;
 
 	seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height,
 			(char *)&fb->pixel_format);
 
-	info = drm_format_info(fb->pixel_format);
-
-	for (i = 0; i < info->num_planes; i++) {
+	for (i = 0; i < fb->fomat->num_planes; i++) {
 		seq_printf(m, "   %d: offset=%d pitch=%d, obj: ",
 				i, fb->offsets[i], fb->pitches[i]);
 		drm_gem_cma_describe(fb_cma->obj[i], m);
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#36 lore raw

PATCH 24/32 drm/nouveau: Use fb->format rather than drm_format_info()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Let's use the pointer to the format information cached under drm_framebuffer rather than look it up manually.

---
 drivers/gpu/drm/nouveau/nv50_display.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/nouveau/nv50_display.c +5 -7
index a9855a4ec532..d3bd428023ea 100644
@@ -1418,12 +1418,10 @@ static int
 nv50_base_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
 		  struct nv50_head_atom *asyh)
 {
-	const u32 format = asyw->state.fb->pixel_format;
-	const struct drm_format_info *info;
+	const struct drm_framebuffer *fb = asyw->state.fb;
 	int ret;
 
-	info = drm_format_info(format);
-	if (!info || !info->depth)
+	if (!fb->format->depth)
 		return -EINVAL;
 
 	ret = drm_plane_helper_check_state(&asyw->state, &asyw->clip,
@@ -1433,14 +1431,14 @@ nv50_base_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
 	if (ret)
 		return ret;
 
-	asyh->base.depth = info->depth;
-	asyh->base.cpp = info->cpp[0];
+	asyh->base.depth = fb->format->depth;
+	asyh->base.cpp = fb->format->cpp[0];
 	asyh->base.x = asyw->state.src.x1 >> 16;
 	asyh->base.y = asyw->state.src.y1 >> 16;
 	asyh->base.w = asyw->state.fb->width;
 	asyh->base.h = asyw->state.fb->height;
 
-	switch (format) {
+	switch (fb->pixel_format) {
 	case DRM_FORMAT_C8         : asyw->image.format = 0x1e; break;
 	case DRM_FORMAT_RGB565     : asyw->image.format = 0xe8; break;
 	case DRM_FORMAT_XRGB1555   :
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#37 lore raw

PATCH 25/32 drm/i915: Store a pointer to the pixel format info for fbc

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Rather than store the pixel format and look up the format info as needed, let's just store a pointer to the format info directly and speed up our lookups.

---
 drivers/gpu/drm/i915/i915_drv.h  |  4 ++--
 drivers/gpu/drm/i915/intel_fbc.c | 14 +++++++-------
 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -2
index be67aeece749..692b79e056be 100644
@@ -1026,7 +1026,7 @@ struct intel_fbc {
 
 		struct {
 			u64 ilk_ggtt_offset;
-			uint32_t pixel_format;
+			const struct drm_format_info *format;
 			unsigned int stride;
 			int fence_reg;
 			unsigned int tiling_mode;
@@ -1042,7 +1042,7 @@ struct intel_fbc {
 
 		struct {
 			u64 ggtt_offset;
-			uint32_t pixel_format;
+			const struct drm_format_info *format;
 			unsigned int stride;
 			int fence_reg;
 		} fb;
drivers/gpu/drm/i915/intel_fbc.c +7 -7
index 62f215b12eb5..659cebc3bfd2 100644
@@ -188,7 +188,7 @@ static void g4x_fbc_activate(struct drm_i915_private *dev_priv)
 	u32 dpfc_ctl;
 
 	dpfc_ctl = DPFC_CTL_PLANE(params->crtc.plane) | DPFC_SR_EN;
-	if (drm_format_plane_cpp(params->fb.pixel_format, 0) == 2)
+	if (params->fb.format->cpp[0] == 2)
 		dpfc_ctl |= DPFC_CTL_LIMIT_2X;
 	else
 		dpfc_ctl |= DPFC_CTL_LIMIT_1X;
@@ -235,7 +235,7 @@ static void ilk_fbc_activate(struct drm_i915_private *dev_priv)
 	int threshold = dev_priv->fbc.threshold;
 
 	dpfc_ctl = DPFC_CTL_PLANE(params->crtc.plane);
-	if (drm_format_plane_cpp(params->fb.pixel_format, 0) == 2)
+	if (params->fb.format->cpp[0] == 2)
 		threshold++;
 
 	switch (threshold) {
@@ -303,7 +303,7 @@ static void gen7_fbc_activate(struct drm_i915_private *dev_priv)
 	if (IS_IVYBRIDGE(dev_priv))
 		dpfc_ctl |= IVB_DPFC_CTL_PLANE(params->crtc.plane);
 
-	if (drm_format_plane_cpp(params->fb.pixel_format, 0) == 2)
+	if (params->fb.format->cpp[0] == 2)
 		threshold++;
 
 	switch (threshold) {
@@ -581,7 +581,7 @@ static int intel_fbc_alloc_cfb(struct intel_crtc *crtc)
 	WARN_ON(drm_mm_node_allocated(&fbc->compressed_fb));
 
 	size = intel_fbc_calculate_cfb_size(dev_priv, &fbc->state_cache);
-	fb_cpp = drm_format_plane_cpp(fbc->state_cache.fb.pixel_format, 0);
+	fb_cpp = fbc->state_cache.fb.format->cpp[0];
 
 	ret = find_compression_threshold(dev_priv, &fbc->compressed_fb,
 					 size, fb_cpp);
@@ -764,7 +764,7 @@ static void intel_fbc_update_state_cache(struct intel_crtc *crtc,
 	 * platforms that need. */
 	if (IS_GEN(dev_priv, 5, 6))
 		cache->fb.ilk_ggtt_offset = i915_gem_object_ggtt_offset(obj, NULL);
-	cache->fb.pixel_format = fb->pixel_format;
+	cache->fb.format = fb->format;
 	cache->fb.stride = fb->pitches[0];
 	cache->fb.fence_reg = get_fence_id(fb);
 	cache->fb.tiling_mode = i915_gem_object_get_tiling(obj);
@@ -823,7 +823,7 @@ static bool intel_fbc_can_activate(struct intel_crtc *crtc)
 		return false;
 	}
 
-	if (!pixel_format_is_valid(dev_priv, cache->fb.pixel_format)) {
+	if (!pixel_format_is_valid(dev_priv, cache->fb.format->format)) {
 		fbc->no_fbc_reason = "pixel format is invalid";
 		return false;
 	}
@@ -892,7 +892,7 @@ static void intel_fbc_get_reg_params(struct intel_crtc *crtc,
 	params->crtc.plane = crtc->plane;
 	params->crtc.fence_y_offset = get_crtc_fence_y_offset(crtc);
 
-	params->fb.pixel_format = cache->fb.pixel_format;
+	params->fb.format = cache->fb.format;
 	params->fb.stride = cache->fb.stride;
 	params->fb.fence_reg = cache->fb.fence_reg;
 
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#38 lore raw

PATCH 26/32 drm/i915: Replace drm_format_plane_cpp() with fb->format->cpp[]

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Avoid the fb format information lookups when we already have the fb->format pointer at hand.

@@
struct drm_framebuffer *fb;
expression E;
@@
- drm_format_plane_cpp(fb->pixel_format, E)
+ fb->format->cpp[E]

@@
struct drm_framebuffer fb;
expression E;
@@
- drm_format_plane_cpp(fb.pixel_format, E)
+ fb.format->cpp[E]

@@
struct intel_plane_state *state;
expression E;
@@
- drm_format_plane_cpp(state->base.fb->pixel_format, E)
+ state->base.fb->format->cpp[E]

@@
struct drm_framebuffer *fb;
expression E1, E2;
@@
unsigned format = fb ? fb->pixel_format : E1;
<+...
- drm_format_plane_cpp(format, E2)
+ fb->format->cpp[E2]
...+>

@@
struct drm_framebuffer *fb;
expression E;
@@
uint32_t format = fb->pixel_format;
<+...
- drm_format_plane_cpp(format, E)
+ fb->format->cpp[E]
...+>

---
 drivers/gpu/drm/i915/intel_display.c | 16 +++++++-------
 drivers/gpu/drm/i915/intel_pm.c      | 42 ++++++++++++++++++------------------
 drivers/gpu/drm/i915/intel_sprite.c  |  2 +-
 3 files changed, 30 insertions(+), 30 deletions(-)
drivers/gpu/drm/i915/intel_display.c +8 -8
index c45da6766fff..6565e5cd0ada 100644
@@ -2275,7 +2275,7 @@ u32 intel_fb_xy_to_linear(int x, int y,
 			  int plane)
 {
 	const struct drm_framebuffer *fb = state->base.fb;
-	unsigned int cpp = drm_format_plane_cpp(fb->pixel_format, plane);
+	unsigned int cpp = fb->format->cpp[plane];
 	unsigned int pitch = fb->pitches[plane];
 
 	return y * pitch + x * cpp;
@@ -2344,7 +2344,7 @@ static u32 intel_adjust_tile_offset(int *x, int *y,
 {
 	const struct drm_i915_private *dev_priv = to_i915(state->base.plane->dev);
 	const struct drm_framebuffer *fb = state->base.fb;
-	unsigned int cpp = drm_format_plane_cpp(fb->pixel_format, plane);
+	unsigned int cpp = fb->format->cpp[plane];
 	unsigned int rotation = state->base.rotation;
 	unsigned int pitch = intel_fb_pitch(fb, plane, rotation);
 
@@ -2400,7 +2400,7 @@ static u32 _intel_compute_tile_offset(const struct drm_i915_private *dev_priv,
 				      u32 alignment)
 {
 	uint64_t fb_modifier = fb->modifier;
-	unsigned int cpp = drm_format_plane_cpp(fb->pixel_format, plane);
+	unsigned int cpp = fb->format->cpp[plane];
 	u32 offset, offset_aligned;
 
 	if (alignment)
@@ -2468,7 +2468,7 @@ u32 intel_compute_tile_offset(int *x, int *y,
 static void intel_fb_offset_to_xy(int *x, int *y,
 				  const struct drm_framebuffer *fb, int plane)
 {
-	unsigned int cpp = drm_format_plane_cpp(fb->pixel_format, plane);
+	unsigned int cpp = fb->format->cpp[plane];
 	unsigned int pitch = fb->pitches[plane];
 	u32 linear_offset = fb->offsets[plane];
 
@@ -2506,7 +2506,7 @@ intel_fill_fb_info(struct drm_i915_private *dev_priv,
 		u32 offset;
 		int x, y;
 
-		cpp = drm_format_plane_cpp(format, i);
+		cpp = fb->format->cpp[i];
 		width = drm_format_plane_width(fb->width, format, i);
 		height = drm_format_plane_height(fb->height, format, i);
 
@@ -2833,7 +2833,7 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc,
 static int skl_max_plane_width(const struct drm_framebuffer *fb, int plane,
 			       unsigned int rotation)
 {
-	int cpp = drm_format_plane_cpp(fb->pixel_format, plane);
+	int cpp = fb->format->cpp[plane];
 
 	switch (fb->modifier) {
 	case DRM_FORMAT_MOD_NONE:
@@ -2912,7 +2912,7 @@ static int skl_check_main_surface(struct intel_plane_state *plane_state)
 	 * TODO: linear and Y-tiled seem fine, Yf untested,
 	 */
 	if (fb->modifier == I915_FORMAT_MOD_X_TILED) {
-		int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+		int cpp = fb->format->cpp[0];
 
 		while ((x + w) * cpp > fb->pitches[0]) {
 			if (offset == 0) {
@@ -3278,7 +3278,7 @@ u32 skl_plane_stride(const struct drm_framebuffer *fb, int plane,
 	 * linear buffers or in number of tiles for tiled buffers.
 	 */
 	if (drm_rotation_90_or_270(rotation)) {
-		int cpp = drm_format_plane_cpp(fb->pixel_format, plane);
+		int cpp = fb->format->cpp[plane];
 
 		stride /= intel_tile_height(dev_priv, fb->modifier, cpp);
 	} else {
drivers/gpu/drm/i915/intel_pm.c +21 -21

147 lines not on this page · raw message

drivers/gpu/drm/i915/intel_sprite.c +1 -1
index 8f131a08d440..b46c1794d3ac 100644
@@ -885,7 +885,7 @@ intel_check_sprite_plane(struct drm_plane *plane,
 	/* Check size restrictions when scaling */
 	if (state->base.visible && (src_w != crtc_w || src_h != crtc_h)) {
 		unsigned int width_bytes;
-		int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+		int cpp = fb->format->cpp[0];
 
 		WARN_ON(!can_scale);
 
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#39 lore raw

PATCH 27/32 drm/i915: Replace drm_format_num_planes() with fb->format->num_planes

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

No need to look up the format info to get the number of planes, just use fb->format->num_planes directly.

---
 drivers/gpu/drm/i915/intel_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
index 6565e5cd0ada..8f63fd38deee 100644
@@ -2497,7 +2497,7 @@ intel_fill_fb_info(struct drm_i915_private *dev_priv,
 	u32 gtt_offset_rotated = 0;
 	unsigned int max_size = 0;
 	uint32_t format = fb->pixel_format;
-	int i, num_planes = drm_format_num_planes(format);
+	int i, num_planes = fb->format->num_planes;
 	unsigned int tile_size = intel_tile_size(dev_priv);
 
 	for (i = 0; i < num_planes; i++) {
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#40 lore raw

PATCH 28/32 drm: Add drm_framebuffer_plane_{width,height}()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Add variants of drm_format_plane_{width,height}() that take an entire fb object instead of just the format. These should be more efficent as they can just look up the format info from the fb->format pointer rather than having to look it up (using a linear search based on the format).

---
 drivers/gpu/drm/drm_framebuffer.c | 44 +++++++++++++++++++++++++++++++++++++++
 include/drm/drm_framebuffer.h     |  6 ++++++
 2 files changed, 50 insertions(+)
drivers/gpu/drm/drm_framebuffer.c +44 -0
index 47478678d609..28d697ae1faf 100644
@@ -793,3 +793,47 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
 	drm_framebuffer_unreference(fb);
 }
 EXPORT_SYMBOL(drm_framebuffer_remove);
+
+/**
+ * drm_framebuffer_plane_width - width of the plane given the first plane
+ * @width: width of the first plane
+ * @fb: the framebuffer
+ * @plane: plane index
+ *
+ * Returns:
+ * The width of @plane, given that the width of the first plane is @width.
+ */
+int drm_framebuffer_plane_width(int width,
+				const struct drm_framebuffer *fb, int plane)
+{
+	if (plane >= fb->format->num_planes)
+		return 0;
+
+	if (plane == 0)
+		return width;
+
+	return width / fb->format->hsub;
+}
+EXPORT_SYMBOL(drm_framebuffer_plane_width);
+
+/**
+ * drm_framebuffer_plane_height - height of the plane given the first plane
+ * @height: height of the first plane
+ * @fb: the framebuffer
+ * @plane: plane index
+ *
+ * Returns:
+ * The height of @plane, given that the height of the first plane is @height.
+ */
+int drm_framebuffer_plane_height(int height,
+				 const struct drm_framebuffer *fb, int plane)
+{
+	if (plane >= fb->format->num_planes)
+		return 0;
+
+	if (plane == 0)
+		return height;
+
+	return height / fb->format->vsub;
+}
+EXPORT_SYMBOL(drm_framebuffer_plane_height);
include/drm/drm_framebuffer.h +6 -0
index 741b3a994d1f..cdcfb86b3f74 100644
@@ -268,4 +268,10 @@ static inline uint32_t drm_framebuffer_read_refcount(struct drm_framebuffer *fb)
 					  struct drm_framebuffer, head);	\
 	     &fb->head != (&(dev)->mode_config.fb_list);			\
 	     fb = list_next_entry(fb, head))
+
+int drm_framebuffer_plane_width(int width,
+				const struct drm_framebuffer *fb, int plane);
+int drm_framebuffer_plane_height(int height,
+				 const struct drm_framebuffer *fb, int plane);
+
 #endif
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#41 lore raw

PATCH 29/32 drm/i915: Use drm_framebuffer_plane_{width, height}() where possible

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Replace drm_format_plane_{width,height}() usage with drm_framebuffer_plane_{width,height}() to avoid the lookup of the format info.

---
 drivers/gpu/drm/i915/intel_display.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +2 -3
index 8f63fd38deee..5d8db436c557 100644
@@ -2496,7 +2496,6 @@ intel_fill_fb_info(struct drm_i915_private *dev_priv,
 	struct intel_rotation_info *rot_info = &intel_fb->rot_info;
 	u32 gtt_offset_rotated = 0;
 	unsigned int max_size = 0;
-	uint32_t format = fb->pixel_format;
 	int i, num_planes = fb->format->num_planes;
 	unsigned int tile_size = intel_tile_size(dev_priv);
 
@@ -2507,8 +2506,8 @@ intel_fill_fb_info(struct drm_i915_private *dev_priv,
 		int x, y;
 
 		cpp = fb->format->cpp[i];
-		width = drm_format_plane_width(fb->width, format, i);
-		height = drm_format_plane_height(fb->height, format, i);
+		width = drm_framebuffer_plane_width(fb->width, fb, i);
+		height = drm_framebuffer_plane_height(fb->height, fb, i);
 
 		intel_fb_offset_to_xy(&x, &y, fb, i);
 
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#42 lore raw

PATCH 30/32 drm: Nuke fb->depth

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Replace uses of fb->depth with fb->format->depth. Less duplicate information is a good thing.

@@
struct drm_framebuffer *fb;
expression E1, E2;
@@

 drm_helper_mode_fill_fb_struct(...) {
	...
-	fb->depth = E1;
	...

}

@@
struct vmw_framebuffer_surface *vfb;
expression E;
@@
- vfb->base.base.depth = E;

@@
struct vmw_framebuffer_dmabuf *vfb;
expression E;
@@
- vfb->base.base.depth = E;

@@
struct nouveau_framebuffer *fb;
@@
- fb->base.depth
+ fb->base.format->depth

@@
struct drm_framebuffer fb;
expression E;
@@
- fb.depth
+ fb.format->depth

@@
struct drm_framebuffer *fb;
expression E;
@@
- fb->depth
+ fb->format->depth

@@
struct drm_framebuffer fb;
@@
- (fb.format->depth)
+ fb.format->depth

@@
struct drm_framebuffer *fb;
@@
- (fb->format->depth)
+ fb->format->depth

@@
@@

 struct drm_framebuffer {
	 ...
-	 unsigned int depth;
	 ...

};

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c        |  4 ++--
 drivers/gpu/drm/armada/armada_fbdev.c         |  3 ++-
 drivers/gpu/drm/ast/ast_fb.c                  |  2 +-
 drivers/gpu/drm/bochs/bochs_fbdev.c           |  2 +-
 drivers/gpu/drm/cirrus/cirrus_fbdev.c         |  4 ++--
 drivers/gpu/drm/drm_fb_cma_helper.c           |  2 +-
 drivers/gpu/drm/drm_fb_helper.c               |  2 +-
 drivers/gpu/drm/drm_framebuffer.c             |  2 +-
 drivers/gpu/drm/drm_modeset_helper.c          |  2 --
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c     |  2 +-
 drivers/gpu/drm/gma500/accel_2d.c             |  2 +-
 drivers/gpu/drm/gma500/framebuffer.c          |  2 +-
 drivers/gpu/drm/gma500/gma_display.c          |  2 +-
 drivers/gpu/drm/gma500/mdfld_intel_display.c  |  2 +-
 drivers/gpu/drm/gma500/oaktrail_crtc.c        |  2 +-
 drivers/gpu/drm/i915/i915_debugfs.c           |  4 ++--
 drivers/gpu/drm/i915/intel_fbdev.c            |  2 +-
 drivers/gpu/drm/mgag200/mgag200_fb.c          |  2 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c        |  6 +++---
 drivers/gpu/drm/msm/msm_fbdev.c               |  2 +-
 drivers/gpu/drm/nouveau/dispnv04/crtc.c       | 12 ++++++------
 drivers/gpu/drm/nouveau/dispnv04/dfp.c        |  2 +-
 drivers/gpu/drm/nouveau/nouveau_fbcon.c       |  3 ++-
 drivers/gpu/drm/omapdrm/omap_fbdev.c          |  2 +-
 drivers/gpu/drm/qxl/qxl_fb.c                  |  5 +++--
 drivers/gpu/drm/radeon/radeon_fb.c            |  4 ++--
 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  5 +++--
 drivers/gpu/drm/tegra/drm.c                   |  3 ++-
 drivers/gpu/drm/tegra/fb.c                    |  2 +-
 drivers/gpu/drm/udl/udl_fb.c                  |  2 +-
 drivers/gpu/drm/virtio/virtgpu_fb.c           |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c            |  7 ++++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c           |  2 --
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c           |  5 +++--
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c          |  2 +-
 include/drm/drm_framebuffer.h                 |  6 ------
 36 files changed, 56 insertions(+), 59 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +2 -2
index f1c9e59a7c87..f24c91b699a9 100644
@@ -245,7 +245,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
 
 	strcpy(info->fix.id, "amdgpudrmfb");
 
-	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
 
 	info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
 	info->fbops = &amdgpufb_ops;
@@ -272,7 +272,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
 	DRM_INFO("fb mappable at 0x%lX\n",  info->fix.smem_start);
 	DRM_INFO("vram apper at 0x%lX\n",  (unsigned long)adev->mc.aper_base);
 	DRM_INFO("size %lu\n", (unsigned long)amdgpu_bo_size(abo));
-	DRM_INFO("fb depth is %d\n", fb->depth);
+	DRM_INFO("fb depth is %d\n", fb->format->depth);
 	DRM_INFO("   pitch is %d\n", fb->pitches[0]);
 
 	vga_switcheroo_client_fb_set(adev->ddev->pdev, info);
drivers/gpu/drm/armada/armada_fbdev.c +2 -1
index c5dc06a55883..3a58fb600b05 100644
@@ -89,7 +89,8 @@ static int armada_fb_create(struct drm_fb_helper *fbh,
 	info->screen_base = ptr;
 	fbh->fb = &dfb->fb;
 
-	drm_fb_helper_fill_fix(info, dfb->fb.pitches[0], dfb->fb.depth);
+	drm_fb_helper_fill_fix(info, dfb->fb.pitches[0],
+			       dfb->fb.format->depth);
 	drm_fb_helper_fill_var(info, fbh, sizes->fb_width, sizes->fb_height);
 
 	DRM_DEBUG_KMS("allocated %dx%d %dbpp fb: 0x%08llx\n",
drivers/gpu/drm/ast/ast_fb.c +1 -1
index d6f5ec64c667..f751792a3c7c 100644
@@ -237,7 +237,7 @@ static int astfb_create(struct drm_fb_helper *helper,
 	info->apertures->ranges[0].base = pci_resource_start(dev->pdev, 0);
 	info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 0);
 
-	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(info, &afbdev->helper, sizes->fb_width, sizes->fb_height);
 
 	info->screen_base = sysram;
drivers/gpu/drm/bochs/bochs_fbdev.c +1 -1
index da790a1c302a..0317c3df6a22 100644
@@ -123,7 +123,7 @@ static int bochsfb_create(struct drm_fb_helper *helper,
 	info->flags = FBINFO_DEFAULT;
 	info->fbops = &bochsfb_ops;
 
-	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(info, &bochs->fb.helper, sizes->fb_width,
 			       sizes->fb_height);
 
drivers/gpu/drm/cirrus/cirrus_fbdev.c +2 -2
index 3a6309d7d8e4..3cac8a03cf4f 100644
@@ -218,7 +218,7 @@ static int cirrusfb_create(struct drm_fb_helper *helper,
 	info->flags = FBINFO_DEFAULT;
 	info->fbops = &cirrusfb_ops;
 
-	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(info, &gfbdev->helper, sizes->fb_width,
 			       sizes->fb_height);
 
@@ -238,7 +238,7 @@ static int cirrusfb_create(struct drm_fb_helper *helper,
 	DRM_INFO("fb mappable at 0x%lX\n", info->fix.smem_start);
 	DRM_INFO("vram aper at 0x%lX\n", (unsigned long)info->fix.smem_start);
 	DRM_INFO("size %lu\n", (unsigned long)info->fix.smem_len);
-	DRM_INFO("fb depth is %d\n", fb->depth);
+	DRM_INFO("fb depth is %d\n", fb->format->depth);
 	DRM_INFO("   pitch is %d\n", fb->pitches[0]);
 
 	return 0;
drivers/gpu/drm/drm_fb_cma_helper.c +1 -1
index 0dc3f5bcbf48..181a9eafe34a 100644
@@ -464,7 +464,7 @@ int drm_fbdev_cma_create_with_funcs(struct drm_fb_helper *helper,
 	fbi->flags = FBINFO_FLAG_DEFAULT;
 	fbi->fbops = &drm_fbdev_cma_ops;
 
-	drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
 
 	offset = fbi->var.xoffset * bytes_per_pixel;
drivers/gpu/drm/drm_fb_helper.c +1 -1
index 14547817566d..755e3b6e9710 100644
@@ -1663,7 +1663,7 @@ void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helpe
 	info->var.height = -1;
 	info->var.width = -1;
 
-	switch (fb->depth) {
+	switch (fb->format->depth) {
 	case 8:
 		info->var.red.offset = 0;
 		info->var.green.offset = 0;
drivers/gpu/drm/drm_framebuffer.c +1 -1
index 28d697ae1faf..00def930b6a5 100644
@@ -432,7 +432,7 @@ int drm_mode_getfb(struct drm_device *dev,
 
 	r->height = fb->height;
 	r->width = fb->width;
-	r->depth = fb->depth;
+	r->depth = fb->format->depth;
 	r->bpp = fb->bits_per_pixel;
 	r->pitch = fb->pitches[0];
 	if (fb->funcs->create_handle) {
drivers/gpu/drm/drm_modeset_helper.c +0 -2
index 1aa5e3bcc8a1..e5d19e5fc341 100644
@@ -83,10 +83,8 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
 		              drm_get_format_name(mode_cmd->pixel_format,
 		                                  &format_name));
 
-		fb->depth = 0;
 		fb->bits_per_pixel = 0;
 	} else {
-		fb->depth = info->depth;
 		fb->bits_per_pixel = info->cpp[0] * 8;
 	}
 
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +1 -1
index 9f35deb56170..e68a46f112f6 100644
@@ -90,7 +90,7 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
 	fbi->flags = FBINFO_FLAG_DEFAULT;
 	fbi->fbops = &exynos_drm_fb_ops;
 
-	drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
 
 	nr_pages = exynos_gem->size >> PAGE_SHIFT;
drivers/gpu/drm/gma500/accel_2d.c +1 -1
index 0d2bb1682508..c51d9259c7a7 100644
@@ -254,7 +254,7 @@ static void psbfb_copyarea_accel(struct fb_info *info,
 	offset = psbfb->gtt->offset;
 	stride = fb->pitches[0];
 
-	switch (fb->depth) {
+	switch (fb->format->depth) {
 	case 8:
 		src_format = PSB_2D_SRC_332RGB;
 		dst_format = PSB_2D_DST_332RGB;
drivers/gpu/drm/gma500/framebuffer.c +1 -1
index 6d89ed760941..a93b59ce6b41 100644
@@ -407,7 +407,7 @@ static int psbfb_create(struct psb_fbdev *fbdev,
 
 	fbdev->psb_fb_helper.fb = fb;
 
-	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
 	strcpy(info->fix.id, "psbdrmfb");
 
 	info->flags = FBINFO_DEFAULT;
drivers/gpu/drm/gma500/gma_display.c +1 -1
index 05b9a4ceb58d..5b852ad152ae 100644
@@ -94,7 +94,7 @@ int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 		dspcntr |= DISPPLANE_8BPP;
 		break;
 	case 16:
-		if (fb->depth == 15)
+		if (fb->format->depth == 15)
 			dspcntr |= DISPPLANE_15_16BPP;
 		else
 			dspcntr |= DISPPLANE_16BPP;
drivers/gpu/drm/gma500/mdfld_intel_display.c +1 -1
index e80895285e94..3be3111825cd 100644
@@ -208,7 +208,7 @@ static int mdfld__intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 		dspcntr |= DISPPLANE_8BPP;
 		break;
 	case 16:
-		if (fb->depth == 15)
+		if (fb->format->depth == 15)
 			dspcntr |= DISPPLANE_15_16BPP;
 		else
 			dspcntr |= DISPPLANE_16BPP;
drivers/gpu/drm/gma500/oaktrail_crtc.c +1 -1
index a51896544d91..569810d47786 100644
@@ -630,7 +630,7 @@ static int oaktrail_pipe_set_base(struct drm_crtc *crtc,
 		dspcntr |= DISPPLANE_8BPP;
 		break;
 	case 16:
-		if (fb->depth == 15)
+		if (fb->format->depth == 15)
 			dspcntr |= DISPPLANE_15_16BPP;
 		else
 			dspcntr |= DISPPLANE_16BPP;
drivers/gpu/drm/i915/i915_debugfs.c +2 -2
index b7f42c448a44..ebcba97616ab 100644
@@ -1894,7 +1894,7 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
 		seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
 			   fbdev_fb->base.width,
 			   fbdev_fb->base.height,
-			   fbdev_fb->base.depth,
+			   fbdev_fb->base.format->depth,
 			   fbdev_fb->base.bits_per_pixel,
 			   fbdev_fb->base.modifier,
 			   drm_framebuffer_read_refcount(&fbdev_fb->base));
@@ -1912,7 +1912,7 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
 		seq_printf(m, "user size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
 			   fb->base.width,
 			   fb->base.height,
-			   fb->base.depth,
+			   fb->base.format->depth,
 			   fb->base.bits_per_pixel,
 			   fb->base.modifier,
 			   drm_framebuffer_read_refcount(&fb->base));
drivers/gpu/drm/i915/intel_fbdev.c +1 -1
index beb08982dc0b..b726483a460d 100644
@@ -261,7 +261,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
 	/* This driver doesn't need a VT switch to restore the mode on resume */
 	info->skip_vt_switch = true;
 
-	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(info, &ifbdev->helper, sizes->fb_width, sizes->fb_height);
 
 	/* If the object is shmemfs backed, it will have given us zeroed pages.
drivers/gpu/drm/mgag200/mgag200_fb.c +1 -1
index 88dd2214114d..19a78b6b5a1a 100644
@@ -217,7 +217,7 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
 	info->apertures->ranges[0].base = mdev->dev->mode_config.fb_base;
 	info->apertures->ranges[0].size = mdev->mc.vram_size;
 
-	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(info, &mfbdev->helper, sizes->fb_width,
 			       sizes->fb_height);
 
drivers/gpu/drm/mgag200/mgag200_mode.c +3 -3
index bdac288ab16d..3180db5e81cb 100644
@@ -39,10 +39,10 @@ static void mga_crtc_load_lut(struct drm_crtc *crtc)
 	WREG8(DAC_INDEX + MGA1064_INDEX, 0);
 
 	if (fb && fb->bits_per_pixel == 16) {
-		int inc = (fb->depth == 15) ? 8 : 4;
+		int inc = (fb->format->depth == 15) ? 8 : 4;
 		u8 r, b;
 		for (i = 0; i < MGAG200_LUT_SIZE; i += inc) {
-			if (fb->depth == 16) {
+			if (fb->format->depth == 16) {
 				if (i > (MGAG200_LUT_SIZE >> 1)) {
 					r = b = 0;
 				} else {
@@ -947,7 +947,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 		dacvalue[MGA1064_MUL_CTL] = MGA1064_MUL_CTL_8bits;
 		break;
 	case 16:
-		if (fb->depth == 15)
+		if (fb->format->depth == 15)
 			dacvalue[MGA1064_MUL_CTL] = MGA1064_MUL_CTL_15bits;
 		else
 			dacvalue[MGA1064_MUL_CTL] = MGA1064_MUL_CTL_16bits;
drivers/gpu/drm/msm/msm_fbdev.c +1 -1
index d29f5e82a410..3af969d8e8db 100644
@@ -148,7 +148,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
 
 	strcpy(fbi->fix.id, "msm");
 
-	drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
 
 	dev->mode_config.fb_base = paddr;
drivers/gpu/drm/nouveau/dispnv04/crtc.c +6 -6
index 8286b8ffe109..480e3ab477fd 100644
@@ -570,7 +570,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
 		regp->CRTC[NV_CIO_CRE_86] = 0x1;
 	}
 
-	regp->CRTC[NV_CIO_CRE_PIXEL_INDEX] = (fb->depth + 1) / 8;
+	regp->CRTC[NV_CIO_CRE_PIXEL_INDEX] = (fb->format->depth + 1) / 8;
 	/* Enable slaved mode (called MODE_TV in nv4ref.h) */
 	if (lvds_output || tmds_output || tv_output)
 		regp->CRTC[NV_CIO_CRE_PIXEL_INDEX] |= (1 << 7);
@@ -584,7 +584,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
 	regp->ramdac_gen_ctrl = NV_PRAMDAC_GENERAL_CONTROL_BPC_8BITS |
 				NV_PRAMDAC_GENERAL_CONTROL_VGA_STATE_SEL |
 				NV_PRAMDAC_GENERAL_CONTROL_PIXMIX_ON;
-	if (fb->depth == 16)
+	if (fb->format->depth == 16)
 		regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_ALT_MODE_SEL;
 	if (drm->device.info.chipset >= 0x11)
 		regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_PIPE_LONG;
@@ -848,16 +848,16 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc,
 
 	nv_crtc->fb.offset = fb->nvbo->bo.offset;
 
-	if (nv_crtc->lut.depth != drm_fb->depth) {
-		nv_crtc->lut.depth = drm_fb->depth;
+	if (nv_crtc->lut.depth != drm_fb->format->depth) {
+		nv_crtc->lut.depth = drm_fb->format->depth;
 		nv_crtc_gamma_load(crtc);
 	}
 
 	/* Update the framebuffer format. */
 	regp->CRTC[NV_CIO_CRE_PIXEL_INDEX] &= ~3;
-	regp->CRTC[NV_CIO_CRE_PIXEL_INDEX] |= (drm_fb->depth + 1) / 8;
+	regp->CRTC[NV_CIO_CRE_PIXEL_INDEX] |= (drm_fb->format->depth + 1) / 8;
 	regp->ramdac_gen_ctrl &= ~NV_PRAMDAC_GENERAL_CONTROL_ALT_MODE_SEL;
-	if (drm_fb->depth == 16)
+	if (drm_fb->format->depth == 16)
 		regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_ALT_MODE_SEL;
 	crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_PIXEL_INDEX);
 	NVWriteRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_GENERAL_CONTROL,
drivers/gpu/drm/nouveau/dispnv04/dfp.c +1 -1
index 945607b3cd41..2e5bb2afda7c 100644
@@ -416,7 +416,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder,
 	/* Output property. */
 	if ((nv_connector->dithering_mode == DITHERING_MODE_ON) ||
 	    (nv_connector->dithering_mode == DITHERING_MODE_AUTO &&
-	     fb->depth > connector->display_info.bpc * 3)) {
+	     fb->format->depth > connector->display_info.bpc * 3)) {
 		if (drm->device.info.chipset == 0x11)
 			regp->dither = savep->dither | 0x00010000;
 		else {
drivers/gpu/drm/nouveau/nouveau_fbcon.c +2 -1
index 2f2a3dcd4ad7..5600f6c64497 100644
@@ -400,7 +400,8 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
 	info->screen_base = nvbo_kmap_obj_iovirtual(fb->nvbo);
 	info->screen_size = fb->nvbo->bo.mem.num_pages << PAGE_SHIFT;
 
-	drm_fb_helper_fill_fix(info, fb->base.pitches[0], fb->base.depth);
+	drm_fb_helper_fill_fix(info, fb->base.pitches[0],
+			       fb->base.format->depth);
 	drm_fb_helper_fill_var(info, &fbcon->helper, sizes->fb_width, sizes->fb_height);
 
 	/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
drivers/gpu/drm/omapdrm/omap_fbdev.c +1 -1
index 8d8ac173f55d..aed99a0fc44b 100644
@@ -190,7 +190,7 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
 
 	strcpy(fbi->fix.id, MODULE_NAME);
 
-	drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
 
 	dev->mode_config.fb_base = paddr;
drivers/gpu/drm/qxl/qxl_fb.c +3 -2
index 7e305d8a4146..e41b3322f433 100644
@@ -279,7 +279,7 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
 	qfbdev->shadow = shadow;
 	strcpy(info->fix.id, "qxldrmfb");
 
-	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
 
 	info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT;
 	info->fbops = &qxlfb_ops;
@@ -316,7 +316,8 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
 	qdev->fbdev_info = info;
 	qdev->fbdev_qfb = &qfbdev->qfb;
 	DRM_INFO("fb mappable at 0x%lX, size %lu\n",  info->fix.smem_start, (unsigned long)info->screen_size);
-	DRM_INFO("fb: depth %d, pitch %d, width %d, height %d\n", fb->depth, fb->pitches[0], fb->width, fb->height);
+	DRM_INFO("fb: depth %d, pitch %d, width %d, height %d\n",
+		 fb->format->depth, fb->pitches[0], fb->width, fb->height);
 	return 0;
 
 out_destroy_fbi:
drivers/gpu/drm/radeon/radeon_fb.c +2 -2
index 899b6a1644bd..6c10a83f3362 100644
@@ -263,7 +263,7 @@ static int radeonfb_create(struct drm_fb_helper *helper,
 
 	strcpy(info->fix.id, "radeondrmfb");
 
-	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
 
 	info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
 	info->fbops = &radeonfb_ops;
@@ -290,7 +290,7 @@ static int radeonfb_create(struct drm_fb_helper *helper,
 	DRM_INFO("fb mappable at 0x%lX\n",  info->fix.smem_start);
 	DRM_INFO("vram apper at 0x%lX\n",  (unsigned long)rdev->mc.aper_base);
 	DRM_INFO("size %lu\n", (unsigned long)radeon_bo_size(rbo));
-	DRM_INFO("fb depth is %d\n", fb->depth);
+	DRM_INFO("fb depth is %d\n", fb->format->depth);
 	DRM_INFO("   pitch is %d\n", fb->pitches[0]);
 
 	vga_switcheroo_client_fb_set(rdev->ddev->pdev, info);
drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c +3 -2
index 8f639c8597a5..52d1fdf9f9da 100644
@@ -94,7 +94,7 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper,
 	fbi->fbops = &rockchip_drm_fbdev_ops;
 
 	fb = helper->fb;
-	drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
 
 	offset = fbi->var.xoffset * bytes_per_pixel;
@@ -106,7 +106,8 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper,
 	fbi->fix.smem_len = rk_obj->base.size;
 
 	DRM_DEBUG_KMS("FB [%dx%d]-%d kvaddr=%p offset=%ld size=%zu\n",
-		      fb->width, fb->height, fb->depth, rk_obj->kvaddr,
+		      fb->width, fb->height, fb->format->depth,
+		      rk_obj->kvaddr,
 		      offset, size);
 
 	fbi->skip_vt_switch = true;
drivers/gpu/drm/tegra/drm.c +2 -1
index b8be3ee4d3b8..d2893f65341a 100644
@@ -875,7 +875,8 @@ static int tegra_debugfs_framebuffers(struct seq_file *s, void *data)
 
 	list_for_each_entry(fb, &drm->mode_config.fb_list, head) {
 		seq_printf(s, "%3d: user size: %d x %d, depth %d, %d bpp, refcount %d\n",
-			   fb->base.id, fb->width, fb->height, fb->depth,
+			   fb->base.id, fb->width, fb->height,
+			   fb->format->depth,
 			   fb->bits_per_pixel,
 			   drm_framebuffer_read_refcount(fb));
 	}
drivers/gpu/drm/tegra/fb.c +1 -1
index a0096493f51c..2a1bf92403b8 100644
@@ -246,7 +246,7 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
 	info->flags = FBINFO_FLAG_DEFAULT;
 	info->fbops = &tegra_fb_ops;
 
-	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(info, helper, fb->width, fb->height);
 
 	offset = info->var.xoffset * bytes_per_pixel +
drivers/gpu/drm/udl/udl_fb.c +1 -1
index fefd87f422ec..e21a3ed3ab2b 100644
@@ -395,7 +395,7 @@ static int udlfb_create(struct drm_fb_helper *helper,
 
 	info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
 	info->fbops = &udlfb_ops;
-	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(info, &ufbdev->helper, sizes->fb_width, sizes->fb_height);
 
 	DRM_DEBUG_KMS("allocated %dx%d vmal %p\n",
drivers/gpu/drm/virtio/virtgpu_fb.c +1 -1
index dd21f950e129..9d0da42cc420 100644
@@ -333,7 +333,7 @@ static int virtio_gpufb_create(struct drm_fb_helper *helper,
 
 	info->screen_base = obj->vmap;
 	info->screen_size = obj->gem_base.size;
-	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
+	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(info, &vfbdev->helper,
 			       sizes->fb_width, sizes->fb_height);
 
drivers/gpu/drm/vmwgfx/vmwgfx_fb.c +4 -3
index d2d93959b119..b6e4add09f44 100644
@@ -83,7 +83,7 @@ static int vmw_fb_setcolreg(unsigned regno, unsigned red, unsigned green,
 		return 1;
 	}
 
-	switch (par->set_fb->depth) {
+	switch (par->set_fb->format->depth) {
 	case 24:
 	case 32:
 		pal[regno] = ((red & 0xff00) << 8) |
@@ -91,7 +91,8 @@ static int vmw_fb_setcolreg(unsigned regno, unsigned red, unsigned green,
 			     ((blue  & 0xff00) >> 8);
 		break;
 	default:
-		DRM_ERROR("Bad depth %u, bpp %u.\n", par->set_fb->depth,
+		DRM_ERROR("Bad depth %u, bpp %u.\n",
+			  par->set_fb->format->depth,
 			  par->set_fb->bits_per_pixel);
 		return 1;
 	}
@@ -486,7 +487,7 @@ static int vmw_fb_kms_framebuffer(struct fb_info *info)
 	if (cur_fb && cur_fb->width == mode_cmd.width &&
 	    cur_fb->height == mode_cmd.height &&
 	    cur_fb->bits_per_pixel == mode_cmd.bpp &&
-	    cur_fb->depth == mode_cmd.depth &&
+	    cur_fb->format->depth == mode_cmd.depth &&
 	    cur_fb->pitches[0] == mode_cmd.pitch)
 		return 0;
 
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0 -2
index 77f936e3056e..2ce4743701f1 100644
@@ -593,7 +593,6 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
 	vfbs->base.base.pixel_format = pixel_format;
 	vfbs->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbs->base.base.pitches[0] = mode_cmd->pitch;
-	vfbs->base.base.depth = mode_cmd->depth;
 	vfbs->base.base.width = mode_cmd->width;
 	vfbs->base.base.height = mode_cmd->height;
 	vfbs->surface = vmw_surface_reference(surface);
@@ -902,7 +901,6 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
 	vfbd->base.base.pixel_format = pixel_format;
 	vfbd->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbd->base.base.pitches[0] = mode_cmd->pitch;
-	vfbd->base.base.depth = mode_cmd->depth;
 	vfbd->base.base.width = mode_cmd->width;
 	vfbd->base.base.height = mode_cmd->height;
 	vfbd->base.dmabuf = true;
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +3 -2
index 23ec673d5e16..a3a839a3d441 100644
@@ -97,7 +97,8 @@ static int vmw_ldu_commit_list(struct vmw_private *dev_priv)
 		fb = entry->base.crtc.primary->fb;
 
 		return vmw_kms_write_svga(dev_priv, w, h, fb->pitches[0],
-					  fb->bits_per_pixel, fb->depth);
+					  fb->bits_per_pixel,
+					  fb->format->depth);
 	}
 
 	if (!list_empty(&lds->active)) {
@@ -105,7 +106,7 @@ static int vmw_ldu_commit_list(struct vmw_private *dev_priv)
 		fb = entry->base.crtc.primary->fb;
 
 		vmw_kms_write_svga(dev_priv, fb->width, fb->height, fb->pitches[0],
-				   fb->bits_per_pixel, fb->depth);
+				   fb->bits_per_pixel, fb->format->depth);
 	}
 
 	/* Make sure we always show something. */
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +1 -1
index f42359084adc..38d7b8a2b78e 100644
@@ -598,7 +598,7 @@ static int do_dmabuf_define_gmrfb(struct vmw_private *dev_priv,
 	struct vmw_dma_buffer *buf =
 		container_of(framebuffer, struct vmw_framebuffer_dmabuf,
 			     base)->buffer;
-	int depth = framebuffer->base.depth;
+	int depth = framebuffer->base.format->depth;
 	struct {
 		uint32_t header;
 		SVGAFifoCmdDefineGMRFB body;
include/drm/drm_framebuffer.h +0 -6
index cdcfb86b3f74..9b9772998db6 100644
@@ -170,12 +170,6 @@ struct drm_framebuffer {
 	 */
 	unsigned int height;
 	/**
-	 * @depth: Depth in bits per pixel for RGB formats. 0 for everything
-	 * else. Legacy information derived from @pixel_format, it's suggested to use
-	 * the DRM FOURCC codes and helper functions directly instead.
-	 */
-	unsigned int depth;
-	/**
 	 * @bits_per_pixel: Storage used bits per pixel for RGB formats. 0 for
 	 * everything else. Legacy information derived from @pixel_format, it's
 	 * suggested to use the DRM FOURCC codes and helper functions directly
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 30/32
#43 lore raw

Re: [PATCH 30/32] drm: Nuke fb->depth

Hi Ville,

Thank you for the patch.

Quoted 67 lines · On Thursday 17 Nov 2016 18:14:29 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Replace uses of fb->depth with fb->format->depth. Less duplicate information is a good thing.

@@
struct drm_framebuffer *fb;
expression E1, E2;
@@

 drm_helper_mode_fill_fb_struct(...) {
	...
(quoted diff) +0 -1
-	fb->depth = E1;
...
 }

@@
struct vmw_framebuffer_surface *vfb;
expression E;
@@
- vfb->base.base.depth = E;

@@
struct vmw_framebuffer_dmabuf *vfb;
expression E;
@@
- vfb->base.base.depth = E;

@@
struct nouveau_framebuffer *fb;
@@
- fb->base.depth
+ fb->base.format->depth

@@
struct drm_framebuffer fb;
expression E;
@@
- fb.depth
+ fb.format->depth

@@
struct drm_framebuffer *fb;
expression E;
@@
- fb->depth
+ fb->format->depth

@@
struct drm_framebuffer fb;
@@
- (fb.format->depth)
+ fb.format->depth

@@
struct drm_framebuffer *fb;
@@
- (fb->format->depth)
+ fb->format->depth

@@
@@

 struct drm_framebuffer {
	 ...
(quoted diff) +0 -1
-	 unsigned int depth;
...
 };
Quoted 1 line
Quoted 38 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c        |  4 ++--
 drivers/gpu/drm/armada/armada_fbdev.c         |  3 ++-
 drivers/gpu/drm/ast/ast_fb.c                  |  2 +-
 drivers/gpu/drm/bochs/bochs_fbdev.c           |  2 +-
 drivers/gpu/drm/cirrus/cirrus_fbdev.c         |  4 ++--
 drivers/gpu/drm/drm_fb_cma_helper.c           |  2 +-
 drivers/gpu/drm/drm_fb_helper.c               |  2 +-
 drivers/gpu/drm/drm_framebuffer.c             |  2 +-
 drivers/gpu/drm/drm_modeset_helper.c          |  2 --
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c     |  2 +-
 drivers/gpu/drm/gma500/accel_2d.c             |  2 +-
 drivers/gpu/drm/gma500/framebuffer.c          |  2 +-
 drivers/gpu/drm/gma500/gma_display.c          |  2 +-
 drivers/gpu/drm/gma500/mdfld_intel_display.c  |  2 +-
 drivers/gpu/drm/gma500/oaktrail_crtc.c        |  2 +-
 drivers/gpu/drm/i915/i915_debugfs.c           |  4 ++--
 drivers/gpu/drm/i915/intel_fbdev.c            |  2 +-
 drivers/gpu/drm/mgag200/mgag200_fb.c          |  2 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c        |  6 +++---
 drivers/gpu/drm/msm/msm_fbdev.c               |  2 +-
 drivers/gpu/drm/nouveau/dispnv04/crtc.c       | 12 ++++++------
 drivers/gpu/drm/nouveau/dispnv04/dfp.c        |  2 +-
 drivers/gpu/drm/nouveau/nouveau_fbcon.c       |  3 ++-
 drivers/gpu/drm/omapdrm/omap_fbdev.c          |  2 +-
 drivers/gpu/drm/qxl/qxl_fb.c                  |  5 +++--
 drivers/gpu/drm/radeon/radeon_fb.c            |  4 ++--
 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c |  5 +++--
 drivers/gpu/drm/tegra/drm.c                   |  3 ++-
 drivers/gpu/drm/tegra/fb.c                    |  2 +-
 drivers/gpu/drm/udl/udl_fb.c                  |  2 +-
 drivers/gpu/drm/virtio/virtgpu_fb.c           |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c            |  7 ++++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c           |  2 --
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c           |  5 +++--
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c          |  2 +-
 include/drm/drm_framebuffer.h                 |  6 ------
 36 files changed, 56 insertions(+), 59 deletions(-)
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#44 lore raw

PATCH 31/32 drm: Nuke fb->bits_per_pixel

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Replace uses of fb->bits_per_pixel with fb->format->cpp[0]*8. Less duplicated information is a good thing.

Note that I didn't put parens around the cpp*8 in the below cocci script, on account of not wanting spurious parens all over the place. Instead I did the unsafe way, and tried to look over the entire diff to spot if any dangerous expressions were produced. I didn't see any.

There are some cases where previously the code did X*bpp/8, so the division happened after the multiplication. Those are now just X*cpp so the division effectively happens before the multiplication, but that is perfectly fine since bpp is always a multiple of 8.

@@
struct drm_framebuffer *fb;
expression E;
@@

 drm_helper_mode_fill_fb_struct(...) {
	...
-	fb->bits_per_pixel = E;
	...

}

@@
struct vmw_framebuffer_surface *vfb;
expression E;
@@
- vfb->base.base.bits_per_pixel = E;

@@
struct vmw_framebuffer_dmabuf *vfb;
expression E;
@@
- vfb->base.base.bits_per_pixel = E;

@@
struct drm_framebuffer *fb;
expression E;
@@

 i9xx_get_initial_plane_config(...) {
	...
-	fb->bits_per_pixel = E;
	...

}

@@
struct drm_framebuffer *fb;
expression E;
@@

 ironlake_get_initial_plane_config(...) {
	...
-	fb->bits_per_pixel = E;
	...

}

@@
struct drm_framebuffer *fb;
expression E;
@@

 skylake_get_initial_plane_config(...) {
	...
-	fb->bits_per_pixel = E;
	...

}

@@
struct drm_framebuffer fb;
expression E;
@@
(
- E * fb.bits_per_pixel / 8
+ E * fb.format->cpp[0]
|
- fb.bits_per_pixel / 8
+ fb.format->cpp[0]
|
- E * fb.bits_per_pixel >> 3
+ E * fb.format->cpp[0]
|
- fb.bits_per_pixel >> 3
+ fb.format->cpp[0]
|
- (fb.bits_per_pixel + 7) / 8
+ fb.format->cpp[0]
|
- fb.bits_per_pixel
+ fb.format->cpp[0] * 8
|
- fb.format->cpp[0] * 8 != 8
+ fb.format->cpp[0] != 1
)

@@
struct drm_framebuffer *fb;
expression E;
@@
(
- E * fb->bits_per_pixel / 8
+ E * fb->format->cpp[0]
|
- fb->bits_per_pixel / 8
+ fb->format->cpp[0]
|
- E * fb->bits_per_pixel >> 3
+ E * fb->format->cpp[0]
|
- fb->bits_per_pixel >> 3
+ fb->format->cpp[0]
|
- (fb->bits_per_pixel + 7) / 8
+ fb->format->cpp[0]
|
- fb->bits_per_pixel
+ fb->format->cpp[0] * 8
|
- fb->format->cpp[0] * 8 != 8
+ fb->format->cpp[0] != 1
)

@@
struct drm_framebuffer fb;
@@
- (fb.format->cpp[0])
+ fb.format->cpp[0]

@@
struct drm_framebuffer *fb;
@@
- (fb->format->cpp[0])
+ fb->format->cpp[0]

@@
@@

 struct drm_framebuffer {
	 ...
-	 int bits_per_pixel;
	 ...

};

---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c        |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c        |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c         |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c         |  2 +-
 drivers/gpu/drm/armada/armada_crtc.c          |  4 ++--
 drivers/gpu/drm/armada/armada_fbdev.c         |  2 +-
 drivers/gpu/drm/ast/ast_fb.c                  |  2 +-
 drivers/gpu/drm/ast/ast_mode.c                |  9 +++++----
 drivers/gpu/drm/cirrus/cirrus_fbdev.c         |  2 +-
 drivers/gpu/drm/cirrus/cirrus_mode.c          |  2 +-
 drivers/gpu/drm/drm_fb_helper.c               |  8 ++++----
 drivers/gpu/drm/drm_framebuffer.c             |  2 +-
 drivers/gpu/drm/drm_modeset_helper.c          |  3 ---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c |  4 ++--
 drivers/gpu/drm/exynos/exynos7_drm_decon.c    |  6 +++---
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c     |  4 ++--
 drivers/gpu/drm/exynos/exynos_drm_fimd.c      |  2 +-
 drivers/gpu/drm/exynos/exynos_mixer.c         |  4 ++--
 drivers/gpu/drm/gma500/framebuffer.c          |  2 +-
 drivers/gpu/drm/gma500/gma_display.c          |  4 ++--
 drivers/gpu/drm/gma500/mdfld_intel_display.c  |  6 +++---
 drivers/gpu/drm/gma500/oaktrail_crtc.c        |  4 ++--
 drivers/gpu/drm/i915/i915_debugfs.c           |  4 ++--
 drivers/gpu/drm/i915/intel_display.c          | 11 ++++-------
 drivers/gpu/drm/i915/intel_fbdev.c            |  6 +++---
 drivers/gpu/drm/mgag200/mgag200_fb.c          |  2 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c        | 16 ++++++++--------
 drivers/gpu/drm/nouveau/dispnv04/crtc.c       |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_display.c     |  2 +-
 drivers/gpu/drm/qxl/qxl_draw.c                |  2 +-
 drivers/gpu/drm/radeon/atombios_crtc.c        | 11 ++++++-----
 drivers/gpu/drm/radeon/r100.c                 |  4 ++--
 drivers/gpu/drm/radeon/radeon_display.c       |  6 +++---
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c   | 14 +++++++-------
 drivers/gpu/drm/tegra/dc.c                    |  2 +-
 drivers/gpu/drm/tegra/drm.c                   |  2 +-
 drivers/gpu/drm/udl/udl_fb.c                  |  2 +-
 drivers/gpu/drm/virtio/virtgpu_fb.c           |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c            |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c           |  2 --
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c           |  4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c          |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c          |  2 +-
 include/drm/drm_framebuffer.h                 |  7 -------
 44 files changed, 89 insertions(+), 102 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +1 -1
index 65a954cb69ed..9c8f33780257 100644
@@ -2220,7 +2220,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(mmGRPH_X_END + amdgpu_crtc->crtc_offset, target_fb->width);
 	WREG32(mmGRPH_Y_END + amdgpu_crtc->crtc_offset, target_fb->height);
 
-	fb_pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
+	fb_pitch_pixels = target_fb->pitches[0] / target_fb->format->cpp[0];
 	WREG32(mmGRPH_PITCH + amdgpu_crtc->crtc_offset, fb_pitch_pixels);
 
 	dce_v10_0_grph_enable(crtc, true);
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +1 -1
index d807e876366b..72ba3a50452b 100644
@@ -2201,7 +2201,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(mmGRPH_X_END + amdgpu_crtc->crtc_offset, target_fb->width);
 	WREG32(mmGRPH_Y_END + amdgpu_crtc->crtc_offset, target_fb->height);
 
-	fb_pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
+	fb_pitch_pixels = target_fb->pitches[0] / target_fb->format->cpp[0];
 	WREG32(mmGRPH_PITCH + amdgpu_crtc->crtc_offset, fb_pitch_pixels);
 
 	dce_v11_0_grph_enable(crtc, true);
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +1 -1
index bc9f2f423270..aa64d9c1a8c8 100644
@@ -1623,7 +1623,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(EVERGREEN_GRPH_X_END + amdgpu_crtc->crtc_offset, target_fb->width);
 	WREG32(EVERGREEN_GRPH_Y_END + amdgpu_crtc->crtc_offset, target_fb->height);
 
-	fb_pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
+	fb_pitch_pixels = target_fb->pitches[0] / target_fb->format->cpp[0];
 	WREG32(EVERGREEN_GRPH_PITCH + amdgpu_crtc->crtc_offset, fb_pitch_pixels);
 
 	dce_v6_0_grph_enable(crtc, true);
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +1 -1
index 4ae59914bc32..ecf6c68b8f43 100644
@@ -2079,7 +2079,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(mmGRPH_X_END + amdgpu_crtc->crtc_offset, target_fb->width);
 	WREG32(mmGRPH_Y_END + amdgpu_crtc->crtc_offset, target_fb->height);
 
-	fb_pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
+	fb_pitch_pixels = target_fb->pitches[0] / target_fb->format->cpp[0];
 	WREG32(mmGRPH_PITCH + amdgpu_crtc->crtc_offset, fb_pitch_pixels);
 
 	dce_v8_0_grph_enable(crtc, true);
drivers/gpu/drm/armada/armada_crtc.c +2 -2
index a51f8cbcfe26..c69a5ea54f23 100644
@@ -169,12 +169,12 @@ static unsigned armada_drm_crtc_calc_fb(struct drm_framebuffer *fb,
 {
 	struct armada_gem_object *obj = drm_fb_obj(fb);
 	unsigned pitch = fb->pitches[0];
-	unsigned offset = y * pitch + x * fb->bits_per_pixel / 8;
+	unsigned offset = y * pitch + x * fb->format->cpp[0];
 	uint32_t addr_odd, addr_even;
 	unsigned i = 0;
 
 	DRM_DEBUG_DRIVER("pitch %u x %d y %d bpp %d\n",
-		pitch, x, y, fb->bits_per_pixel);
+		pitch, x, y, fb->format->cpp[0] * 8);
 
 	addr_odd = addr_even = obj->dev_addr + offset;
 
drivers/gpu/drm/armada/armada_fbdev.c +1 -1
index 3a58fb600b05..78335100cbc3 100644
@@ -94,7 +94,7 @@ static int armada_fb_create(struct drm_fb_helper *fbh,
 	drm_fb_helper_fill_var(info, fbh, sizes->fb_width, sizes->fb_height);
 
 	DRM_DEBUG_KMS("allocated %dx%d %dbpp fb: 0x%08llx\n",
-		dfb->fb.width, dfb->fb.height, dfb->fb.bits_per_pixel,
+		dfb->fb.width, dfb->fb.height, dfb->fb.format->cpp[0] * 8,
 		(unsigned long long)obj->phys_addr);
 
 	return 0;
drivers/gpu/drm/ast/ast_fb.c +1 -1
index f751792a3c7c..b085140fae95 100644
@@ -49,7 +49,7 @@ static void ast_dirty_update(struct ast_fbdev *afbdev,
 	struct drm_gem_object *obj;
 	struct ast_bo *bo;
 	int src_offset, dst_offset;
-	int bpp = (afbdev->afb.base.bits_per_pixel + 7)/8;
+	int bpp = afbdev->afb.base.format->cpp[0];
 	int ret = -EBUSY;
 	bool unmap = false;
 	bool store_for_later = false;
drivers/gpu/drm/ast/ast_mode.c +5 -4
index deb3684ccaf8..0cf5e0ab5015 100644
@@ -85,7 +85,7 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo
 	bool check_sync;
 	struct ast_vbios_enhtable *best = NULL;
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		vbios_mode->std_table = &vbios_stdtable[VGAModeIndex];
 		color_index = VGAModeIndex - 1;
@@ -208,7 +208,8 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo
 		ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x91, 0x00);
 		if (vbios_mode->enh_table->flags & NewModeInfo) {
 			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x91, 0xa8);
-			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x92, fb->bits_per_pixel);
+			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x92,
+					  fb->format->cpp[0] * 8);
 			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x93, adjusted_mode->clock / 1000);
 			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x94, adjusted_mode->crtc_hdisplay);
 			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x95, adjusted_mode->crtc_hdisplay >> 8);
@@ -400,7 +401,7 @@ static void ast_set_ext_reg(struct drm_crtc *crtc, struct drm_display_mode *mode
 	const struct drm_framebuffer *fb = crtc->primary->fb;
 	u8 jregA0 = 0, jregA3 = 0, jregA8 = 0;
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		jregA0 = 0x70;
 		jregA3 = 0x01;
@@ -457,7 +458,7 @@ static bool ast_set_dac_reg(struct drm_crtc *crtc, struct drm_display_mode *mode
 {
 	const struct drm_framebuffer *fb = crtc->primary->fb;
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		break;
 	default:
drivers/gpu/drm/cirrus/cirrus_fbdev.c +1 -1
index 3cac8a03cf4f..79a5cd108245 100644
@@ -22,7 +22,7 @@ static void cirrus_dirty_update(struct cirrus_fbdev *afbdev,
 	struct drm_gem_object *obj;
 	struct cirrus_bo *bo;
 	int src_offset, dst_offset;
-	int bpp = (afbdev->gfb.base.bits_per_pixel + 7)/8;
+	int bpp = afbdev->gfb.base.format->cpp[0];
 	int ret = -EBUSY;
 	bool unmap = false;
 	bool store_for_later = false;
drivers/gpu/drm/cirrus/cirrus_mode.c +1 -1
index f2297acae235..e78a7a295cef 100644
@@ -258,7 +258,7 @@ static int cirrus_crtc_mode_set(struct drm_crtc *crtc,
 	sr07 = RREG8(SEQ_DATA);
 	sr07 &= 0xe0;
 	hdr = 0;
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		sr07 |= 0x11;
 		break;
drivers/gpu/drm/drm_fb_helper.c +4 -4
index 755e3b6e9710..bf5a06b7c0c1 100644
@@ -1162,7 +1162,7 @@ static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 		    !fb_helper->funcs->gamma_get))
 		return -EINVAL;
 
-	WARN_ON(fb->bits_per_pixel != 8);
+	WARN_ON(fb->format->cpp[0] * 8 != 8);
 
 	fb_helper->funcs->gamma_set(crtc, red, green, blue, regno);
 
@@ -1245,14 +1245,14 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
 	 * Changes struct fb_var_screeninfo are currently not pushed back
 	 * to KMS, hence fail if different settings are requested.
 	 */
-	if (var->bits_per_pixel != fb->bits_per_pixel ||
+	if (var->bits_per_pixel != fb->format->cpp[0] * 8 ||
 	    var->xres != fb->width || var->yres != fb->height ||
 	    var->xres_virtual != fb->width || var->yres_virtual != fb->height) {
 		DRM_DEBUG("fb userspace requested width/height/bpp different than current fb "
 			  "request %dx%d-%d (virtual %dx%d) > %dx%d-%d\n",
 			  var->xres, var->yres, var->bits_per_pixel,
 			  var->xres_virtual, var->yres_virtual,
-			  fb->width, fb->height, fb->bits_per_pixel);
+			  fb->width, fb->height, fb->format->cpp[0] * 8);
 		return -EINVAL;
 	}
 
@@ -1655,7 +1655,7 @@ void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helpe
 	info->pseudo_palette = fb_helper->pseudo_palette;
 	info->var.xres_virtual = fb->width;
 	info->var.yres_virtual = fb->height;
-	info->var.bits_per_pixel = fb->bits_per_pixel;
+	info->var.bits_per_pixel = fb->format->cpp[0] * 8;
 	info->var.accel_flags = FB_ACCELF_TEXT;
 	info->var.xoffset = 0;
 	info->var.yoffset = 0;
drivers/gpu/drm/drm_framebuffer.c +1 -1
index 00def930b6a5..98c054098808 100644
@@ -433,7 +433,7 @@ int drm_mode_getfb(struct drm_device *dev,
 	r->height = fb->height;
 	r->width = fb->width;
 	r->depth = fb->format->depth;
-	r->bpp = fb->bits_per_pixel;
+	r->bpp = fb->format->cpp[0] * 8;
 	r->pitch = fb->pitches[0];
 	if (fb->funcs->create_handle) {
 		if (drm_is_current_master(file_priv) || capable(CAP_SYS_ADMIN) ||
drivers/gpu/drm/drm_modeset_helper.c +0 -3
index e5d19e5fc341..3c44409244dc 100644
@@ -82,10 +82,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
 		DRM_DEBUG_KMS("non-RGB pixel format %s\n",
 		              drm_get_format_name(mode_cmd->pixel_format,
 		                                  &format_name));
-
-		fb->bits_per_pixel = 0;
 	} else {
-		fb->bits_per_pixel = info->cpp[0] * 8;
 	}
 
 	fb->dev = dev;
drivers/gpu/drm/exynos/exynos5433_drm_decon.c +2 -2
index 6ca1f3117fe8..e8ce4a318586 100644
@@ -226,7 +226,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
 		return;
 	}
 
-	DRM_DEBUG_KMS("bpp = %u\n", fb->bits_per_pixel);
+	DRM_DEBUG_KMS("bpp = %u\n", fb->format->cpp[0] * 8);
 
 	/*
 	 * In case of exynos, setting dma-burst to 16Word causes permanent
@@ -275,7 +275,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
 	struct decon_context *ctx = crtc->ctx;
 	struct drm_framebuffer *fb = state->base.fb;
 	unsigned int win = plane->index;
-	unsigned int bpp = fb->bits_per_pixel >> 3;
+	unsigned int bpp = fb->format->cpp[0];
 	unsigned int pitch = fb->pitches[0];
 	dma_addr_t dma_addr = exynos_drm_fb_dma_addr(fb, 0);
 	u32 val;
drivers/gpu/drm/exynos/exynos7_drm_decon.c +3 -3
index f4d5a2133777..58dc9a5196bc 100644
@@ -330,7 +330,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
 		break;
 	}
 
-	DRM_DEBUG_KMS("bpp = %d\n", fb->bits_per_pixel);
+	DRM_DEBUG_KMS("bpp = %d\n", fb->format->cpp[0] * 8);
 
 	/*
 	 * In case of exynos, setting dma-burst to 16Word causes permanent
@@ -340,7 +340,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
 	 * movement causes unstable DMA which results into iommu crash/tear.
 	 */
 
-	padding = (fb->pitches[0] / (fb->bits_per_pixel >> 3)) - fb->width;
+	padding = (fb->pitches[0] / fb->format->cpp[0]) - fb->width;
 	if (fb->width + padding < MIN_FB_WIDTH_FOR_16WORD_BURST) {
 		val &= ~WINCONx_BURSTLEN_MASK;
 		val |= WINCONx_BURSTLEN_8WORD;
@@ -407,7 +407,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
 	unsigned int last_x;
 	unsigned int last_y;
 	unsigned int win = plane->index;
-	unsigned int bpp = fb->bits_per_pixel >> 3;
+	unsigned int bpp = fb->format->cpp[0];
 	unsigned int pitch = fb->pitches[0];
 
 	if (ctx->suspended)
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +2 -2
index e68a46f112f6..d8808158d418 100644
@@ -76,7 +76,7 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
 {
 	struct fb_info *fbi;
 	struct drm_framebuffer *fb = helper->fb;
-	unsigned int size = fb->width * fb->height * (fb->bits_per_pixel >> 3);
+	unsigned int size = fb->width * fb->height * fb->format->cpp[0];
 	unsigned int nr_pages;
 	unsigned long offset;
 
@@ -103,7 +103,7 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
 		return -EIO;
 	}
 
-	offset = fbi->var.xoffset * (fb->bits_per_pixel >> 3);
+	offset = fbi->var.xoffset * fb->format->cpp[0];
 	offset += fbi->var.yoffset * fb->pitches[0];
 
 	fbi->screen_base = exynos_gem->kvaddr + offset;
drivers/gpu/drm/exynos/exynos_drm_fimd.c +1 -1
index e2e405170d35..0029065979b8 100644
@@ -738,7 +738,7 @@ static void fimd_update_plane(struct exynos_drm_crtc *crtc,
 	unsigned long val, size, offset;
 	unsigned int last_x, last_y, buf_offsize, line_size;
 	unsigned int win = plane->index;
-	unsigned int bpp = fb->bits_per_pixel >> 3;
+	unsigned int bpp = fb->format->cpp[0];
 	unsigned int pitch = fb->pitches[0];
 
 	if (ctx->suspended)
drivers/gpu/drm/exynos/exynos_mixer.c +2 -2
index edb20a34c66c..b313e61aab65 100644
@@ -631,7 +631,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
 
 	/* converting dma address base and source offset */
 	dma_addr = exynos_drm_fb_dma_addr(fb, 0)
-		+ (state->src.x * fb->bits_per_pixel >> 3)
+		+ (state->src.x * fb->format->cpp[0])
 		+ (state->src.y * fb->pitches[0]);
 	src_x_offset = 0;
 	src_y_offset = 0;
@@ -649,7 +649,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
 
 	/* setup geometry */
 	mixer_reg_write(res, MXR_GRAPHIC_SPAN(win),
-			fb->pitches[0] / (fb->bits_per_pixel >> 3));
+			fb->pitches[0] / fb->format->cpp[0]);
 
 	/* setup display size */
 	if (ctx->mxr_ver == MXR_VER_128_0_0_184 &&
drivers/gpu/drm/gma500/framebuffer.c +1 -1
index a93b59ce6b41..6bf33ba055b3 100644
@@ -77,7 +77,7 @@ static int psbfb_setcolreg(unsigned regno, unsigned red, unsigned green,
 	    (transp << info->var.transp.offset);
 
 	if (regno < 16) {
-		switch (fb->bits_per_pixel) {
+		switch (fb->format->cpp[0] * 8) {
 		case 16:
 			((uint32_t *) info->pseudo_palette)[regno] = v;
 			break;
drivers/gpu/drm/gma500/gma_display.c +2 -2
index 5b852ad152ae..d1c5642b1c1e 100644
@@ -82,14 +82,14 @@ int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 	if (ret < 0)
 		goto gma_pipe_set_base_exit;
 	start = psbfb->gtt->offset;
-	offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
+	offset = y * fb->pitches[0] + x * fb->format->cpp[0];
 
 	REG_WRITE(map->stride, fb->pitches[0]);
 
 	dspcntr = REG_READ(map->cntr);
 	dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		dspcntr |= DISPPLANE_8BPP;
 		break;
drivers/gpu/drm/gma500/mdfld_intel_display.c +3 -3
index 3be3111825cd..63c6e08600ae 100644
@@ -148,7 +148,7 @@ static int check_fb(struct drm_framebuffer *fb)
 	if (!fb)
 		return 0;
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 	case 16:
 	case 24:
@@ -197,13 +197,13 @@ static int mdfld__intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 		return 0;
 
 	start = psbfb->gtt->offset;
-	offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
+	offset = y * fb->pitches[0] + x * fb->format->cpp[0];
 
 	REG_WRITE(map->stride, fb->pitches[0]);
 	dspcntr = REG_READ(map->cntr);
 	dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		dspcntr |= DISPPLANE_8BPP;
 		break;
drivers/gpu/drm/gma500/oaktrail_crtc.c +2 -2
index 569810d47786..0fff269d3fe6 100644
@@ -618,14 +618,14 @@ static int oaktrail_pipe_set_base(struct drm_crtc *crtc,
 		return 0;
 
 	start = psbfb->gtt->offset;
-	offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
+	offset = y * fb->pitches[0] + x * fb->format->cpp[0];
 
 	REG_WRITE(map->stride, fb->pitches[0]);
 
 	dspcntr = REG_READ(map->cntr);
 	dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		dspcntr |= DISPPLANE_8BPP;
 		break;
drivers/gpu/drm/i915/i915_debugfs.c +2 -2
index ebcba97616ab..ee272ec8732c 100644
@@ -1895,7 +1895,7 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
 			   fbdev_fb->base.width,
 			   fbdev_fb->base.height,
 			   fbdev_fb->base.format->depth,
-			   fbdev_fb->base.bits_per_pixel,
+			   fbdev_fb->base.format->cpp[0] * 8,
 			   fbdev_fb->base.modifier,
 			   drm_framebuffer_read_refcount(&fbdev_fb->base));
 		describe_obj(m, fbdev_fb->obj);
@@ -1913,7 +1913,7 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
 			   fb->base.width,
 			   fb->base.height,
 			   fb->base.format->depth,
-			   fb->base.bits_per_pixel,
+			   fb->base.format->cpp[0] * 8,
 			   fb->base.modifier,
 			   drm_framebuffer_read_refcount(&fb->base));
 		describe_obj(m, fb->obj);
drivers/gpu/drm/i915/intel_display.c +4 -7
index 5d8db436c557..6c889f0e8e0f 100644
@@ -8715,7 +8715,6 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
 	pixel_format = val & DISPPLANE_PIXFORMAT_MASK;
 	fourcc = i9xx_format_to_fourcc(pixel_format);
 	fb->pixel_format = fourcc;
-	fb->bits_per_pixel = drm_format_plane_cpp(fourcc, 0) * 8;
 	fb->format = drm_format_info(fourcc);
 
 	if (INTEL_GEN(dev_priv) >= 4) {
@@ -8744,7 +8743,7 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
 
 	DRM_DEBUG_KMS("pipe/plane %c/%d with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
 		      pipe_name(pipe), plane, fb->width, fb->height,
-		      fb->bits_per_pixel, base, fb->pitches[0],
+		      fb->format->cpp[0] * 8, base, fb->pitches[0],
 		      plane_config->size);
 
 	plane_config->fb = intel_fb;
@@ -9747,7 +9746,6 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
 				      val & PLANE_CTL_ORDER_RGBX,
 				      val & PLANE_CTL_ALPHA_MASK);
 	fb->pixel_format = fourcc;
-	fb->bits_per_pixel = drm_format_plane_cpp(fourcc, 0) * 8;
 	fb->format = drm_format_info(fourcc);
 
 	tiling = val & PLANE_CTL_TILED_MASK;
@@ -9792,7 +9790,7 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
 
 	DRM_DEBUG_KMS("pipe %c with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
 		      pipe_name(pipe), fb->width, fb->height,
-		      fb->bits_per_pixel, base, fb->pitches[0],
+		      fb->format->cpp[0] * 8, base, fb->pitches[0],
 		      plane_config->size);
 
 	plane_config->fb = intel_fb;
@@ -9863,7 +9861,6 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
 	pixel_format = val & DISPPLANE_PIXFORMAT_MASK;
 	fourcc = i9xx_format_to_fourcc(pixel_format);
 	fb->pixel_format = fourcc;
-	fb->bits_per_pixel = drm_format_plane_cpp(fourcc, 0) * 8;
 	fb->format = drm_format_info(fourcc);
 
 	base = I915_READ(DSPSURF(pipe)) & 0xfffff000;
@@ -9892,7 +9889,7 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
 
 	DRM_DEBUG_KMS("pipe %c with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
 		      pipe_name(pipe), fb->width, fb->height,
-		      fb->bits_per_pixel, base, fb->pitches[0],
+		      fb->format->cpp[0] * 8, base, fb->pitches[0],
 		      plane_config->size);
 
 	plane_config->fb = intel_fb;
@@ -11051,7 +11048,7 @@ mode_fits_in_fbdev(struct drm_device *dev,
 
 	fb = &dev_priv->fbdev->fb->base;
 	if (fb->pitches[0] < intel_framebuffer_pitch_for_width(mode->hdisplay,
-							       fb->bits_per_pixel))
+							       fb->format->cpp[0] * 8))
 		return NULL;
 
 	if (obj->base.size < mode->vdisplay * fb->pitches[0])
drivers/gpu/drm/i915/intel_fbdev.c +3 -3
index b726483a460d..3f60a4f6f078 100644
@@ -621,7 +621,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 		 * rather than the current pipe's, since they differ.
 		 */
 		cur_size = intel_crtc->config->base.adjusted_mode.crtc_hdisplay;
-		cur_size = cur_size * fb->base.bits_per_pixel / 8;
+		cur_size = cur_size * fb->base.format->cpp[0];
 		if (fb->base.pitches[0] < cur_size) {
 			DRM_DEBUG_KMS("fb not wide enough for plane %c (%d vs %d)\n",
 				      pipe_name(intel_crtc->pipe),
@@ -639,7 +639,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 			      pipe_name(intel_crtc->pipe),
 			      intel_crtc->config->base.adjusted_mode.crtc_hdisplay,
 			      intel_crtc->config->base.adjusted_mode.crtc_vdisplay,
-			      fb->base.bits_per_pixel,
+			      fb->base.format->cpp[0] * 8,
 			      cur_size);
 
 		if (cur_size > max_size) {
@@ -660,7 +660,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 		goto out;
 	}
 
-	ifbdev->preferred_bpp = fb->base.bits_per_pixel;
+	ifbdev->preferred_bpp = fb->base.format->cpp[0] * 8;
 	ifbdev->fb = fb;
 
 	drm_framebuffer_reference(&ifbdev->fb->base);
drivers/gpu/drm/mgag200/mgag200_fb.c +1 -1
index 19a78b6b5a1a..1a665e1671b8 100644
@@ -24,7 +24,7 @@ static void mga_dirty_update(struct mga_fbdev *mfbdev,
 	struct drm_gem_object *obj;
 	struct mgag200_bo *bo;
 	int src_offset, dst_offset;
-	int bpp = (mfbdev->mfb.base.bits_per_pixel + 7)/8;
+	int bpp = mfbdev->mfb.base.format->cpp[0];
 	int ret = -EBUSY;
 	bool unmap = false;
 	bool store_for_later = false;
drivers/gpu/drm/mgag200/mgag200_mode.c +8 -8
index 3180db5e81cb..1e039cfddedf 100644
@@ -38,7 +38,7 @@ static void mga_crtc_load_lut(struct drm_crtc *crtc)
 
 	WREG8(DAC_INDEX + MGA1064_INDEX, 0);
 
-	if (fb && fb->bits_per_pixel == 16) {
+	if (fb && fb->format->cpp[0] * 8 == 16) {
 		int inc = (fb->format->depth == 15) ? 8 : 4;
 		u8 r, b;
 		for (i = 0; i < MGAG200_LUT_SIZE; i += inc) {
@@ -903,7 +903,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 		/* 0x48: */        0,    0,    0,    0,    0,    0,    0,    0
 	};
 
-	bppshift = mdev->bpp_shifts[(fb->bits_per_pixel >> 3) - 1];
+	bppshift = mdev->bpp_shifts[fb->format->cpp[0] - 1];
 
 	switch (mdev->type) {
 	case G200_SE_A:
@@ -942,7 +942,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 		break;
 	}
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		dacvalue[MGA1064_MUL_CTL] = MGA1064_MUL_CTL_8bits;
 		break;
@@ -998,8 +998,8 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 	WREG_SEQ(3, 0);
 	WREG_SEQ(4, 0xe);
 
-	pitch = fb->pitches[0] / (fb->bits_per_pixel / 8);
-	if (fb->bits_per_pixel == 24)
+	pitch = fb->pitches[0] / fb->format->cpp[0];
+	if (fb->format->cpp[0] * 8 == 24)
 		pitch = (pitch * 3) >> (4 - bppshift);
 	else
 		pitch = pitch >> (4 - bppshift);
@@ -1076,7 +1076,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 		((vdisplay & 0xc00) >> 7) |
 		((vsyncstart & 0xc00) >> 5) |
 		((vdisplay & 0x400) >> 3);
-	if (fb->bits_per_pixel == 24)
+	if (fb->format->cpp[0] * 8 == 24)
 		ext_vga[3] = (((1 << bppshift) * 3) - 1) | 0x80;
 	else
 		ext_vga[3] = ((1 << bppshift) - 1) | 0x80;
@@ -1139,9 +1139,9 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 			u32 bpp;
 			u32 mb;
 
-			if (fb->bits_per_pixel > 16)
+			if (fb->format->cpp[0] * 8 > 16)
 				bpp = 32;
-			else if (fb->bits_per_pixel > 8)
+			else if (fb->format->cpp[0] * 8 > 8)
 				bpp = 16;
 			else
 				bpp = 8;
drivers/gpu/drm/nouveau/dispnv04/crtc.c +2 -2
index 480e3ab477fd..a72754d73c84 100644
@@ -874,11 +874,11 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc,
 
 	/* Update the framebuffer location. */
 	regp->fb_start = nv_crtc->fb.offset & ~3;
-	regp->fb_start += (y * drm_fb->pitches[0]) + (x * drm_fb->bits_per_pixel / 8);
+	regp->fb_start += (y * drm_fb->pitches[0]) + (x * drm_fb->format->cpp[0]);
 	nv_set_crtc_base(dev, nv_crtc->index, regp->fb_start);
 
 	/* Update the arbitration parameters. */
-	nouveau_calc_arb(dev, crtc->mode.clock, drm_fb->bits_per_pixel,
+	nouveau_calc_arb(dev, crtc->mode.clock, drm_fb->format->cpp[0] * 8,
 			 &arb_burst, &arb_lwm);
 
 	regp->CRTC[NV_CIO_CRE_FF_INDEX] = arb_burst;
drivers/gpu/drm/nouveau/nouveau_display.c +1 -1
index a46d893aaafa..317ac38fc613 100644
@@ -888,7 +888,7 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 
 	/* Initialize a page flip struct */
 	*s = (struct nouveau_page_flip_state)
-		{ { }, event, crtc, fb->bits_per_pixel, fb->pitches[0],
+		{ { }, event, crtc, fb->format->cpp[0] * 8, fb->pitches[0],
 		  new_bo->bo.offset };
 
 	/* Keep vblanks on during flip, for the target crtc of this flip */
drivers/gpu/drm/qxl/qxl_draw.c +1 -1
index 9b728edf1b49..4d8681e84e68 100644
@@ -283,7 +283,7 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,
 	struct qxl_rect *rects;
 	int stride = qxl_fb->base.pitches[0];
 	/* depth is not actually interesting, we don't mask with it */
-	int depth = qxl_fb->base.bits_per_pixel;
+	int depth = qxl_fb->base.format->cpp[0] * 8;
 	uint8_t *surface_base;
 	struct qxl_release *release;
 	struct qxl_bo *clips_bo;
drivers/gpu/drm/radeon/atombios_crtc.c +6 -5
index 05f4ebe31ce2..8eeffc5324b2 100644
@@ -1277,7 +1277,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 
 				/* Calculate the macrotile mode index. */
 				tile_split_bytes = 64 << tile_split;
-				tileb = 8 * 8 * target_fb->bits_per_pixel / 8;
+				tileb = (8 * 8) * target_fb->format->cpp[0];
 				tileb = min(tile_split_bytes, tileb);
 
 				for (index = 0; tileb > 64; index++)
@@ -1285,13 +1285,14 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 
 				if (index >= 16) {
 					DRM_ERROR("Wrong screen bpp (%u) or tile split (%u)\n",
-						  target_fb->bits_per_pixel, tile_split);
+						  target_fb->format->cpp[0] * 8,
+						  tile_split);
 					return -EINVAL;
 				}
 
 				num_banks = (rdev->config.cik.macrotile_mode_array[index] >> 6) & 0x3;
 			} else {
-				switch (target_fb->bits_per_pixel) {
+				switch (target_fb->format->cpp[0] * 8) {
 				case 8:
 					index = 10;
 					break;
@@ -1414,7 +1415,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(EVERGREEN_GRPH_X_END + radeon_crtc->crtc_offset, target_fb->width);
 	WREG32(EVERGREEN_GRPH_Y_END + radeon_crtc->crtc_offset, target_fb->height);
 
-	fb_pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
+	fb_pitch_pixels = target_fb->pitches[0] / target_fb->format->cpp[0];
 	WREG32(EVERGREEN_GRPH_PITCH + radeon_crtc->crtc_offset, fb_pitch_pixels);
 	WREG32(EVERGREEN_GRPH_ENABLE + radeon_crtc->crtc_offset, 1);
 
@@ -1621,7 +1622,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(AVIVO_D1GRPH_X_END + radeon_crtc->crtc_offset, target_fb->width);
 	WREG32(AVIVO_D1GRPH_Y_END + radeon_crtc->crtc_offset, target_fb->height);
 
-	fb_pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
+	fb_pitch_pixels = target_fb->pitches[0] / target_fb->format->cpp[0];
 	WREG32(AVIVO_D1GRPH_PITCH + radeon_crtc->crtc_offset, fb_pitch_pixels);
 	WREG32(AVIVO_D1GRPH_ENABLE + radeon_crtc->crtc_offset, 1);
 
drivers/gpu/drm/radeon/r100.c +2 -2
index 984b35f43554..e3399310d41d 100644
@@ -3229,7 +3229,7 @@ void r100_bandwidth_update(struct radeon_device *rdev)
 			rdev->mode_info.crtcs[0]->base.primary->fb;
 
 		mode1 = &rdev->mode_info.crtcs[0]->base.mode;
-		pixel_bytes1 = fb->bits_per_pixel / 8;
+		pixel_bytes1 = fb->format->cpp[0];
 	}
 	if (!(rdev->flags & RADEON_SINGLE_CRTC)) {
 		if (rdev->mode_info.crtcs[1]->base.enabled) {
@@ -3237,7 +3237,7 @@ void r100_bandwidth_update(struct radeon_device *rdev)
 				rdev->mode_info.crtcs[1]->base.primary->fb;
 
 			mode2 = &rdev->mode_info.crtcs[1]->base.mode;
-			pixel_bytes2 = fb->bits_per_pixel / 8;
+			pixel_bytes2 = fb->format->cpp[0];
 		}
 	}
 
drivers/gpu/drm/radeon/radeon_display.c +3 -3
index 6285355eb5d5..aea8b62835a4 100644
@@ -549,19 +549,19 @@ static int radeon_crtc_page_flip_target(struct drm_crtc *crtc,
 	if (!ASIC_IS_AVIVO(rdev)) {
 		/* crtc offset is from display base addr not FB location */
 		base -= radeon_crtc->legacy_display_base_addr;
-		pitch_pixels = fb->pitches[0] / (fb->bits_per_pixel / 8);
+		pitch_pixels = fb->pitches[0] / fb->format->cpp[0];
 
 		if (tiling_flags & RADEON_TILING_MACRO) {
 			if (ASIC_IS_R300(rdev)) {
 				base &= ~0x7ff;
 			} else {
-				int byteshift = fb->bits_per_pixel >> 4;
+				int byteshift = fb->format->cpp[0] * 8 >> 4;
 				int tile_addr = (((crtc->y >> 3) * pitch_pixels +  crtc->x) >> (8 - byteshift)) << 11;
 				base += tile_addr + ((crtc->x << byteshift) % 256) + ((crtc->y % 8) << 8);
 			}
 		} else {
 			int offset = crtc->y * pitch_pixels + crtc->x;
-			switch (fb->bits_per_pixel) {
+			switch (fb->format->cpp[0] * 8) {
 			case 8:
 			default:
 				offset *= 1;
drivers/gpu/drm/radeon/radeon_legacy_crtc.c +7 -7
index 31c03e32a6b5..ce6cb6666212 100644
@@ -402,7 +402,7 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
 		target_fb = crtc->primary->fb;
 	}
 
-	switch (target_fb->bits_per_pixel) {
+	switch (target_fb->format->cpp[0] * 8) {
 	case 8:
 		format = 2;
 		break;
@@ -476,9 +476,9 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
 
 	crtc_offset_cntl = 0;
 
-	pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
-	crtc_pitch = DIV_ROUND_UP(pitch_pixels * target_fb->bits_per_pixel,
-				  target_fb->bits_per_pixel * 8);
+	pitch_pixels = target_fb->pitches[0] / target_fb->format->cpp[0];
+	crtc_pitch = DIV_ROUND_UP(pitch_pixels * target_fb->format->cpp[0] * 8,
+				  target_fb->format->cpp[0] * 8 * 8);
 	crtc_pitch |= crtc_pitch << 16;
 
 	crtc_offset_cntl |= RADEON_CRTC_GUI_TRIG_OFFSET_LEFT_EN;
@@ -503,14 +503,14 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
 			crtc_tile_x0_y0 = x | (y << 16);
 			base &= ~0x7ff;
 		} else {
-			int byteshift = target_fb->bits_per_pixel >> 4;
+			int byteshift = target_fb->format->cpp[0] * 8 >> 4;
 			int tile_addr = (((y >> 3) * pitch_pixels +  x) >> (8 - byteshift)) << 11;
 			base += tile_addr + ((x << byteshift) % 256) + ((y % 8) << 8);
 			crtc_offset_cntl |= (y % 16);
 		}
 	} else {
 		int offset = y * pitch_pixels + x;
-		switch (target_fb->bits_per_pixel) {
+		switch (target_fb->format->cpp[0] * 8) {
 		case 8:
 			offset *= 1;
 			break;
@@ -602,7 +602,7 @@ static bool radeon_set_crtc_timing(struct drm_crtc *crtc, struct drm_display_mod
 		}
 	}
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		format = 2;
 		break;
drivers/gpu/drm/tegra/dc.c +1 -1
index 4010d69cbd08..3af157a2d40c 100644
@@ -568,7 +568,7 @@ static void tegra_plane_atomic_update(struct drm_plane *plane,
 	window.dst.y = plane->state->crtc_y;
 	window.dst.w = plane->state->crtc_w;
 	window.dst.h = plane->state->crtc_h;
-	window.bits_per_pixel = fb->bits_per_pixel;
+	window.bits_per_pixel = fb->format->cpp[0] * 8;
 	window.bottom_up = tegra_fb_is_bottom_up(fb);
 
 	/* copy from state */
drivers/gpu/drm/tegra/drm.c +1 -1
index d2893f65341a..e289dbc6ad82 100644
@@ -877,7 +877,7 @@ static int tegra_debugfs_framebuffers(struct seq_file *s, void *data)
 		seq_printf(s, "%3d: user size: %d x %d, depth %d, %d bpp, refcount %d\n",
 			   fb->base.id, fb->width, fb->height,
 			   fb->format->depth,
-			   fb->bits_per_pixel,
+			   fb->format->cpp[0] * 8,
 			   drm_framebuffer_read_refcount(fb));
 	}
 
drivers/gpu/drm/udl/udl_fb.c +1 -1
index e21a3ed3ab2b..b8dc06d68777 100644
@@ -89,7 +89,7 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
 	int bytes_identical = 0;
 	struct urb *urb;
 	int aligned_x;
-	int bpp = (fb->base.bits_per_pixel / 8);
+	int bpp = fb->base.format->cpp[0];
 
 	if (!fb->active_16)
 		return 0;
drivers/gpu/drm/virtio/virtgpu_fb.c +1 -1
index 9d0da42cc420..61254b991265 100644
@@ -43,7 +43,7 @@ static int virtio_gpu_dirty_update(struct virtio_gpu_framebuffer *fb,
 	struct drm_device *dev = fb->base.dev;
 	struct virtio_gpu_device *vgdev = dev->dev_private;
 	bool store_for_later = false;
-	int bpp = fb->base.bits_per_pixel / 8;
+	int bpp = fb->base.format->cpp[0];
 	int x2, y2;
 	unsigned long flags;
 	struct virtio_gpu_object *obj = gem_to_virtio_gpu_obj(fb->obj);
drivers/gpu/drm/vmwgfx/vmwgfx_fb.c +3 -3
index b6e4add09f44..4d9ab16fb909 100644
@@ -93,7 +93,7 @@ static int vmw_fb_setcolreg(unsigned regno, unsigned red, unsigned green,
 	default:
 		DRM_ERROR("Bad depth %u, bpp %u.\n",
 			  par->set_fb->format->depth,
-			  par->set_fb->bits_per_pixel);
+			  par->set_fb->format->cpp[0] * 8);
 		return 1;
 	}
 
@@ -198,7 +198,7 @@ static void vmw_fb_dirty_flush(struct work_struct *work)
 	 * Handle panning when copying from vmalloc to framebuffer.
 	 * Clip dirty area to framebuffer.
 	 */
-	cpp = (cur_fb->bits_per_pixel + 7) / 8;
+	cpp = cur_fb->format->cpp[0];
 	max_x = par->fb_x + cur_fb->width;
 	max_y = par->fb_y + cur_fb->height;
 
@@ -486,7 +486,7 @@ static int vmw_fb_kms_framebuffer(struct fb_info *info)
 	cur_fb = par->set_fb;
 	if (cur_fb && cur_fb->width == mode_cmd.width &&
 	    cur_fb->height == mode_cmd.height &&
-	    cur_fb->bits_per_pixel == mode_cmd.bpp &&
+	    cur_fb->format->cpp[0] * 8 == mode_cmd.bpp &&
 	    cur_fb->format->depth == mode_cmd.depth &&
 	    cur_fb->pitches[0] == mode_cmd.pitch)
 		return 0;
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0 -2
index 2ce4743701f1..eb8e36462961 100644
@@ -591,7 +591,6 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
 	/* XXX get the first 4 from the surface info */
 	vfbs->base.base.format = drm_format_info(pixel_format);
 	vfbs->base.base.pixel_format = pixel_format;
-	vfbs->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbs->base.base.pitches[0] = mode_cmd->pitch;
 	vfbs->base.base.width = mode_cmd->width;
 	vfbs->base.base.height = mode_cmd->height;
@@ -899,7 +898,6 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
 	vfbd->base.base.dev = dev;
 	vfbd->base.base.format = drm_format_info(pixel_format);
 	vfbd->base.base.pixel_format = pixel_format;
-	vfbd->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbd->base.base.pitches[0] = mode_cmd->pitch;
 	vfbd->base.base.width = mode_cmd->width;
 	vfbd->base.base.height = mode_cmd->height;
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +2 -2
index a3a839a3d441..3806148e1bdb 100644
@@ -97,7 +97,7 @@ static int vmw_ldu_commit_list(struct vmw_private *dev_priv)
 		fb = entry->base.crtc.primary->fb;
 
 		return vmw_kms_write_svga(dev_priv, w, h, fb->pitches[0],
-					  fb->bits_per_pixel,
+					  fb->format->cpp[0] * 8,
 					  fb->format->depth);
 	}
 
@@ -106,7 +106,7 @@ static int vmw_ldu_commit_list(struct vmw_private *dev_priv)
 		fb = entry->base.crtc.primary->fb;
 
 		vmw_kms_write_svga(dev_priv, fb->width, fb->height, fb->pitches[0],
-				   fb->bits_per_pixel, fb->format->depth);
+				   fb->format->cpp[0] * 8, fb->format->depth);
 	}
 
 	/* Make sure we always show something. */
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +1 -1
index 38d7b8a2b78e..d4268efc37d2 100644
@@ -618,7 +618,7 @@ static int do_dmabuf_define_gmrfb(struct vmw_private *dev_priv,
 	}
 
 	cmd->header = SVGA_CMD_DEFINE_GMRFB;
-	cmd->body.format.bitsPerPixel = framebuffer->base.bits_per_pixel;
+	cmd->body.format.bitsPerPixel = framebuffer->base.format->cpp[0] * 8;
 	cmd->body.format.colorDepth = depth;
 	cmd->body.format.reserved = 0;
 	cmd->body.bytesPerLine = framebuffer->base.pitches[0];
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +1 -1
index 94ad8d2acf9a..b27cd18ee66a 100644
@@ -424,7 +424,7 @@ static int vmw_stdu_bind_fb(struct vmw_private *dev_priv,
 		 */
 		if (new_content_type == SEPARATE_DMA) {
 
-			switch (new_fb->bits_per_pixel) {
+			switch (new_fb->format->cpp[0] * 8) {
 			case 32:
 				content_srf.format = SVGA3D_X8R8G8B8;
 				break;
include/drm/drm_framebuffer.h +0 -7
index 9b9772998db6..4efc5066475a 100644
@@ -170,13 +170,6 @@ struct drm_framebuffer {
 	 */
 	unsigned int height;
 	/**
-	 * @bits_per_pixel: Storage used bits per pixel for RGB formats. 0 for
-	 * everything else. Legacy information derived from @pixel_format, it's
-	 * suggested to use the DRM FOURCC codes and helper functions directly
-	 * instead.
-	 */
-	int bits_per_pixel;
-	/**
 	 * @flags: Framebuffer flags like DRM_MODE_FB_INTERLACED or
 	 * DRM_MODE_FB_MODIFIERS.
 	 */
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 31/32
#45 lore raw

Re: [PATCH 31/32] drm: Nuke fb->bits_per_pixel

Hi Ville,

Thank you for the patch.

Quoted 14 lines · On Thursday 17 Nov 2016 18:14:30 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Replace uses of fb->bits_per_pixel with fb->format->cpp[0]*8. Less duplicated information is a good thing.

Note that I didn't put parens around the cpp*8 in the below cocci script, on account of not wanting spurious parens all over the place. Instead I did the unsafe way, and tried to look over the entire diff to spot if any dangerous expressions were produced. I didn't see any.

There are some cases where previously the code did X*bpp/8, so the division happened after the multiplication. Those are now just X*cpp so the division effectively happens before the multiplication, but that is perfectly fine since bpp is always a multiple of 8.

[snip]

Quoted 47 lines
---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c        |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c        |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c         |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c         |  2 +-
 drivers/gpu/drm/armada/armada_crtc.c          |  4 ++--
 drivers/gpu/drm/armada/armada_fbdev.c         |  2 +-
 drivers/gpu/drm/ast/ast_fb.c                  |  2 +-
 drivers/gpu/drm/ast/ast_mode.c                |  9 +++++----
 drivers/gpu/drm/cirrus/cirrus_fbdev.c         |  2 +-
 drivers/gpu/drm/cirrus/cirrus_mode.c          |  2 +-
 drivers/gpu/drm/drm_fb_helper.c               |  8 ++++----
 drivers/gpu/drm/drm_framebuffer.c             |  2 +-
 drivers/gpu/drm/drm_modeset_helper.c          |  3 ---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c |  4 ++--
 drivers/gpu/drm/exynos/exynos7_drm_decon.c    |  6 +++---
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c     |  4 ++--
 drivers/gpu/drm/exynos/exynos_drm_fimd.c      |  2 +-
 drivers/gpu/drm/exynos/exynos_mixer.c         |  4 ++--
 drivers/gpu/drm/gma500/framebuffer.c          |  2 +-
 drivers/gpu/drm/gma500/gma_display.c          |  4 ++--
 drivers/gpu/drm/gma500/mdfld_intel_display.c  |  6 +++---
 drivers/gpu/drm/gma500/oaktrail_crtc.c        |  4 ++--
 drivers/gpu/drm/i915/i915_debugfs.c           |  4 ++--
 drivers/gpu/drm/i915/intel_display.c          | 11 ++++-------
 drivers/gpu/drm/i915/intel_fbdev.c            |  6 +++---
 drivers/gpu/drm/mgag200/mgag200_fb.c          |  2 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c        | 16 ++++++++--------
 drivers/gpu/drm/nouveau/dispnv04/crtc.c       |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_display.c     |  2 +-
 drivers/gpu/drm/qxl/qxl_draw.c                |  2 +-
 drivers/gpu/drm/radeon/atombios_crtc.c        | 11 ++++++-----
 drivers/gpu/drm/radeon/r100.c                 |  4 ++--
 drivers/gpu/drm/radeon/radeon_display.c       |  6 +++---
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c   | 14 +++++++-------
 drivers/gpu/drm/tegra/dc.c                    |  2 +-
 drivers/gpu/drm/tegra/drm.c                   |  2 +-
 drivers/gpu/drm/udl/udl_fb.c                  |  2 +-
 drivers/gpu/drm/virtio/virtgpu_fb.c           |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c            |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c           |  2 --
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c           |  4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c          |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c          |  2 +-
 include/drm/drm_framebuffer.h                 |  7 -------
 44 files changed, 89 insertions(+), 102 deletions(-)

[snip]

drivers/gpu/drm/drm_fb_helper.c static int setcolreg(struct drm_crtc *crtc, u16 red, · line 1165

Quoted 10 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_fb_helper.c index 755e3b6e9710..bf5a06b7c0c1 100644

drivers/gpu/drm/drm_fb_helper.c +1 -1
@@ -1162,7 +1162,7 @@ static int setcolreg(struct drm_crtc *crtc, u16 red,
 u16 green, !fb_helper->funcs->gamma_get))
 		return -EINVAL;
 
-	WARN_ON(fb->bits_per_pixel != 8);
+	WARN_ON(fb->format->cpp[0] * 8 != 8);

Maybe just WARN_ON(fb->format->cpp[0] != 1); ?

Quoted 1 line
drivers/gpu/drm/drm_fb_helper.c +0 -0
 	fb_helper->funcs->gamma_set(crtc, red, green, blue, regno);

[snip]

Quoted 6 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_modeset_helper.c index e5d19e5fc341..3c44409244dc 100644

drivers/gpu/drm/drm_modeset_helper.c void drm_helper_mode_fill_fb_struct(struct drm_device · line 86

Quoted 8 lines
drivers/gpu/drm/drm_modeset_helper.c +0 -3
@@ -82,10 +82,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device
 *dev, DRM_DEBUG_KMS("non-RGB pixel format %s\n",
 		              drm_get_format_name(mode_cmd->pixel_format,
 		                                  &format_name));
-
-		fb->bits_per_pixel = 0;
 	} else {
-		fb->bits_per_pixel = info->cpp[0] * 8;
 	}

I think you can remove the whole check.

Quoted 2 lines
drivers/gpu/drm/drm_modeset_helper.c +0 -0
 	fb->dev = dev;

[snip]

drivers/gpu/drm/radeon/atombios_crtc.c static int dce4_crtc_do_set_base(struct drm_crtc · line 1281

Quoted 12 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/radeon/atombios_crtc.c index 05f4ebe31ce2..8eeffc5324b2 100644

drivers/gpu/drm/radeon/atombios_crtc.c +1 -1
@@ -1277,7 +1277,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc
 *crtc,
 
 				/* Calculate the macrotile mode index. */
 				tile_split_bytes = 64 << tile_split;
-				tileb = 8 * 8 * target_fb->bits_per_pixel / 8;
+				tileb = (8 * 8) * target_fb->format->cpp[0];

The parentheses are not needed.

With these fixed,

Quoted 3 lines
drivers/gpu/drm/radeon/atombios_crtc.c +0 -0
 				tileb = min(tile_split_bytes, tileb);
 

for (index = 0; tileb > 64; index++)

[snip]

Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#46 lore raw

Re: [PATCH 31/32] drm: Nuke fb->bits_per_pixel

Quoted 80 lines · Laurent Pinchart

Hi Ville,

Thank you for the patch.

Quoted 14 lines · On Thursday 17 Nov 2016 18:14:30 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Replace uses of fb->bits_per_pixel with fb->format->cpp[0]*8. Less duplicated information is a good thing.

Note that I didn't put parens around the cpp*8 in the below cocci script, on account of not wanting spurious parens all over the place. Instead I did the unsafe way, and tried to look over the entire diff to spot if any dangerous expressions were produced. I didn't see any.

There are some cases where previously the code did X*bpp/8, so the division happened after the multiplication. Those are now just X*cpp so the division effectively happens before the multiplication, but that is perfectly fine since bpp is always a multiple of 8.

[snip]

Quoted 47 lines
---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c        |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c        |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c         |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c         |  2 +-
 drivers/gpu/drm/armada/armada_crtc.c          |  4 ++--
 drivers/gpu/drm/armada/armada_fbdev.c         |  2 +-
 drivers/gpu/drm/ast/ast_fb.c                  |  2 +-
 drivers/gpu/drm/ast/ast_mode.c                |  9 +++++----
 drivers/gpu/drm/cirrus/cirrus_fbdev.c         |  2 +-
 drivers/gpu/drm/cirrus/cirrus_mode.c          |  2 +-
 drivers/gpu/drm/drm_fb_helper.c               |  8 ++++----
 drivers/gpu/drm/drm_framebuffer.c             |  2 +-
 drivers/gpu/drm/drm_modeset_helper.c          |  3 ---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c |  4 ++--
 drivers/gpu/drm/exynos/exynos7_drm_decon.c    |  6 +++---
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c     |  4 ++--
 drivers/gpu/drm/exynos/exynos_drm_fimd.c      |  2 +-
 drivers/gpu/drm/exynos/exynos_mixer.c         |  4 ++--
 drivers/gpu/drm/gma500/framebuffer.c          |  2 +-
 drivers/gpu/drm/gma500/gma_display.c          |  4 ++--
 drivers/gpu/drm/gma500/mdfld_intel_display.c  |  6 +++---
 drivers/gpu/drm/gma500/oaktrail_crtc.c        |  4 ++--
 drivers/gpu/drm/i915/i915_debugfs.c           |  4 ++--
 drivers/gpu/drm/i915/intel_display.c          | 11 ++++-------
 drivers/gpu/drm/i915/intel_fbdev.c            |  6 +++---
 drivers/gpu/drm/mgag200/mgag200_fb.c          |  2 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c        | 16 ++++++++--------
 drivers/gpu/drm/nouveau/dispnv04/crtc.c       |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_display.c     |  2 +-
 drivers/gpu/drm/qxl/qxl_draw.c                |  2 +-
 drivers/gpu/drm/radeon/atombios_crtc.c        | 11 ++++++-----
 drivers/gpu/drm/radeon/r100.c                 |  4 ++--
 drivers/gpu/drm/radeon/radeon_display.c       |  6 +++---
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c   | 14 +++++++-------
 drivers/gpu/drm/tegra/dc.c                    |  2 +-
 drivers/gpu/drm/tegra/drm.c                   |  2 +-
 drivers/gpu/drm/udl/udl_fb.c                  |  2 +-
 drivers/gpu/drm/virtio/virtgpu_fb.c           |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c            |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c           |  2 --
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c           |  4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c          |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c          |  2 +-
 include/drm/drm_framebuffer.h                 |  7 -------
 44 files changed, 89 insertions(+), 102 deletions(-)

[snip]

Quoted 8 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_fb_helper.c index 755e3b6e9710..bf5a06b7c0c1 100644

drivers/gpu/drm/drm_fb_helper.c +0 -0
@@ -1162,7 +1162,7 @@ static int setcolreg(struct drm_crtc *crtc, u16 red,
 u16 green, !fb_helper->funcs->gamma_get))
 		return -EINVAL;
 
Quoted 4 lines

drivers/gpu/drm/drm_fb_helper.c static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green, · line 1165

Quoted 2 lines
drivers/gpu/drm/drm_fb_helper.c +1 -1
-	WARN_ON(fb->bits_per_pixel != 8);
+	WARN_ON(fb->format->cpp[0] * 8 != 8);

Maybe just WARN_ON(fb->format->cpp[0] != 1); ?

I think I had a bit of cocci to do that... Yeah, it's there, and rerunning it does clean this up.

spatch is rather finicky and does occasionally miss entire files when you run it in the -dir mode. But in this case it clearly do something to the file, so not sure why the cleanup part didn't get done.

Quoted 5 lines
Quoted 2 lines
drivers/gpu/drm/drm_fb_helper.c +0 -0
 	fb_helper->funcs->gamma_set(crtc, red, green, blue, regno);

[snip]

Quoted 16 lines
Quoted 6 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_modeset_helper.c index e5d19e5fc341..3c44409244dc 100644

drivers/gpu/drm/drm_modeset_helper.c void drm_helper_mode_fill_fb_struct(struct drm_device · line 86

Quoted 8 lines
drivers/gpu/drm/drm_modeset_helper.c +0 -3
@@ -82,10 +82,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device
 *dev, DRM_DEBUG_KMS("non-RGB pixel format %s\n",
 		              drm_get_format_name(mode_cmd->pixel_format,
 		                                  &format_name));
-
-		fb->bits_per_pixel = 0;
 	} else {
-		fb->bits_per_pixel = info->cpp[0] * 8;
 	}

I think you can remove the whole check.

Not sure I can tell the tool that. Probably easier to remove it by hand afterwards.

Quoted 14 lines
Quoted 3 lines
drivers/gpu/drm/drm_modeset_helper.c +0 -0
 	fb->dev = dev;

[snip]

Quoted 8 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/radeon/atombios_crtc.c index 05f4ebe31ce2..8eeffc5324b2 100644

drivers/gpu/drm/radeon/atombios_crtc.c +0 -0
@@ -1277,7 +1277,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc
 *crtc,
 
Quoted 6 lines

drivers/gpu/drm/radeon/atombios_crtc.c static int dce4_crtc_do_set_base(struct drm_crtc *crtc, · line 1280

Quoted 4 lines
drivers/gpu/drm/radeon/atombios_crtc.c +1 -1
 				/* Calculate the macrotile mode index. */
 				tile_split_bytes = 64 << tile_split;
-				tileb = 8 * 8 * target_fb->bits_per_pixel / 8;
+				tileb = (8 * 8) * target_fb->format->cpp[0];

The parentheses are not needed.

Added by cocci. I guess I can tell it to clean that up, but have to double check that it won't accidentally clean up something else too which needs extra parens.

Quoted 15 lines

With these fixed,

Quoted 3 lines
drivers/gpu/drm/radeon/atombios_crtc.c +0 -0
 				tileb = min(tile_split_bytes, tileb);
 

for (index = 0; tileb > 64; index++)

[snip]

Signature · 3 lines
Regards,

Laurent Pinchart
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#47 lore raw

Re: [PATCH 31/32] drm: Nuke fb->bits_per_pixel

Hi Ville,

Quoted 114 lines · On Thursday 17 Nov 2016 20:35:46 Ville Syrjälä wrote:
Quoted 78 lines · Laurent Pinchart
Quoted 14 lines · On Thursday 17 Nov 2016 18:14:30 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Replace uses of fb->bits_per_pixel with fb->format->cpp[0]*8. Less duplicated information is a good thing.

Note that I didn't put parens around the cpp*8 in the below cocci script, on account of not wanting spurious parens all over the place. Instead I did the unsafe way, and tried to look over the entire diff to spot if any dangerous expressions were produced. I didn't see any.

There are some cases where previously the code did X*bpp/8, so the division happened after the multiplication. Those are now just X*cpp so the division effectively happens before the multiplication, but that is perfectly fine since bpp is always a multiple of 8.

[snip]

Quoted 48 lines

---

 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c        |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c        |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c         |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c         |  2 +-
 drivers/gpu/drm/armada/armada_crtc.c          |  4 ++--
 drivers/gpu/drm/armada/armada_fbdev.c         |  2 +-
 drivers/gpu/drm/ast/ast_fb.c                  |  2 +-
 drivers/gpu/drm/ast/ast_mode.c                |  9 +++++----
 drivers/gpu/drm/cirrus/cirrus_fbdev.c         |  2 +-
 drivers/gpu/drm/cirrus/cirrus_mode.c          |  2 +-
 drivers/gpu/drm/drm_fb_helper.c               |  8 ++++----
 drivers/gpu/drm/drm_framebuffer.c             |  2 +-
 drivers/gpu/drm/drm_modeset_helper.c          |  3 ---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c |  4 ++--
 drivers/gpu/drm/exynos/exynos7_drm_decon.c    |  6 +++---
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c     |  4 ++--
 drivers/gpu/drm/exynos/exynos_drm_fimd.c      |  2 +-
 drivers/gpu/drm/exynos/exynos_mixer.c         |  4 ++--
 drivers/gpu/drm/gma500/framebuffer.c          |  2 +-
 drivers/gpu/drm/gma500/gma_display.c          |  4 ++--
 drivers/gpu/drm/gma500/mdfld_intel_display.c  |  6 +++---
 drivers/gpu/drm/gma500/oaktrail_crtc.c        |  4 ++--
 drivers/gpu/drm/i915/i915_debugfs.c           |  4 ++--
 drivers/gpu/drm/i915/intel_display.c          | 11 ++++-------
 drivers/gpu/drm/i915/intel_fbdev.c            |  6 +++---
 drivers/gpu/drm/mgag200/mgag200_fb.c          |  2 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c        | 16 ++++++++--------
 drivers/gpu/drm/nouveau/dispnv04/crtc.c       |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_display.c     |  2 +-
 drivers/gpu/drm/qxl/qxl_draw.c                |  2 +-
 drivers/gpu/drm/radeon/atombios_crtc.c        | 11 ++++++-----
 drivers/gpu/drm/radeon/r100.c                 |  4 ++--
 drivers/gpu/drm/radeon/radeon_display.c       |  6 +++---
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c   | 14 +++++++-------
 drivers/gpu/drm/tegra/dc.c                    |  2 +-
 drivers/gpu/drm/tegra/drm.c                   |  2 +-
 drivers/gpu/drm/udl/udl_fb.c                  |  2 +-
 drivers/gpu/drm/virtio/virtgpu_fb.c           |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c            |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c           |  2 --
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c           |  4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c          |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c          |  2 +-
 include/drm/drm_framebuffer.h                 |  7 -------
 44 files changed, 89 insertions(+), 102 deletions(-)

[snip]

Quoted 9 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_fb_helper.c index 755e3b6e9710..bf5a06b7c0c1 100644

drivers/gpu/drm/drm_fb_helper.c +0 -0
@@ -1162,7 +1162,7 @@ static int setcolreg(struct drm_crtc *crtc, u16
 red, u16 green,
 		!fb_helper->funcs->gamma_get))
 
Quoted 6 lines

drivers/gpu/drm/drm_fb_helper.c static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green, · line 1165

Quoted 4 lines
drivers/gpu/drm/drm_fb_helper.c +1 -1
 		return -EINVAL;
 
-	WARN_ON(fb->bits_per_pixel != 8);
+	WARN_ON(fb->format->cpp[0] * 8 != 8);

Maybe just WARN_ON(fb->format->cpp[0] != 1); ?

I think I had a bit of cocci to do that... Yeah, it's there, and rerunning it does clean this up.

spatch is rather finicky and does occasionally miss entire files when you run it in the -dir mode. But in this case it clearly do something to the file, so not sure why the cleanup part didn't get done.

Quoted 4 lines
Quoted 1 line
drivers/gpu/drm/drm_fb_helper.c +0 -0
 	fb_helper->funcs->gamma_set(crtc, red, green, blue, regno);

[snip]

Quoted 16 lines
Quoted 6 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_modeset_helper.c index e5d19e5fc341..3c44409244dc 100644

drivers/gpu/drm/drm_modeset_helper.c void drm_helper_mode_fill_fb_struct(struct drm_device · line 86

Quoted 8 lines
drivers/gpu/drm/drm_modeset_helper.c +0 -3
@@ -82,10 +82,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device
 *dev, DRM_DEBUG_KMS("non-RGB pixel format %s\n",
 		              drm_get_format_name(mode_cmd->pixel_format,
 		                                  &format_name));
-
-		fb->bits_per_pixel = 0;
 	} else {
-		fb->bits_per_pixel = info->cpp[0] * 8;
 	}

I think you can remove the whole check.

Quoted 2 lines

Not sure I can tell the tool that. Probably easier to remove it by hand afterwards.

Fine with me, you can create a follow-up patch that manually fixes the left- overs.

Quoted 19 lines
Quoted 4 lines
Quoted 1 line
drivers/gpu/drm/drm_modeset_helper.c +0 -0
 	fb->dev = dev;

[snip]

Quoted 14 lines

drivers/gpu/drm/radeon/atombios_crtc.c static int dce4_crtc_do_set_base(struct drm_crtc · line 1280

Quoted 12 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/radeon/atombios_crtc.c index
05f4ebe31ce2..8eeffc5324b2
100644

drivers/gpu/drm/radeon/atombios_crtc.c +1 -1
@@ -1277,7 +1277,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc
 *crtc,
 				/* Calculate the macrotile mode index. */
 				tile_split_bytes = 64 << tile_split;
-				tileb = 8 * 8 * target_fb->bits_per_pixel / 8;
+				tileb = (8 * 8) * target_fb->format->cpp[0];

The parentheses are not needed.

Quoted 3 lines

Added by cocci. I guess I can tell it to clean that up, but have to double check that it won't accidentally clean up something else too which needs extra parens.

You can also fix it manually in a subsequent patch.

Quoted 9 lines
Quoted 9 lines

With these fixed,

Quoted 3 lines
drivers/gpu/drm/radeon/atombios_crtc.c +0 -0
 				tileb = min(tile_split_bytes, tileb);
 
 				for (index = 0; tileb > 64; index++)

[snip]

Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#48 lore raw

PATCH v2 31/32 drm: Nuke fb->bits_per_pixel

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Replace uses of fb->bits_per_pixel with fb->format->cpp[0]*8. Less duplicated information is a good thing.

Note that I didn't put parens around the cpp*8 in the below cocci script, on account of not wanting spurious parens all over the place. Instead I did the unsafe way, and tried to look over the entire diff to spot if any dangerous expressions were produced. I didn't see any.

There are some cases where previously the code did X*bpp/8, so the division happened after the multiplication. Those are now just X*cpp so the division effectively happens before the multiplication, but that is perfectly fine since bpp is always a multiple of 8.

@@
struct drm_framebuffer *fb;
expression E;
@@

 drm_helper_mode_fill_fb_struct(...) {
	...
-	fb->bits_per_pixel = E;
	...

}

@@
struct vmw_framebuffer_surface *vfb;
expression E;
@@
- vfb->base.base.bits_per_pixel = E;

@@
struct vmw_framebuffer_dmabuf *vfb;
expression E;
@@
- vfb->base.base.bits_per_pixel = E;

@@
struct drm_framebuffer *fb;
expression E;
@@

 i9xx_get_initial_plane_config(...) {
	...
-	fb->bits_per_pixel = E;
	...

}

@@
struct drm_framebuffer *fb;
expression E;
@@

 ironlake_get_initial_plane_config(...) {
	...
-	fb->bits_per_pixel = E;
	...

}

@@
struct drm_framebuffer *fb;
expression E;
@@

 skylake_get_initial_plane_config(...) {
	...
-	fb->bits_per_pixel = E;
	...

}

@@
struct drm_framebuffer fb;
expression E;
@@
(
- E * fb.bits_per_pixel / 8
+ E * fb.format->cpp[0]
|
- fb.bits_per_pixel / 8
+ fb.format->cpp[0]
|
- E * fb.bits_per_pixel >> 3
+ E * fb.format->cpp[0]
|
- fb.bits_per_pixel >> 3
+ fb.format->cpp[0]
|
- (fb.bits_per_pixel + 7) / 8
+ fb.format->cpp[0]
|
- fb.bits_per_pixel
+ fb.format->cpp[0] * 8
|
- fb.format->cpp[0] * 8 != 8
+ fb.format->cpp[0] != 1
)

@@
struct drm_framebuffer *fb;
expression E;
@@
(
- E * fb->bits_per_pixel / 8
+ E * fb->format->cpp[0]
|
- fb->bits_per_pixel / 8
+ fb->format->cpp[0]
|
- E * fb->bits_per_pixel >> 3
+ E * fb->format->cpp[0]
|
- fb->bits_per_pixel >> 3
+ fb->format->cpp[0]
|
- (fb->bits_per_pixel + 7) / 8
+ fb->format->cpp[0]
|
- fb->bits_per_pixel
+ fb->format->cpp[0] * 8
|
- fb->format->cpp[0] * 8 != 8
+ fb->format->cpp[0] != 1
)

@@
@@
- (8 * 8)
+ 8 * 8

@@
struct drm_framebuffer fb;
@@
- (fb.format->cpp[0])
+ fb.format->cpp[0]

@@
struct drm_framebuffer *fb;
@@
- (fb->format->cpp[0])
+ fb->format->cpp[0]

@@
@@

 struct drm_framebuffer {
	 ...
-	 int bits_per_pixel;
	 ...

};

v2: Clean up the 'cpp*8 != 8' and '(8 * 8)' cases (Laurent)

---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c        |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c        |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c         |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c         |  2 +-
 drivers/gpu/drm/armada/armada_crtc.c          |  4 ++--
 drivers/gpu/drm/armada/armada_fbdev.c         |  2 +-
 drivers/gpu/drm/ast/ast_fb.c                  |  2 +-
 drivers/gpu/drm/ast/ast_mode.c                |  9 +++++----
 drivers/gpu/drm/cirrus/cirrus_fbdev.c         |  2 +-
 drivers/gpu/drm/cirrus/cirrus_mode.c          |  2 +-
 drivers/gpu/drm/drm_fb_helper.c               |  8 ++++----
 drivers/gpu/drm/drm_framebuffer.c             |  2 +-
 drivers/gpu/drm/drm_modeset_helper.c          |  3 ---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c |  4 ++--
 drivers/gpu/drm/exynos/exynos7_drm_decon.c    |  6 +++---
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c     |  4 ++--
 drivers/gpu/drm/exynos/exynos_drm_fimd.c      |  2 +-
 drivers/gpu/drm/exynos/exynos_mixer.c         |  4 ++--
 drivers/gpu/drm/gma500/framebuffer.c          |  2 +-
 drivers/gpu/drm/gma500/gma_display.c          |  4 ++--
 drivers/gpu/drm/gma500/mdfld_intel_display.c  |  6 +++---
 drivers/gpu/drm/gma500/oaktrail_crtc.c        |  4 ++--
 drivers/gpu/drm/i915/i915_debugfs.c           |  4 ++--
 drivers/gpu/drm/i915/intel_display.c          | 11 ++++-------
 drivers/gpu/drm/i915/intel_fbdev.c            |  6 +++---
 drivers/gpu/drm/mgag200/mgag200_fb.c          |  2 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c        | 16 ++++++++--------
 drivers/gpu/drm/nouveau/dispnv04/crtc.c       |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_display.c     |  2 +-
 drivers/gpu/drm/qxl/qxl_draw.c                |  2 +-
 drivers/gpu/drm/radeon/atombios_crtc.c        | 11 ++++++-----
 drivers/gpu/drm/radeon/r100.c                 |  4 ++--
 drivers/gpu/drm/radeon/radeon_display.c       |  6 +++---
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c   | 14 +++++++-------
 drivers/gpu/drm/tegra/dc.c                    |  2 +-
 drivers/gpu/drm/tegra/drm.c                   |  2 +-
 drivers/gpu/drm/udl/udl_fb.c                  |  2 +-
 drivers/gpu/drm/virtio/virtgpu_fb.c           |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c            |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c           |  2 --
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c           |  4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c          |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c          |  2 +-
 include/drm/drm_framebuffer.h                 |  7 -------
 44 files changed, 89 insertions(+), 102 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +1 -1
index 65a954cb69ed..9c8f33780257 100644
@@ -2220,7 +2220,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(mmGRPH_X_END + amdgpu_crtc->crtc_offset, target_fb->width);
 	WREG32(mmGRPH_Y_END + amdgpu_crtc->crtc_offset, target_fb->height);
 
-	fb_pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
+	fb_pitch_pixels = target_fb->pitches[0] / target_fb->format->cpp[0];
 	WREG32(mmGRPH_PITCH + amdgpu_crtc->crtc_offset, fb_pitch_pixels);
 
 	dce_v10_0_grph_enable(crtc, true);
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +1 -1
index d807e876366b..72ba3a50452b 100644
@@ -2201,7 +2201,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(mmGRPH_X_END + amdgpu_crtc->crtc_offset, target_fb->width);
 	WREG32(mmGRPH_Y_END + amdgpu_crtc->crtc_offset, target_fb->height);
 
-	fb_pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
+	fb_pitch_pixels = target_fb->pitches[0] / target_fb->format->cpp[0];
 	WREG32(mmGRPH_PITCH + amdgpu_crtc->crtc_offset, fb_pitch_pixels);
 
 	dce_v11_0_grph_enable(crtc, true);
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +1 -1
index bc9f2f423270..aa64d9c1a8c8 100644
@@ -1623,7 +1623,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(EVERGREEN_GRPH_X_END + amdgpu_crtc->crtc_offset, target_fb->width);
 	WREG32(EVERGREEN_GRPH_Y_END + amdgpu_crtc->crtc_offset, target_fb->height);
 
-	fb_pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
+	fb_pitch_pixels = target_fb->pitches[0] / target_fb->format->cpp[0];
 	WREG32(EVERGREEN_GRPH_PITCH + amdgpu_crtc->crtc_offset, fb_pitch_pixels);
 
 	dce_v6_0_grph_enable(crtc, true);
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +1 -1
index 4ae59914bc32..ecf6c68b8f43 100644
@@ -2079,7 +2079,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(mmGRPH_X_END + amdgpu_crtc->crtc_offset, target_fb->width);
 	WREG32(mmGRPH_Y_END + amdgpu_crtc->crtc_offset, target_fb->height);
 
-	fb_pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
+	fb_pitch_pixels = target_fb->pitches[0] / target_fb->format->cpp[0];
 	WREG32(mmGRPH_PITCH + amdgpu_crtc->crtc_offset, fb_pitch_pixels);
 
 	dce_v8_0_grph_enable(crtc, true);
drivers/gpu/drm/armada/armada_crtc.c +2 -2
index a51f8cbcfe26..c69a5ea54f23 100644
@@ -169,12 +169,12 @@ static unsigned armada_drm_crtc_calc_fb(struct drm_framebuffer *fb,
 {
 	struct armada_gem_object *obj = drm_fb_obj(fb);
 	unsigned pitch = fb->pitches[0];
-	unsigned offset = y * pitch + x * fb->bits_per_pixel / 8;
+	unsigned offset = y * pitch + x * fb->format->cpp[0];
 	uint32_t addr_odd, addr_even;
 	unsigned i = 0;
 
 	DRM_DEBUG_DRIVER("pitch %u x %d y %d bpp %d\n",
-		pitch, x, y, fb->bits_per_pixel);
+		pitch, x, y, fb->format->cpp[0] * 8);
 
 	addr_odd = addr_even = obj->dev_addr + offset;
 
drivers/gpu/drm/armada/armada_fbdev.c +1 -1
index 3a58fb600b05..78335100cbc3 100644
@@ -94,7 +94,7 @@ static int armada_fb_create(struct drm_fb_helper *fbh,
 	drm_fb_helper_fill_var(info, fbh, sizes->fb_width, sizes->fb_height);
 
 	DRM_DEBUG_KMS("allocated %dx%d %dbpp fb: 0x%08llx\n",
-		dfb->fb.width, dfb->fb.height, dfb->fb.bits_per_pixel,
+		dfb->fb.width, dfb->fb.height, dfb->fb.format->cpp[0] * 8,
 		(unsigned long long)obj->phys_addr);
 
 	return 0;
drivers/gpu/drm/ast/ast_fb.c +1 -1
index f751792a3c7c..b085140fae95 100644
@@ -49,7 +49,7 @@ static void ast_dirty_update(struct ast_fbdev *afbdev,
 	struct drm_gem_object *obj;
 	struct ast_bo *bo;
 	int src_offset, dst_offset;
-	int bpp = (afbdev->afb.base.bits_per_pixel + 7)/8;
+	int bpp = afbdev->afb.base.format->cpp[0];
 	int ret = -EBUSY;
 	bool unmap = false;
 	bool store_for_later = false;
drivers/gpu/drm/ast/ast_mode.c +5 -4
index deb3684ccaf8..0cf5e0ab5015 100644
@@ -85,7 +85,7 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo
 	bool check_sync;
 	struct ast_vbios_enhtable *best = NULL;
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		vbios_mode->std_table = &vbios_stdtable[VGAModeIndex];
 		color_index = VGAModeIndex - 1;
@@ -208,7 +208,8 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo
 		ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x91, 0x00);
 		if (vbios_mode->enh_table->flags & NewModeInfo) {
 			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x91, 0xa8);
-			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x92, fb->bits_per_pixel);
+			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x92,
+					  fb->format->cpp[0] * 8);
 			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x93, adjusted_mode->clock / 1000);
 			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x94, adjusted_mode->crtc_hdisplay);
 			ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x95, adjusted_mode->crtc_hdisplay >> 8);
@@ -400,7 +401,7 @@ static void ast_set_ext_reg(struct drm_crtc *crtc, struct drm_display_mode *mode
 	const struct drm_framebuffer *fb = crtc->primary->fb;
 	u8 jregA0 = 0, jregA3 = 0, jregA8 = 0;
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		jregA0 = 0x70;
 		jregA3 = 0x01;
@@ -457,7 +458,7 @@ static bool ast_set_dac_reg(struct drm_crtc *crtc, struct drm_display_mode *mode
 {
 	const struct drm_framebuffer *fb = crtc->primary->fb;
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		break;
 	default:
drivers/gpu/drm/cirrus/cirrus_fbdev.c +1 -1
index 3cac8a03cf4f..79a5cd108245 100644
@@ -22,7 +22,7 @@ static void cirrus_dirty_update(struct cirrus_fbdev *afbdev,
 	struct drm_gem_object *obj;
 	struct cirrus_bo *bo;
 	int src_offset, dst_offset;
-	int bpp = (afbdev->gfb.base.bits_per_pixel + 7)/8;
+	int bpp = afbdev->gfb.base.format->cpp[0];
 	int ret = -EBUSY;
 	bool unmap = false;
 	bool store_for_later = false;
drivers/gpu/drm/cirrus/cirrus_mode.c +1 -1
index f2297acae235..e78a7a295cef 100644
@@ -258,7 +258,7 @@ static int cirrus_crtc_mode_set(struct drm_crtc *crtc,
 	sr07 = RREG8(SEQ_DATA);
 	sr07 &= 0xe0;
 	hdr = 0;
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		sr07 |= 0x11;
 		break;
drivers/gpu/drm/drm_fb_helper.c +4 -4
index 755e3b6e9710..01e6ddf6680f 100644
@@ -1162,7 +1162,7 @@ static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 		    !fb_helper->funcs->gamma_get))
 		return -EINVAL;
 
-	WARN_ON(fb->bits_per_pixel != 8);
+	WARN_ON(fb->format->cpp[0] != 1);
 
 	fb_helper->funcs->gamma_set(crtc, red, green, blue, regno);
 
@@ -1245,14 +1245,14 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
 	 * Changes struct fb_var_screeninfo are currently not pushed back
 	 * to KMS, hence fail if different settings are requested.
 	 */
-	if (var->bits_per_pixel != fb->bits_per_pixel ||
+	if (var->bits_per_pixel != fb->format->cpp[0] * 8 ||
 	    var->xres != fb->width || var->yres != fb->height ||
 	    var->xres_virtual != fb->width || var->yres_virtual != fb->height) {
 		DRM_DEBUG("fb userspace requested width/height/bpp different than current fb "
 			  "request %dx%d-%d (virtual %dx%d) > %dx%d-%d\n",
 			  var->xres, var->yres, var->bits_per_pixel,
 			  var->xres_virtual, var->yres_virtual,
-			  fb->width, fb->height, fb->bits_per_pixel);
+			  fb->width, fb->height, fb->format->cpp[0] * 8);
 		return -EINVAL;
 	}
 
@@ -1655,7 +1655,7 @@ void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helpe
 	info->pseudo_palette = fb_helper->pseudo_palette;
 	info->var.xres_virtual = fb->width;
 	info->var.yres_virtual = fb->height;
-	info->var.bits_per_pixel = fb->bits_per_pixel;
+	info->var.bits_per_pixel = fb->format->cpp[0] * 8;
 	info->var.accel_flags = FB_ACCELF_TEXT;
 	info->var.xoffset = 0;
 	info->var.yoffset = 0;
drivers/gpu/drm/drm_framebuffer.c +1 -1
index 00def930b6a5..98c054098808 100644
@@ -433,7 +433,7 @@ int drm_mode_getfb(struct drm_device *dev,
 	r->height = fb->height;
 	r->width = fb->width;
 	r->depth = fb->format->depth;
-	r->bpp = fb->bits_per_pixel;
+	r->bpp = fb->format->cpp[0] * 8;
 	r->pitch = fb->pitches[0];
 	if (fb->funcs->create_handle) {
 		if (drm_is_current_master(file_priv) || capable(CAP_SYS_ADMIN) ||
drivers/gpu/drm/drm_modeset_helper.c +0 -3
index e5d19e5fc341..3c44409244dc 100644
@@ -82,10 +82,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
 		DRM_DEBUG_KMS("non-RGB pixel format %s\n",
 		              drm_get_format_name(mode_cmd->pixel_format,
 		                                  &format_name));
-
-		fb->bits_per_pixel = 0;
 	} else {
-		fb->bits_per_pixel = info->cpp[0] * 8;
 	}
 
 	fb->dev = dev;
drivers/gpu/drm/exynos/exynos5433_drm_decon.c +2 -2
index 6ca1f3117fe8..e8ce4a318586 100644
@@ -226,7 +226,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
 		return;
 	}
 
-	DRM_DEBUG_KMS("bpp = %u\n", fb->bits_per_pixel);
+	DRM_DEBUG_KMS("bpp = %u\n", fb->format->cpp[0] * 8);
 
 	/*
 	 * In case of exynos, setting dma-burst to 16Word causes permanent
@@ -275,7 +275,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
 	struct decon_context *ctx = crtc->ctx;
 	struct drm_framebuffer *fb = state->base.fb;
 	unsigned int win = plane->index;
-	unsigned int bpp = fb->bits_per_pixel >> 3;
+	unsigned int bpp = fb->format->cpp[0];
 	unsigned int pitch = fb->pitches[0];
 	dma_addr_t dma_addr = exynos_drm_fb_dma_addr(fb, 0);
 	u32 val;
drivers/gpu/drm/exynos/exynos7_drm_decon.c +3 -3
index f4d5a2133777..58dc9a5196bc 100644
@@ -330,7 +330,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
 		break;
 	}
 
-	DRM_DEBUG_KMS("bpp = %d\n", fb->bits_per_pixel);
+	DRM_DEBUG_KMS("bpp = %d\n", fb->format->cpp[0] * 8);
 
 	/*
 	 * In case of exynos, setting dma-burst to 16Word causes permanent
@@ -340,7 +340,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
 	 * movement causes unstable DMA which results into iommu crash/tear.
 	 */
 
-	padding = (fb->pitches[0] / (fb->bits_per_pixel >> 3)) - fb->width;
+	padding = (fb->pitches[0] / fb->format->cpp[0]) - fb->width;
 	if (fb->width + padding < MIN_FB_WIDTH_FOR_16WORD_BURST) {
 		val &= ~WINCONx_BURSTLEN_MASK;
 		val |= WINCONx_BURSTLEN_8WORD;
@@ -407,7 +407,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
 	unsigned int last_x;
 	unsigned int last_y;
 	unsigned int win = plane->index;
-	unsigned int bpp = fb->bits_per_pixel >> 3;
+	unsigned int bpp = fb->format->cpp[0];
 	unsigned int pitch = fb->pitches[0];
 
 	if (ctx->suspended)
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +2 -2
index e68a46f112f6..d8808158d418 100644
@@ -76,7 +76,7 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
 {
 	struct fb_info *fbi;
 	struct drm_framebuffer *fb = helper->fb;
-	unsigned int size = fb->width * fb->height * (fb->bits_per_pixel >> 3);
+	unsigned int size = fb->width * fb->height * fb->format->cpp[0];
 	unsigned int nr_pages;
 	unsigned long offset;
 
@@ -103,7 +103,7 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
 		return -EIO;
 	}
 
-	offset = fbi->var.xoffset * (fb->bits_per_pixel >> 3);
+	offset = fbi->var.xoffset * fb->format->cpp[0];
 	offset += fbi->var.yoffset * fb->pitches[0];
 
 	fbi->screen_base = exynos_gem->kvaddr + offset;
drivers/gpu/drm/exynos/exynos_drm_fimd.c +1 -1
index e2e405170d35..0029065979b8 100644
@@ -738,7 +738,7 @@ static void fimd_update_plane(struct exynos_drm_crtc *crtc,
 	unsigned long val, size, offset;
 	unsigned int last_x, last_y, buf_offsize, line_size;
 	unsigned int win = plane->index;
-	unsigned int bpp = fb->bits_per_pixel >> 3;
+	unsigned int bpp = fb->format->cpp[0];
 	unsigned int pitch = fb->pitches[0];
 
 	if (ctx->suspended)
drivers/gpu/drm/exynos/exynos_mixer.c +2 -2
index edb20a34c66c..b313e61aab65 100644
@@ -631,7 +631,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
 
 	/* converting dma address base and source offset */
 	dma_addr = exynos_drm_fb_dma_addr(fb, 0)
-		+ (state->src.x * fb->bits_per_pixel >> 3)
+		+ (state->src.x * fb->format->cpp[0])
 		+ (state->src.y * fb->pitches[0]);
 	src_x_offset = 0;
 	src_y_offset = 0;
@@ -649,7 +649,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
 
 	/* setup geometry */
 	mixer_reg_write(res, MXR_GRAPHIC_SPAN(win),
-			fb->pitches[0] / (fb->bits_per_pixel >> 3));
+			fb->pitches[0] / fb->format->cpp[0]);
 
 	/* setup display size */
 	if (ctx->mxr_ver == MXR_VER_128_0_0_184 &&
drivers/gpu/drm/gma500/framebuffer.c +1 -1
index a93b59ce6b41..6bf33ba055b3 100644
@@ -77,7 +77,7 @@ static int psbfb_setcolreg(unsigned regno, unsigned red, unsigned green,
 	    (transp << info->var.transp.offset);
 
 	if (regno < 16) {
-		switch (fb->bits_per_pixel) {
+		switch (fb->format->cpp[0] * 8) {
 		case 16:
 			((uint32_t *) info->pseudo_palette)[regno] = v;
 			break;
drivers/gpu/drm/gma500/gma_display.c +2 -2
index 5b852ad152ae..d1c5642b1c1e 100644
@@ -82,14 +82,14 @@ int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 	if (ret < 0)
 		goto gma_pipe_set_base_exit;
 	start = psbfb->gtt->offset;
-	offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
+	offset = y * fb->pitches[0] + x * fb->format->cpp[0];
 
 	REG_WRITE(map->stride, fb->pitches[0]);
 
 	dspcntr = REG_READ(map->cntr);
 	dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		dspcntr |= DISPPLANE_8BPP;
 		break;
drivers/gpu/drm/gma500/mdfld_intel_display.c +3 -3
index 3be3111825cd..63c6e08600ae 100644
@@ -148,7 +148,7 @@ static int check_fb(struct drm_framebuffer *fb)
 	if (!fb)
 		return 0;
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 	case 16:
 	case 24:
@@ -197,13 +197,13 @@ static int mdfld__intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 		return 0;
 
 	start = psbfb->gtt->offset;
-	offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
+	offset = y * fb->pitches[0] + x * fb->format->cpp[0];
 
 	REG_WRITE(map->stride, fb->pitches[0]);
 	dspcntr = REG_READ(map->cntr);
 	dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		dspcntr |= DISPPLANE_8BPP;
 		break;
drivers/gpu/drm/gma500/oaktrail_crtc.c +2 -2
index 569810d47786..0fff269d3fe6 100644
@@ -618,14 +618,14 @@ static int oaktrail_pipe_set_base(struct drm_crtc *crtc,
 		return 0;
 
 	start = psbfb->gtt->offset;
-	offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
+	offset = y * fb->pitches[0] + x * fb->format->cpp[0];
 
 	REG_WRITE(map->stride, fb->pitches[0]);
 
 	dspcntr = REG_READ(map->cntr);
 	dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		dspcntr |= DISPPLANE_8BPP;
 		break;
drivers/gpu/drm/i915/i915_debugfs.c +2 -2
index ebcba97616ab..ee272ec8732c 100644
@@ -1895,7 +1895,7 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
 			   fbdev_fb->base.width,
 			   fbdev_fb->base.height,
 			   fbdev_fb->base.format->depth,
-			   fbdev_fb->base.bits_per_pixel,
+			   fbdev_fb->base.format->cpp[0] * 8,
 			   fbdev_fb->base.modifier,
 			   drm_framebuffer_read_refcount(&fbdev_fb->base));
 		describe_obj(m, fbdev_fb->obj);
@@ -1913,7 +1913,7 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
 			   fb->base.width,
 			   fb->base.height,
 			   fb->base.format->depth,
-			   fb->base.bits_per_pixel,
+			   fb->base.format->cpp[0] * 8,
 			   fb->base.modifier,
 			   drm_framebuffer_read_refcount(&fb->base));
 		describe_obj(m, fb->obj);
drivers/gpu/drm/i915/intel_display.c +4 -7
index 5d8db436c557..6c889f0e8e0f 100644
@@ -8715,7 +8715,6 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
 	pixel_format = val & DISPPLANE_PIXFORMAT_MASK;
 	fourcc = i9xx_format_to_fourcc(pixel_format);
 	fb->pixel_format = fourcc;
-	fb->bits_per_pixel = drm_format_plane_cpp(fourcc, 0) * 8;
 	fb->format = drm_format_info(fourcc);
 
 	if (INTEL_GEN(dev_priv) >= 4) {
@@ -8744,7 +8743,7 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
 
 	DRM_DEBUG_KMS("pipe/plane %c/%d with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
 		      pipe_name(pipe), plane, fb->width, fb->height,
-		      fb->bits_per_pixel, base, fb->pitches[0],
+		      fb->format->cpp[0] * 8, base, fb->pitches[0],
 		      plane_config->size);
 
 	plane_config->fb = intel_fb;
@@ -9747,7 +9746,6 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
 				      val & PLANE_CTL_ORDER_RGBX,
 				      val & PLANE_CTL_ALPHA_MASK);
 	fb->pixel_format = fourcc;
-	fb->bits_per_pixel = drm_format_plane_cpp(fourcc, 0) * 8;
 	fb->format = drm_format_info(fourcc);
 
 	tiling = val & PLANE_CTL_TILED_MASK;
@@ -9792,7 +9790,7 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
 
 	DRM_DEBUG_KMS("pipe %c with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
 		      pipe_name(pipe), fb->width, fb->height,
-		      fb->bits_per_pixel, base, fb->pitches[0],
+		      fb->format->cpp[0] * 8, base, fb->pitches[0],
 		      plane_config->size);
 
 	plane_config->fb = intel_fb;
@@ -9863,7 +9861,6 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
 	pixel_format = val & DISPPLANE_PIXFORMAT_MASK;
 	fourcc = i9xx_format_to_fourcc(pixel_format);
 	fb->pixel_format = fourcc;
-	fb->bits_per_pixel = drm_format_plane_cpp(fourcc, 0) * 8;
 	fb->format = drm_format_info(fourcc);
 
 	base = I915_READ(DSPSURF(pipe)) & 0xfffff000;
@@ -9892,7 +9889,7 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
 
 	DRM_DEBUG_KMS("pipe %c with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
 		      pipe_name(pipe), fb->width, fb->height,
-		      fb->bits_per_pixel, base, fb->pitches[0],
+		      fb->format->cpp[0] * 8, base, fb->pitches[0],
 		      plane_config->size);
 
 	plane_config->fb = intel_fb;
@@ -11051,7 +11048,7 @@ mode_fits_in_fbdev(struct drm_device *dev,
 
 	fb = &dev_priv->fbdev->fb->base;
 	if (fb->pitches[0] < intel_framebuffer_pitch_for_width(mode->hdisplay,
-							       fb->bits_per_pixel))
+							       fb->format->cpp[0] * 8))
 		return NULL;
 
 	if (obj->base.size < mode->vdisplay * fb->pitches[0])
drivers/gpu/drm/i915/intel_fbdev.c +3 -3
index b726483a460d..3f60a4f6f078 100644
@@ -621,7 +621,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 		 * rather than the current pipe's, since they differ.
 		 */
 		cur_size = intel_crtc->config->base.adjusted_mode.crtc_hdisplay;
-		cur_size = cur_size * fb->base.bits_per_pixel / 8;
+		cur_size = cur_size * fb->base.format->cpp[0];
 		if (fb->base.pitches[0] < cur_size) {
 			DRM_DEBUG_KMS("fb not wide enough for plane %c (%d vs %d)\n",
 				      pipe_name(intel_crtc->pipe),
@@ -639,7 +639,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 			      pipe_name(intel_crtc->pipe),
 			      intel_crtc->config->base.adjusted_mode.crtc_hdisplay,
 			      intel_crtc->config->base.adjusted_mode.crtc_vdisplay,
-			      fb->base.bits_per_pixel,
+			      fb->base.format->cpp[0] * 8,
 			      cur_size);
 
 		if (cur_size > max_size) {
@@ -660,7 +660,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 		goto out;
 	}
 
-	ifbdev->preferred_bpp = fb->base.bits_per_pixel;
+	ifbdev->preferred_bpp = fb->base.format->cpp[0] * 8;
 	ifbdev->fb = fb;
 
 	drm_framebuffer_reference(&ifbdev->fb->base);
drivers/gpu/drm/mgag200/mgag200_fb.c +1 -1
index 19a78b6b5a1a..1a665e1671b8 100644
@@ -24,7 +24,7 @@ static void mga_dirty_update(struct mga_fbdev *mfbdev,
 	struct drm_gem_object *obj;
 	struct mgag200_bo *bo;
 	int src_offset, dst_offset;
-	int bpp = (mfbdev->mfb.base.bits_per_pixel + 7)/8;
+	int bpp = mfbdev->mfb.base.format->cpp[0];
 	int ret = -EBUSY;
 	bool unmap = false;
 	bool store_for_later = false;
drivers/gpu/drm/mgag200/mgag200_mode.c +8 -8
index 3180db5e81cb..1e039cfddedf 100644
@@ -38,7 +38,7 @@ static void mga_crtc_load_lut(struct drm_crtc *crtc)
 
 	WREG8(DAC_INDEX + MGA1064_INDEX, 0);
 
-	if (fb && fb->bits_per_pixel == 16) {
+	if (fb && fb->format->cpp[0] * 8 == 16) {
 		int inc = (fb->format->depth == 15) ? 8 : 4;
 		u8 r, b;
 		for (i = 0; i < MGAG200_LUT_SIZE; i += inc) {
@@ -903,7 +903,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 		/* 0x48: */        0,    0,    0,    0,    0,    0,    0,    0
 	};
 
-	bppshift = mdev->bpp_shifts[(fb->bits_per_pixel >> 3) - 1];
+	bppshift = mdev->bpp_shifts[fb->format->cpp[0] - 1];
 
 	switch (mdev->type) {
 	case G200_SE_A:
@@ -942,7 +942,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 		break;
 	}
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		dacvalue[MGA1064_MUL_CTL] = MGA1064_MUL_CTL_8bits;
 		break;
@@ -998,8 +998,8 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 	WREG_SEQ(3, 0);
 	WREG_SEQ(4, 0xe);
 
-	pitch = fb->pitches[0] / (fb->bits_per_pixel / 8);
-	if (fb->bits_per_pixel == 24)
+	pitch = fb->pitches[0] / fb->format->cpp[0];
+	if (fb->format->cpp[0] * 8 == 24)
 		pitch = (pitch * 3) >> (4 - bppshift);
 	else
 		pitch = pitch >> (4 - bppshift);
@@ -1076,7 +1076,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 		((vdisplay & 0xc00) >> 7) |
 		((vsyncstart & 0xc00) >> 5) |
 		((vdisplay & 0x400) >> 3);
-	if (fb->bits_per_pixel == 24)
+	if (fb->format->cpp[0] * 8 == 24)
 		ext_vga[3] = (((1 << bppshift) * 3) - 1) | 0x80;
 	else
 		ext_vga[3] = ((1 << bppshift) - 1) | 0x80;
@@ -1139,9 +1139,9 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 			u32 bpp;
 			u32 mb;
 
-			if (fb->bits_per_pixel > 16)
+			if (fb->format->cpp[0] * 8 > 16)
 				bpp = 32;
-			else if (fb->bits_per_pixel > 8)
+			else if (fb->format->cpp[0] * 8 > 8)
 				bpp = 16;
 			else
 				bpp = 8;
drivers/gpu/drm/nouveau/dispnv04/crtc.c +2 -2
index 480e3ab477fd..a72754d73c84 100644
@@ -874,11 +874,11 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc,
 
 	/* Update the framebuffer location. */
 	regp->fb_start = nv_crtc->fb.offset & ~3;
-	regp->fb_start += (y * drm_fb->pitches[0]) + (x * drm_fb->bits_per_pixel / 8);
+	regp->fb_start += (y * drm_fb->pitches[0]) + (x * drm_fb->format->cpp[0]);
 	nv_set_crtc_base(dev, nv_crtc->index, regp->fb_start);
 
 	/* Update the arbitration parameters. */
-	nouveau_calc_arb(dev, crtc->mode.clock, drm_fb->bits_per_pixel,
+	nouveau_calc_arb(dev, crtc->mode.clock, drm_fb->format->cpp[0] * 8,
 			 &arb_burst, &arb_lwm);
 
 	regp->CRTC[NV_CIO_CRE_FF_INDEX] = arb_burst;
drivers/gpu/drm/nouveau/nouveau_display.c +1 -1
index a46d893aaafa..317ac38fc613 100644
@@ -888,7 +888,7 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 
 	/* Initialize a page flip struct */
 	*s = (struct nouveau_page_flip_state)
-		{ { }, event, crtc, fb->bits_per_pixel, fb->pitches[0],
+		{ { }, event, crtc, fb->format->cpp[0] * 8, fb->pitches[0],
 		  new_bo->bo.offset };
 
 	/* Keep vblanks on during flip, for the target crtc of this flip */
drivers/gpu/drm/qxl/qxl_draw.c +1 -1
index 9b728edf1b49..4d8681e84e68 100644
@@ -283,7 +283,7 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,
 	struct qxl_rect *rects;
 	int stride = qxl_fb->base.pitches[0];
 	/* depth is not actually interesting, we don't mask with it */
-	int depth = qxl_fb->base.bits_per_pixel;
+	int depth = qxl_fb->base.format->cpp[0] * 8;
 	uint8_t *surface_base;
 	struct qxl_release *release;
 	struct qxl_bo *clips_bo;
drivers/gpu/drm/radeon/atombios_crtc.c +6 -5
index 05f4ebe31ce2..0d7f84f7d71d 100644
@@ -1277,7 +1277,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 
 				/* Calculate the macrotile mode index. */
 				tile_split_bytes = 64 << tile_split;
-				tileb = 8 * 8 * target_fb->bits_per_pixel / 8;
+				tileb = 8 * 8 * target_fb->format->cpp[0];
 				tileb = min(tile_split_bytes, tileb);
 
 				for (index = 0; tileb > 64; index++)
@@ -1285,13 +1285,14 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 
 				if (index >= 16) {
 					DRM_ERROR("Wrong screen bpp (%u) or tile split (%u)\n",
-						  target_fb->bits_per_pixel, tile_split);
+						  target_fb->format->cpp[0] * 8,
+						  tile_split);
 					return -EINVAL;
 				}
 
 				num_banks = (rdev->config.cik.macrotile_mode_array[index] >> 6) & 0x3;
 			} else {
-				switch (target_fb->bits_per_pixel) {
+				switch (target_fb->format->cpp[0] * 8) {
 				case 8:
 					index = 10;
 					break;
@@ -1414,7 +1415,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(EVERGREEN_GRPH_X_END + radeon_crtc->crtc_offset, target_fb->width);
 	WREG32(EVERGREEN_GRPH_Y_END + radeon_crtc->crtc_offset, target_fb->height);
 
-	fb_pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
+	fb_pitch_pixels = target_fb->pitches[0] / target_fb->format->cpp[0];
 	WREG32(EVERGREEN_GRPH_PITCH + radeon_crtc->crtc_offset, fb_pitch_pixels);
 	WREG32(EVERGREEN_GRPH_ENABLE + radeon_crtc->crtc_offset, 1);
 
@@ -1621,7 +1622,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
 	WREG32(AVIVO_D1GRPH_X_END + radeon_crtc->crtc_offset, target_fb->width);
 	WREG32(AVIVO_D1GRPH_Y_END + radeon_crtc->crtc_offset, target_fb->height);
 
-	fb_pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
+	fb_pitch_pixels = target_fb->pitches[0] / target_fb->format->cpp[0];
 	WREG32(AVIVO_D1GRPH_PITCH + radeon_crtc->crtc_offset, fb_pitch_pixels);
 	WREG32(AVIVO_D1GRPH_ENABLE + radeon_crtc->crtc_offset, 1);
 
drivers/gpu/drm/radeon/r100.c +2 -2
index 984b35f43554..e3399310d41d 100644
@@ -3229,7 +3229,7 @@ void r100_bandwidth_update(struct radeon_device *rdev)
 			rdev->mode_info.crtcs[0]->base.primary->fb;
 
 		mode1 = &rdev->mode_info.crtcs[0]->base.mode;
-		pixel_bytes1 = fb->bits_per_pixel / 8;
+		pixel_bytes1 = fb->format->cpp[0];
 	}
 	if (!(rdev->flags & RADEON_SINGLE_CRTC)) {
 		if (rdev->mode_info.crtcs[1]->base.enabled) {
@@ -3237,7 +3237,7 @@ void r100_bandwidth_update(struct radeon_device *rdev)
 				rdev->mode_info.crtcs[1]->base.primary->fb;
 
 			mode2 = &rdev->mode_info.crtcs[1]->base.mode;
-			pixel_bytes2 = fb->bits_per_pixel / 8;
+			pixel_bytes2 = fb->format->cpp[0];
 		}
 	}
 
drivers/gpu/drm/radeon/radeon_display.c +3 -3
index 6285355eb5d5..aea8b62835a4 100644
@@ -549,19 +549,19 @@ static int radeon_crtc_page_flip_target(struct drm_crtc *crtc,
 	if (!ASIC_IS_AVIVO(rdev)) {
 		/* crtc offset is from display base addr not FB location */
 		base -= radeon_crtc->legacy_display_base_addr;
-		pitch_pixels = fb->pitches[0] / (fb->bits_per_pixel / 8);
+		pitch_pixels = fb->pitches[0] / fb->format->cpp[0];
 
 		if (tiling_flags & RADEON_TILING_MACRO) {
 			if (ASIC_IS_R300(rdev)) {
 				base &= ~0x7ff;
 			} else {
-				int byteshift = fb->bits_per_pixel >> 4;
+				int byteshift = fb->format->cpp[0] * 8 >> 4;
 				int tile_addr = (((crtc->y >> 3) * pitch_pixels +  crtc->x) >> (8 - byteshift)) << 11;
 				base += tile_addr + ((crtc->x << byteshift) % 256) + ((crtc->y % 8) << 8);
 			}
 		} else {
 			int offset = crtc->y * pitch_pixels + crtc->x;
-			switch (fb->bits_per_pixel) {
+			switch (fb->format->cpp[0] * 8) {
 			case 8:
 			default:
 				offset *= 1;
drivers/gpu/drm/radeon/radeon_legacy_crtc.c +7 -7
index 31c03e32a6b5..ce6cb6666212 100644
@@ -402,7 +402,7 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
 		target_fb = crtc->primary->fb;
 	}
 
-	switch (target_fb->bits_per_pixel) {
+	switch (target_fb->format->cpp[0] * 8) {
 	case 8:
 		format = 2;
 		break;
@@ -476,9 +476,9 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
 
 	crtc_offset_cntl = 0;
 
-	pitch_pixels = target_fb->pitches[0] / (target_fb->bits_per_pixel / 8);
-	crtc_pitch = DIV_ROUND_UP(pitch_pixels * target_fb->bits_per_pixel,
-				  target_fb->bits_per_pixel * 8);
+	pitch_pixels = target_fb->pitches[0] / target_fb->format->cpp[0];
+	crtc_pitch = DIV_ROUND_UP(pitch_pixels * target_fb->format->cpp[0] * 8,
+				  target_fb->format->cpp[0] * 8 * 8);
 	crtc_pitch |= crtc_pitch << 16;
 
 	crtc_offset_cntl |= RADEON_CRTC_GUI_TRIG_OFFSET_LEFT_EN;
@@ -503,14 +503,14 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
 			crtc_tile_x0_y0 = x | (y << 16);
 			base &= ~0x7ff;
 		} else {
-			int byteshift = target_fb->bits_per_pixel >> 4;
+			int byteshift = target_fb->format->cpp[0] * 8 >> 4;
 			int tile_addr = (((y >> 3) * pitch_pixels +  x) >> (8 - byteshift)) << 11;
 			base += tile_addr + ((x << byteshift) % 256) + ((y % 8) << 8);
 			crtc_offset_cntl |= (y % 16);
 		}
 	} else {
 		int offset = y * pitch_pixels + x;
-		switch (target_fb->bits_per_pixel) {
+		switch (target_fb->format->cpp[0] * 8) {
 		case 8:
 			offset *= 1;
 			break;
@@ -602,7 +602,7 @@ static bool radeon_set_crtc_timing(struct drm_crtc *crtc, struct drm_display_mod
 		}
 	}
 
-	switch (fb->bits_per_pixel) {
+	switch (fb->format->cpp[0] * 8) {
 	case 8:
 		format = 2;
 		break;
drivers/gpu/drm/tegra/dc.c +1 -1
index 4010d69cbd08..3af157a2d40c 100644
@@ -568,7 +568,7 @@ static void tegra_plane_atomic_update(struct drm_plane *plane,
 	window.dst.y = plane->state->crtc_y;
 	window.dst.w = plane->state->crtc_w;
 	window.dst.h = plane->state->crtc_h;
-	window.bits_per_pixel = fb->bits_per_pixel;
+	window.bits_per_pixel = fb->format->cpp[0] * 8;
 	window.bottom_up = tegra_fb_is_bottom_up(fb);
 
 	/* copy from state */
drivers/gpu/drm/tegra/drm.c +1 -1
index d2893f65341a..e289dbc6ad82 100644
@@ -877,7 +877,7 @@ static int tegra_debugfs_framebuffers(struct seq_file *s, void *data)
 		seq_printf(s, "%3d: user size: %d x %d, depth %d, %d bpp, refcount %d\n",
 			   fb->base.id, fb->width, fb->height,
 			   fb->format->depth,
-			   fb->bits_per_pixel,
+			   fb->format->cpp[0] * 8,
 			   drm_framebuffer_read_refcount(fb));
 	}
 
drivers/gpu/drm/udl/udl_fb.c +1 -1
index e21a3ed3ab2b..b8dc06d68777 100644
@@ -89,7 +89,7 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
 	int bytes_identical = 0;
 	struct urb *urb;
 	int aligned_x;
-	int bpp = (fb->base.bits_per_pixel / 8);
+	int bpp = fb->base.format->cpp[0];
 
 	if (!fb->active_16)
 		return 0;
drivers/gpu/drm/virtio/virtgpu_fb.c +1 -1
index 9d0da42cc420..61254b991265 100644
@@ -43,7 +43,7 @@ static int virtio_gpu_dirty_update(struct virtio_gpu_framebuffer *fb,
 	struct drm_device *dev = fb->base.dev;
 	struct virtio_gpu_device *vgdev = dev->dev_private;
 	bool store_for_later = false;
-	int bpp = fb->base.bits_per_pixel / 8;
+	int bpp = fb->base.format->cpp[0];
 	int x2, y2;
 	unsigned long flags;
 	struct virtio_gpu_object *obj = gem_to_virtio_gpu_obj(fb->obj);
drivers/gpu/drm/vmwgfx/vmwgfx_fb.c +3 -3
index b6e4add09f44..4d9ab16fb909 100644
@@ -93,7 +93,7 @@ static int vmw_fb_setcolreg(unsigned regno, unsigned red, unsigned green,
 	default:
 		DRM_ERROR("Bad depth %u, bpp %u.\n",
 			  par->set_fb->format->depth,
-			  par->set_fb->bits_per_pixel);
+			  par->set_fb->format->cpp[0] * 8);
 		return 1;
 	}
 
@@ -198,7 +198,7 @@ static void vmw_fb_dirty_flush(struct work_struct *work)
 	 * Handle panning when copying from vmalloc to framebuffer.
 	 * Clip dirty area to framebuffer.
 	 */
-	cpp = (cur_fb->bits_per_pixel + 7) / 8;
+	cpp = cur_fb->format->cpp[0];
 	max_x = par->fb_x + cur_fb->width;
 	max_y = par->fb_y + cur_fb->height;
 
@@ -486,7 +486,7 @@ static int vmw_fb_kms_framebuffer(struct fb_info *info)
 	cur_fb = par->set_fb;
 	if (cur_fb && cur_fb->width == mode_cmd.width &&
 	    cur_fb->height == mode_cmd.height &&
-	    cur_fb->bits_per_pixel == mode_cmd.bpp &&
+	    cur_fb->format->cpp[0] * 8 == mode_cmd.bpp &&
 	    cur_fb->format->depth == mode_cmd.depth &&
 	    cur_fb->pitches[0] == mode_cmd.pitch)
 		return 0;
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0 -2
index 2ce4743701f1..eb8e36462961 100644
@@ -591,7 +591,6 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
 	/* XXX get the first 4 from the surface info */
 	vfbs->base.base.format = drm_format_info(pixel_format);
 	vfbs->base.base.pixel_format = pixel_format;
-	vfbs->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbs->base.base.pitches[0] = mode_cmd->pitch;
 	vfbs->base.base.width = mode_cmd->width;
 	vfbs->base.base.height = mode_cmd->height;
@@ -899,7 +898,6 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
 	vfbd->base.base.dev = dev;
 	vfbd->base.base.format = drm_format_info(pixel_format);
 	vfbd->base.base.pixel_format = pixel_format;
-	vfbd->base.base.bits_per_pixel = mode_cmd->bpp;
 	vfbd->base.base.pitches[0] = mode_cmd->pitch;
 	vfbd->base.base.width = mode_cmd->width;
 	vfbd->base.base.height = mode_cmd->height;
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +2 -2
index a3a839a3d441..3806148e1bdb 100644
@@ -97,7 +97,7 @@ static int vmw_ldu_commit_list(struct vmw_private *dev_priv)
 		fb = entry->base.crtc.primary->fb;
 
 		return vmw_kms_write_svga(dev_priv, w, h, fb->pitches[0],
-					  fb->bits_per_pixel,
+					  fb->format->cpp[0] * 8,
 					  fb->format->depth);
 	}
 
@@ -106,7 +106,7 @@ static int vmw_ldu_commit_list(struct vmw_private *dev_priv)
 		fb = entry->base.crtc.primary->fb;
 
 		vmw_kms_write_svga(dev_priv, fb->width, fb->height, fb->pitches[0],
-				   fb->bits_per_pixel, fb->format->depth);
+				   fb->format->cpp[0] * 8, fb->format->depth);
 	}
 
 	/* Make sure we always show something. */
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +1 -1
index 38d7b8a2b78e..d4268efc37d2 100644
@@ -618,7 +618,7 @@ static int do_dmabuf_define_gmrfb(struct vmw_private *dev_priv,
 	}
 
 	cmd->header = SVGA_CMD_DEFINE_GMRFB;
-	cmd->body.format.bitsPerPixel = framebuffer->base.bits_per_pixel;
+	cmd->body.format.bitsPerPixel = framebuffer->base.format->cpp[0] * 8;
 	cmd->body.format.colorDepth = depth;
 	cmd->body.format.reserved = 0;
 	cmd->body.bytesPerLine = framebuffer->base.pitches[0];
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +1 -1
index 94ad8d2acf9a..b27cd18ee66a 100644
@@ -424,7 +424,7 @@ static int vmw_stdu_bind_fb(struct vmw_private *dev_priv,
 		 */
 		if (new_content_type == SEPARATE_DMA) {
 
-			switch (new_fb->bits_per_pixel) {
+			switch (new_fb->format->cpp[0] * 8) {
 			case 32:
 				content_srf.format = SVGA3D_X8R8G8B8;
 				break;
include/drm/drm_framebuffer.h +0 -7
index 9b9772998db6..4efc5066475a 100644
@@ -170,13 +170,6 @@ struct drm_framebuffer {
 	 */
 	unsigned int height;
 	/**
-	 * @bits_per_pixel: Storage used bits per pixel for RGB formats. 0 for
-	 * everything else. Legacy information derived from @pixel_format, it's
-	 * suggested to use the DRM FOURCC codes and helper functions directly
-	 * instead.
-	 */
-	int bits_per_pixel;
-	/**
 	 * @flags: Framebuffer flags like DRM_MODE_FB_INTERLACED or
 	 * DRM_MODE_FB_MODIFIERS.
 	 */
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#49 lore raw

PATCH 32/32 drm: Nuke fb->pixel_format

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Replace uses of fb->bits_per_pixel with fb->format->format. Less duplicated information is a good thing.

Note that coccinelle failed to eliminate the
"/* fourcc format */" comment from drm_framebuffer.h, so I had to do that part manually.

@@
struct drm_framebuffer *fb;
expression E;
@@

 drm_helper_mode_fill_fb_struct(...) {
	...
-	fb->pixel_format = E;
	...

}

@@
struct vmw_framebuffer_surface *vfb;
expression E;
@@
- vfb->base.base.pixel_format = E;

@@
struct vmw_framebuffer_dmabuf *vfb;
expression E;
@@
- vfb->base.base.pixel_format = E;

@@
struct drm_framebuffer *fb;
expression E;
@@

 i9xx_get_initial_plane_config(...) {
	...
-	fb->pixel_format = E;
	...

}

@@
struct drm_framebuffer *fb;
expression E;
@@

 ironlake_get_initial_plane_config(...) {
	...
-	fb->pixel_format = E;
	...

}

@@
struct drm_framebuffer *fb;
expression E;
@@

 skylake_get_initial_plane_config(...) {
	...
-	fb->pixel_format = E;
	...

}

@@
struct drm_framebuffer *fb;
@@
- fb->pixel_format
+ fb->format->format

@@
struct intel_framebuffer *fb;
@@
- fb->base.pixel_format
+ fb->base.format->format

@@
struct drm_plane_state *state;
@@
- state->fb->pixel_format
+ state->fb->format->format

@@
struct drm_plane_state state;
@@
- state.fb->pixel_format
+ state.fb->format->format

@@
struct drm_crtc *crtc;
@@
- crtc->primary->fb->pixel_format
+ crtc->primary->fb->format->format

@@
struct drm_mode_set *set;
@@
- set->fb->pixel_format
+ set->fb->format->format

@@
struct drm_mode_set *set;
@@
- set->crtc->primary->fb->pixel_format
+ set->crtc->primary->fb->format->format

@@
@@

 struct drm_framebuffer {
	 ...
-	 uint32_t pixel_format;
	 ...

};

---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c          |  4 +--
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c          |  4 +--
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c           |  4 +--
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c           |  4 +--
 drivers/gpu/drm/arc/arcpgu_crtc.c               |  2 +-
 drivers/gpu/drm/arm/hdlcd_crtc.c                |  4 +--
 drivers/gpu/drm/arm/malidp_planes.c             | 10 +++----
 drivers/gpu/drm/armada/armada_crtc.c            |  2 +-
 drivers/gpu/drm/armada/armada_overlay.c         |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 22 +++++++-------
 drivers/gpu/drm/drm_atomic.c                    |  6 ++--
 drivers/gpu/drm/drm_crtc.c                      |  4 +--
 drivers/gpu/drm/drm_crtc_helper.c               |  4 +--
 drivers/gpu/drm/drm_fb_cma_helper.c             |  2 +-
 drivers/gpu/drm/drm_framebuffer.c               |  2 +-
 drivers/gpu/drm/drm_modeset_helper.c            |  1 -
 drivers/gpu/drm/drm_plane.c                     |  6 ++--
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c   |  2 +-
 drivers/gpu/drm/exynos/exynos7_drm_decon.c      |  2 +-
 drivers/gpu/drm/exynos/exynos_drm_fimd.c        |  2 +-
 drivers/gpu/drm/exynos/exynos_mixer.c           |  8 ++---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c     |  4 +--
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c |  6 ++--
 drivers/gpu/drm/i915/i915_debugfs.c             |  3 +-
 drivers/gpu/drm/i915/intel_atomic_plane.c       |  4 +--
 drivers/gpu/drm/i915/intel_display.c            | 33 ++++++++++----------
 drivers/gpu/drm/i915/intel_fbdev.c              |  2 +-
 drivers/gpu/drm/i915/intel_overlay.c            |  2 +-
 drivers/gpu/drm/i915/intel_pm.c                 | 10 +++----
 drivers/gpu/drm/i915/intel_sprite.c             | 12 ++++----
 drivers/gpu/drm/imx/ipuv3-plane.c               | 40 ++++++++++++-------------
 drivers/gpu/drm/mediatek/mtk_drm_plane.c        |  2 +-
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c       |  2 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c       |  4 +--
 drivers/gpu/drm/msm/msm_fb.c                    | 10 +++----
 drivers/gpu/drm/nouveau/dispnv04/overlay.c      |  8 ++---
 drivers/gpu/drm/nouveau/nv50_display.c          |  4 +--
 drivers/gpu/drm/omapdrm/omap_fb.c               | 10 +++----
 drivers/gpu/drm/radeon/atombios_crtc.c          |  8 ++---
 drivers/gpu/drm/rcar-du/rcar_du_plane.c         |  4 +--
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c           |  4 +--
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c     | 22 +++++++-------
 drivers/gpu/drm/shmobile/shmob_drm_crtc.c       |  6 ++--
 drivers/gpu/drm/shmobile/shmob_drm_plane.c      |  4 +--
 drivers/gpu/drm/sti/sti_gdp.c                   | 10 +++----
 drivers/gpu/drm/sti/sti_hqvdp.c                 |  2 +-
 drivers/gpu/drm/sun4i/sun4i_backend.c           |  5 ++--
 drivers/gpu/drm/tegra/dc.c                      |  6 ++--
 drivers/gpu/drm/tegra/fb.c                      |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c            |  4 +--
 drivers/gpu/drm/tilcdc/tilcdc_plane.c           |  4 +--
 drivers/gpu/drm/vc4/vc4_plane.c                 |  6 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c             |  2 --
 drivers/gpu/drm/zte/zx_plane.c                  |  2 +-
 include/drm/drm_framebuffer.h                   |  4 ---
 56 files changed, 171 insertions(+), 179 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +2 -2
index 9c8f33780257..575f010a3112 100644
@@ -2072,7 +2072,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,
 
 	pipe_config = AMDGPU_TILING_GET(tiling_flags, PIPE_CONFIG);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format = REG_SET_FIELD(0, GRPH_CONTROL, GRPH_DEPTH, 0);
 		fb_format = REG_SET_FIELD(fb_format, GRPH_CONTROL, GRPH_FORMAT, 0);
@@ -2145,7 +2145,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +2 -2
index 72ba3a50452b..9f325f4e018c 100644
@@ -2053,7 +2053,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,
 
 	pipe_config = AMDGPU_TILING_GET(tiling_flags, PIPE_CONFIG);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format = REG_SET_FIELD(0, GRPH_CONTROL, GRPH_DEPTH, 0);
 		fb_format = REG_SET_FIELD(fb_format, GRPH_CONTROL, GRPH_FORMAT, 0);
@@ -2126,7 +2126,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2 -2
index aa64d9c1a8c8..6975a78f733b 100644
@@ -1494,7 +1494,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,
 	amdgpu_bo_get_tiling_flags(abo, &tiling_flags);
 	amdgpu_bo_unreserve(abo);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_8BPP) |
 			     EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_INDEXED));
@@ -1560,7 +1560,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +2 -2
index ecf6c68b8f43..bfdfda50f0e7 100644
@@ -1950,7 +1950,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
 
 	pipe_config = AMDGPU_TILING_GET(tiling_flags, PIPE_CONFIG);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format = ((GRPH_DEPTH_8BPP << GRPH_CONTROL__GRPH_DEPTH__SHIFT) |
 			     (GRPH_FORMAT_INDEXED << GRPH_CONTROL__GRPH_FORMAT__SHIFT));
@@ -2016,7 +2016,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
drivers/gpu/drm/arc/arcpgu_crtc.c +1 -1
index 5c26c5f126a3..ad9a95916f1f 100644
@@ -36,7 +36,7 @@ static void arc_pgu_set_pxl_fmt(struct drm_crtc *crtc)
 {
 	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
 	const struct drm_framebuffer *fb = crtc->primary->state->fb;
-	uint32_t pixel_format = fb->pixel_format;
+	uint32_t pixel_format = fb->format->format;
 	struct simplefb_format *format = NULL;
 	int i;
 
drivers/gpu/drm/arm/hdlcd_crtc.c +2 -2
index 8a0fee03aa39..94eb458cd52d 100644
@@ -65,7 +65,7 @@ static int hdlcd_set_pxl_fmt(struct drm_crtc *crtc)
 	struct simplefb_format *format = NULL;
 	int i;
 
-	pixel_format = fb->pixel_format;
+	pixel_format = fb->format->format;
 
 	for (i = 0; i < ARRAY_SIZE(supported_formats); i++) {
 		if (supported_formats[i].fourcc == pixel_format)
@@ -239,7 +239,7 @@ static void hdlcd_plane_atomic_update(struct drm_plane *plane,
 	scanout_start = gem->paddr + fb->offsets[0] +
 		plane->state->crtc_y * fb->pitches[0] +
 		plane->state->crtc_x *
-		drm_format_plane_cpp(fb->pixel_format, 0);
+		drm_format_plane_cpp(fb->format->format, 0);
 
 	hdlcd = plane->dev->dev_private;
 	hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_LENGTH, fb->pitches[0]);
drivers/gpu/drm/arm/malidp_planes.c +5 -5
index ee7f7663a307..45130d1692cd 100644
@@ -112,11 +112,11 @@ static int malidp_de_plane_check(struct drm_plane *plane,
 	fb = state->fb;
 
 	ms->format = malidp_hw_get_format_id(&mp->hwdev->map, mp->layer->id,
-					    fb->pixel_format);
+					    fb->format->format);
 	if (ms->format == MALIDP_INVALID_FORMAT_ID)
 		return -EINVAL;
 
-	ms->n_planes = drm_format_num_planes(fb->pixel_format);
+	ms->n_planes = drm_format_num_planes(fb->format->format);
 	for (i = 0; i < ms->n_planes; i++) {
 		if (!malidp_hw_pitch_valid(mp->hwdev, fb->pitches[i])) {
 			DRM_DEBUG_KMS("Invalid pitch %u for plane %d\n",
@@ -137,8 +137,8 @@ static int malidp_de_plane_check(struct drm_plane *plane,
 
 	/* packed RGB888 / BGR888 can't be rotated or flipped */
 	if (state->rotation != DRM_ROTATE_0 &&
-	    (fb->pixel_format == DRM_FORMAT_RGB888 ||
-	     fb->pixel_format == DRM_FORMAT_BGR888))
+	    (fb->format->format == DRM_FORMAT_RGB888 ||
+	     fb->format->format == DRM_FORMAT_BGR888))
 		return -EINVAL;
 
 	ms->rotmem_size = 0;
@@ -147,7 +147,7 @@ static int malidp_de_plane_check(struct drm_plane *plane,
 
 		val = mp->hwdev->rotmem_required(mp->hwdev, state->crtc_h,
 						 state->crtc_w,
-						 fb->pixel_format);
+						 fb->format->format);
 		if (val < 0)
 			return val;
 
drivers/gpu/drm/armada/armada_crtc.c +1 -1
index c69a5ea54f23..52e139dc9e38 100644
@@ -996,7 +996,7 @@ static int armada_drm_crtc_page_flip(struct drm_crtc *crtc,
 	int ret;
 
 	/* We don't support changing the pixel format */
-	if (fb->pixel_format != crtc->primary->fb->pixel_format)
+	if (fb->format->format != crtc->primary->fb->format->format)
 		return -EINVAL;
 
 	work = kmalloc(sizeof(*work), GFP_KERNEL);
drivers/gpu/drm/armada/armada_overlay.c +1 -1
index 152b4e716269..5a3dd724e01c 100644
@@ -182,7 +182,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 		src_y = src.y1 >> 16;
 		src_x = src.x1 >> 16;
 
-		pixel_format = fb->pixel_format;
+		pixel_format = fb->format->format;
 		hsub = drm_format_horz_chroma_subsampling(pixel_format);
 		num_planes = drm_format_num_planes(pixel_format);
 
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c +1 -1
index 377e43cea9dd..1406996cc89b 100644
@@ -446,7 +446,7 @@ void atmel_hlcdc_layer_update_set_fb(struct atmel_hlcdc_layer *layer,
 		return;
 
 	if (fb)
-		nplanes = drm_format_num_planes(fb->pixel_format);
+		nplanes = drm_format_num_planes(fb->format->format);
 
 	if (nplanes > layer->max_planes)
 		return;
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +11 -11
index 246ed1e33d8a..91c1daaee365 100644
@@ -356,7 +356,7 @@ atmel_hlcdc_plane_update_general_settings(struct atmel_hlcdc_plane *plane,
 		cfg |= ATMEL_HLCDC_LAYER_OVR | ATMEL_HLCDC_LAYER_ITER2BL |
 		       ATMEL_HLCDC_LAYER_ITER;
 
-		if (atmel_hlcdc_format_embeds_alpha(state->base.fb->pixel_format))
+		if (atmel_hlcdc_format_embeds_alpha(state->base.fb->format->format))
 			cfg |= ATMEL_HLCDC_LAYER_LAEN;
 		else
 			cfg |= ATMEL_HLCDC_LAYER_GAEN |
@@ -386,13 +386,13 @@ static void atmel_hlcdc_plane_update_format(struct atmel_hlcdc_plane *plane,
 	u32 cfg;
 	int ret;
 
-	ret = atmel_hlcdc_format_to_plane_mode(state->base.fb->pixel_format,
+	ret = atmel_hlcdc_format_to_plane_mode(state->base.fb->format->format,
 					       &cfg);
 	if (ret)
 		return;
 
-	if ((state->base.fb->pixel_format == DRM_FORMAT_YUV422 ||
-	     state->base.fb->pixel_format == DRM_FORMAT_NV61) &&
+	if ((state->base.fb->format->format == DRM_FORMAT_YUV422 ||
+	     state->base.fb->format->format == DRM_FORMAT_NV61) &&
 	    drm_rotation_90_or_270(state->base.rotation))
 		cfg |= ATMEL_HLCDC_YUV422ROT;
 
@@ -405,7 +405,7 @@ static void atmel_hlcdc_plane_update_format(struct atmel_hlcdc_plane *plane,
 	 * Rotation optimization is not working on RGB888 (rotation is still
 	 * working but without any optimization).
 	 */
-	if (state->base.fb->pixel_format == DRM_FORMAT_RGB888)
+	if (state->base.fb->format->format == DRM_FORMAT_RGB888)
 		cfg = ATMEL_HLCDC_LAYER_DMA_ROTDIS;
 	else
 		cfg = 0;
@@ -514,7 +514,7 @@ atmel_hlcdc_plane_prepare_disc_area(struct drm_crtc_state *c_state)
 		ovl_state = drm_plane_state_to_atmel_hlcdc_plane_state(ovl_s);
 
 		if (!ovl_s->fb ||
-		    atmel_hlcdc_format_embeds_alpha(ovl_s->fb->pixel_format) ||
+		    atmel_hlcdc_format_embeds_alpha(ovl_s->fb->format->format) ||
 		    ovl_state->alpha != 255)
 			continue;
 
@@ -621,7 +621,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
 	state->src_w >>= 16;
 	state->src_h >>= 16;
 
-	state->nplanes = drm_format_num_planes(fb->pixel_format);
+	state->nplanes = drm_format_num_planes(fb->format->format);
 	if (state->nplanes > ATMEL_HLCDC_MAX_PLANES)
 		return -EINVAL;
 
@@ -664,15 +664,15 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
 	patched_src_h = DIV_ROUND_CLOSEST(patched_crtc_h * state->src_h,
 					  state->crtc_h);
 
-	hsub = drm_format_horz_chroma_subsampling(fb->pixel_format);
-	vsub = drm_format_vert_chroma_subsampling(fb->pixel_format);
+	hsub = drm_format_horz_chroma_subsampling(fb->format->format);
+	vsub = drm_format_vert_chroma_subsampling(fb->format->format);
 
 	for (i = 0; i < state->nplanes; i++) {
 		unsigned int offset = 0;
 		int xdiv = i ? hsub : 1;
 		int ydiv = i ? vsub : 1;
 
-		state->bpp[i] = drm_format_plane_cpp(fb->pixel_format, i);
+		state->bpp[i] = drm_format_plane_cpp(fb->format->format, i);
 		if (!state->bpp[i])
 			return -EINVAL;
 
@@ -741,7 +741,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
 
 	if ((state->crtc_h != state->src_h || state->crtc_w != state->src_w) &&
 	    (!layout->memsize ||
-	     atmel_hlcdc_format_embeds_alpha(state->base.fb->pixel_format)))
+	     atmel_hlcdc_format_embeds_alpha(state->base.fb->format->format)))
 		return -EINVAL;
 
 	if (state->crtc_x < 0 || state->crtc_y < 0)
drivers/gpu/drm/drm_atomic.c +3 -3
index cb6ab0106b0b..a3e4a0dc8fb4 100644
@@ -902,11 +902,11 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
 	}
 
 	/* Check whether this plane supports the fb pixel format. */
-	ret = drm_plane_check_pixel_format(plane, state->fb->pixel_format);
+	ret = drm_plane_check_pixel_format(plane, state->fb->format->format);
 	if (ret) {
 		struct drm_format_name_buf format_name;
 		DRM_DEBUG_ATOMIC("Invalid pixel format %s\n",
-		                 drm_get_format_name(state->fb->pixel_format,
+		                 drm_get_format_name(state->fb->format->format,
 		                                     &format_name));
 		return ret;
 	}
@@ -964,7 +964,7 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,
 		struct drm_format_name_buf format_name;
 
 		drm_printf(p, "\t\tformat=%s\n",
-		              drm_get_format_name(fb->pixel_format, &format_name));
+		              drm_get_format_name(fb->format->format, &format_name));
 		drm_printf(p, "\t\t\tmodifier=0x%llx\n", fb->modifier);
 		drm_printf(p, "\t\tsize=%dx%d\n", fb->width, fb->height);
 		drm_printf(p, "\t\tlayers:\n");
drivers/gpu/drm/drm_crtc.c +2 -2
index 90931e039731..7e814741f7f3 100644
@@ -556,11 +556,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
 		 */
 		if (!crtc->primary->format_default) {
 			ret = drm_plane_check_pixel_format(crtc->primary,
-							   fb->pixel_format);
+							   fb->format->format);
 			if (ret) {
 				struct drm_format_name_buf format_name;
 				DRM_DEBUG_KMS("Invalid pixel format %s\n",
-				              drm_get_format_name(fb->pixel_format,
+				              drm_get_format_name(fb->format->format,
 				                                  &format_name));
 				goto out;
 			}
drivers/gpu/drm/drm_crtc_helper.c +2 -2
index 5d2cb138eba6..94bce0b462aa 100644
@@ -588,8 +588,8 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
 		if (set->crtc->primary->fb == NULL) {
 			DRM_DEBUG_KMS("crtc has no fb, full mode set\n");
 			mode_changed = true;
-		} else if (set->fb->pixel_format !=
-			   set->crtc->primary->fb->pixel_format) {
+		} else if (set->fb->format->format !=
+			   set->crtc->primary->fb->format->format) {
 			mode_changed = true;
 		} else
 			fb_changed = true;
drivers/gpu/drm/drm_fb_cma_helper.c +1 -1
index 181a9eafe34a..aab4465307ed 100644
@@ -307,7 +307,7 @@ static void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file *m)
 	int i;
 
 	seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height,
-			(char *)&fb->pixel_format);
+			(char *)&fb->format->format);
 
 	for (i = 0; i < fb->fomat->num_planes; i++) {
 		seq_printf(m, "   %d: offset=%d pitch=%d, obj: ",
drivers/gpu/drm/drm_framebuffer.c +1 -1
index 98c054098808..e48c9e7fa78e 100644
@@ -634,7 +634,7 @@ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
 	INIT_LIST_HEAD(&fb->filp_head);
 	if (WARN_ON_ONCE(fb->dev != dev)) {
 		fb->dev = dev;
-		fb->format = drm_format_info(fb->pixel_format);
+		fb->format = drm_format_info(fb->format->format);
 	}
 	fb->funcs = funcs;
 
drivers/gpu/drm/drm_modeset_helper.c +0 -1
index 3c44409244dc..639e474e7d43 100644
@@ -94,7 +94,6 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
 		fb->offsets[i] = mode_cmd->offsets[i];
 	}
 	fb->modifier = mode_cmd->modifier[0];
-	fb->pixel_format = mode_cmd->pixel_format;
 	fb->flags = mode_cmd->flags;
 }
 EXPORT_SYMBOL(drm_helper_mode_fill_fb_struct);
drivers/gpu/drm/drm_plane.c +3 -3
index 419ac313c36f..ac1e06df7280 100644
@@ -478,11 +478,11 @@ static int __setplane_internal(struct drm_plane *plane,
 	}
 
 	/* Check whether this plane supports the fb pixel format. */
-	ret = drm_plane_check_pixel_format(plane, fb->pixel_format);
+	ret = drm_plane_check_pixel_format(plane, fb->format->format);
 	if (ret) {
 		struct drm_format_name_buf format_name;
 		DRM_DEBUG_KMS("Invalid pixel format %s\n",
-		              drm_get_format_name(fb->pixel_format,
+		              drm_get_format_name(fb->format->format,
 		                                  &format_name));
 		goto out;
 	}
@@ -854,7 +854,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 	if (ret)
 		goto out;
 
-	if (crtc->primary->fb->pixel_format != fb->pixel_format) {
+	if (crtc->primary->fb->format->format != fb->format->format) {
 		DRM_DEBUG_KMS("Page flip is not allowed to change frame buffer format.\n");
 		ret = -EINVAL;
 		goto out;
drivers/gpu/drm/exynos/exynos5433_drm_decon.c +1 -1
index e8ce4a318586..c5c01628c715 100644
@@ -200,7 +200,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
 	val = readl(ctx->addr + DECON_WINCONx(win));
 	val &= ~WINCONx_BPPMODE_MASK;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_XRGB1555:
 		val |= WINCONx_BPPMODE_16BPP_I1555;
 		val |= WINCONx_HAWSWP_F;
drivers/gpu/drm/exynos/exynos7_drm_decon.c +1 -1
index 58dc9a5196bc..f9ab19e205e2 100644
@@ -281,7 +281,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
 	val = readl(ctx->regs + WINCON(win));
 	val &= ~WINCONx_BPPMODE_MASK;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_RGB565:
 		val |= WINCONx_BPPMODE_16BPP_565;
 		val |= WINCONx_BURSTLEN_16WORD;
drivers/gpu/drm/exynos/exynos_drm_fimd.c +1 -1
index 0029065979b8..745cfbdf6b39 100644
@@ -804,7 +804,7 @@ static void fimd_update_plane(struct exynos_drm_crtc *crtc,
 		DRM_DEBUG_KMS("osd size = 0x%x\n", (unsigned int)val);
 	}
 
-	fimd_win_set_pixfmt(ctx, win, fb->pixel_format, state->src.w);
+	fimd_win_set_pixfmt(ctx, win, fb->format->format, state->src.w);
 
 	/* hardware window 0 doesn't support color key. */
 	if (win != 0)
drivers/gpu/drm/exynos/exynos_mixer.c +4 -4
index b313e61aab65..a106046e0c93 100644
@@ -485,7 +485,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
 	bool crcb_mode = false;
 	u32 val;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_NV12:
 		crcb_mode = false;
 		break;
@@ -494,7 +494,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
 		break;
 	default:
 		DRM_ERROR("pixel format for vp is wrong [%d].\n",
-				fb->pixel_format);
+				fb->format->format);
 		return;
 	}
 
@@ -597,7 +597,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
 	unsigned int fmt;
 	u32 val;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_XRGB4444:
 	case DRM_FORMAT_ARGB4444:
 		fmt = MXR_FORMAT_ARGB4444;
@@ -681,7 +681,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
 	mixer_cfg_scan(ctx, mode->vdisplay);
 	mixer_cfg_rgb_fmt(ctx, mode->vdisplay);
 	mixer_cfg_layer(ctx, win, priority, true);
-	mixer_cfg_gfx_blend(ctx, win, is_alpha_format(fb->pixel_format));
+	mixer_cfg_gfx_blend(ctx, win, is_alpha_format(fb->format->format));
 
 	/* layer update mandatory for mixer 16.0.33.0 */
 	if (ctx->mxr_ver == MXR_VER_16_0_33_0 ||
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c +2 -2
index a99f48847420..0a20723aa6e1 100644
@@ -44,7 +44,7 @@ static int fsl_dcu_drm_plane_atomic_check(struct drm_plane *plane,
 	if (!state->fb || !state->crtc)
 		return 0;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_RGB565:
 	case DRM_FORMAT_RGB888:
 	case DRM_FORMAT_XRGB8888:
@@ -96,7 +96,7 @@ static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane,
 
 	gem = drm_fb_cma_get_gem_obj(fb, 0);
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_RGB565:
 		bpp = FSL_DCU_RGB565;
 		break;
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +3 -3
index afc2b5d2d5f0..2f0c2e1c6110 100644
@@ -617,7 +617,7 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb,
 			 ch + 1, y, in_h, stride, (u32)obj->paddr);
 	DRM_DEBUG_DRIVER("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n",
 			 addr, fb->width, fb->height, fmt,
-			 drm_get_format_name(fb->pixel_format, &format_name));
+			 drm_get_format_name(fb->format->format, &format_name));
 
 	/* get reg offset */
 	reg_ctrl = RD_CH_CTRL(ch);
@@ -773,7 +773,7 @@ static void ade_update_channel(struct ade_plane *aplane,
 {
 	struct ade_hw_ctx *ctx = aplane->ctx;
 	void __iomem *base = ctx->base;
-	u32 fmt = ade_get_format(fb->pixel_format);
+	u32 fmt = ade_get_format(fb->format->format);
 	u32 ch = aplane->ch;
 	u32 in_w;
 	u32 in_h;
@@ -835,7 +835,7 @@ static int ade_plane_atomic_check(struct drm_plane *plane,
 	if (!crtc || !fb)
 		return 0;
 
-	fmt = ade_get_format(fb->pixel_format);
+	fmt = ade_get_format(fb->format->format);
 	if (fmt == ADE_FORMAT_UNSUPPORT)
 		return -EINVAL;
 
drivers/gpu/drm/i915/i915_debugfs.c +2 -1
index ee272ec8732c..e571e9a37ac4 100644
@@ -3042,7 +3042,8 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)
 		state = plane->state;
 
 		if (state->fb) {
-			drm_get_format_name(state->fb->pixel_format, &format_name);
+			drm_get_format_name(state->fb->format->format,
+					    &format_name);
 		} else {
 			sprintf(format_name.str, "N/A");
 		}
drivers/gpu/drm/i915/intel_atomic_plane.c +2 -2
index dbe9fb41ae53..e049838159a1 100644
@@ -155,11 +155,11 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
 		 * RGB 16-bit 5:6:5, and Indexed 8-bit.
 		 * TBD: Add RGB64 case once its added in supported format list.
 		 */
-		switch (state->fb->pixel_format) {
+		switch (state->fb->format->format) {
 		case DRM_FORMAT_C8:
 		case DRM_FORMAT_RGB565:
 			DRM_DEBUG_KMS("Unsupported pixel format %s for 90/270!\n",
-			              drm_get_format_name(state->fb->pixel_format,
+			              drm_get_format_name(state->fb->format->format,
 			                                  &format_name));
 			return -EINVAL;
 
drivers/gpu/drm/i915/intel_display.c +15 -18
index 6c889f0e8e0f..f5f9f1422d69 100644
@@ -2455,7 +2455,7 @@ u32 intel_compute_tile_offset(int *x, int *y,
 	u32 alignment;
 
 	/* AUX_DIST needs only 4K alignment */
-	if (fb->pixel_format == DRM_FORMAT_NV12 && plane == 1)
+	if (fb->format->format == DRM_FORMAT_NV12 && plane == 1)
 		alignment = 4096;
 	else
 		alignment = intel_surf_alignment(dev_priv, fb->modifier);
@@ -2700,7 +2700,7 @@ intel_alloc_initial_plane_obj(struct intel_crtc *crtc,
 	if (plane_config->tiling == I915_TILING_X)
 		obj->tiling_and_stride = fb->pitches[0] | I915_TILING_X;
 
-	mode_cmd.pixel_format = fb->pixel_format;
+	mode_cmd.pixel_format = fb->format->format;
 	mode_cmd.width = fb->width;
 	mode_cmd.height = fb->height;
 	mode_cmd.pitches[0] = fb->pitches[0];
@@ -2976,7 +2976,7 @@ int skl_check_plane_surface(struct intel_plane_state *plane_state)
 	 * Handle the AUX surface first since
 	 * the main surface setup depends on it.
 	 */
-	if (fb->pixel_format == DRM_FORMAT_NV12) {
+	if (fb->format->format == DRM_FORMAT_NV12) {
 		ret = skl_check_nv12_aux_surface(plane_state);
 		if (ret)
 			return ret;
@@ -3031,7 +3031,7 @@ static void i9xx_update_primary_plane(struct drm_plane *primary,
 		I915_WRITE(PRIMCNSTALPHA(plane), 0);
 	}
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_C8:
 		dspcntr |= DISPPLANE_8BPP;
 		break;
@@ -3146,7 +3146,7 @@ static void ironlake_update_primary_plane(struct drm_plane *primary,
 	if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
 		dspcntr |= DISPPLANE_PIPE_CSC_ENABLE;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_C8:
 		dspcntr |= DISPPLANE_8BPP;
 		break;
@@ -3282,7 +3282,7 @@ u32 skl_plane_stride(const struct drm_framebuffer *fb, int plane,
 		stride /= intel_tile_height(dev_priv, fb->modifier, cpp);
 	} else {
 		stride /= intel_fb_stride_alignment(dev_priv, fb->modifier,
-						    fb->pixel_format);
+						    fb->format->format);
 	}
 
 	return stride;
@@ -3396,7 +3396,7 @@ static void skylake_update_primary_plane(struct drm_plane *plane,
 		    PLANE_CTL_PIPE_GAMMA_ENABLE |
 		    PLANE_CTL_PIPE_CSC_ENABLE;
 
-	plane_ctl |= skl_plane_ctl_format(fb->pixel_format);
+	plane_ctl |= skl_plane_ctl_format(fb->format->format);
 	plane_ctl |= skl_plane_ctl_tiling(fb->modifier);
 	plane_ctl |= PLANE_CTL_PLANE_GAMMA_DISABLE;
 	plane_ctl |= skl_plane_ctl_rotation(rotation);
@@ -4768,7 +4768,7 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
 	}
 
 	/* Check src format */
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_RGB565:
 	case DRM_FORMAT_XBGR8888:
 	case DRM_FORMAT_XRGB8888:
@@ -4784,7 +4784,7 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
 	default:
 		DRM_DEBUG_KMS("[PLANE:%d:%s] FB:%d unsupported scaling format 0x%x\n",
 			      intel_plane->base.base.id, intel_plane->base.name,
-			      fb->base.id, fb->pixel_format);
+			      fb->base.id, fb->format->format);
 		return -EINVAL;
 	}
 
@@ -8714,7 +8714,6 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
 
 	pixel_format = val & DISPPLANE_PIXFORMAT_MASK;
 	fourcc = i9xx_format_to_fourcc(pixel_format);
-	fb->pixel_format = fourcc;
 	fb->format = drm_format_info(fourcc);
 
 	if (INTEL_GEN(dev_priv) >= 4) {
@@ -8736,7 +8735,7 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
 	fb->pitches[0] = val & 0xffffffc0;
 
 	aligned_height = intel_fb_align_height(dev, fb->height,
-					       fb->pixel_format,
+					       fb->format->format,
 					       fb->modifier);
 
 	plane_config->size = fb->pitches[0] * aligned_height;
@@ -9745,7 +9744,6 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
 	fourcc = skl_format_to_fourcc(pixel_format,
 				      val & PLANE_CTL_ORDER_RGBX,
 				      val & PLANE_CTL_ALPHA_MASK);
-	fb->pixel_format = fourcc;
 	fb->format = drm_format_info(fourcc);
 
 	tiling = val & PLANE_CTL_TILED_MASK;
@@ -9779,11 +9777,11 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
 
 	val = I915_READ(PLANE_STRIDE(pipe, 0));
 	stride_mult = intel_fb_stride_alignment(dev_priv, fb->modifier,
-						fb->pixel_format);
+						fb->format->format);
 	fb->pitches[0] = (val & 0x3ff) * stride_mult;
 
 	aligned_height = intel_fb_align_height(dev, fb->height,
-					       fb->pixel_format,
+					       fb->format->format,
 					       fb->modifier);
 
 	plane_config->size = fb->pitches[0] * aligned_height;
@@ -9860,7 +9858,6 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
 
 	pixel_format = val & DISPPLANE_PIXFORMAT_MASK;
 	fourcc = i9xx_format_to_fourcc(pixel_format);
-	fb->pixel_format = fourcc;
 	fb->format = drm_format_info(fourcc);
 
 	base = I915_READ(DSPSURF(pipe)) & 0xfffff000;
@@ -9882,7 +9879,7 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
 	fb->pitches[0] = val & 0xffffffc0;
 
 	aligned_height = intel_fb_align_height(dev, fb->height,
-					       fb->pixel_format,
+					       fb->format->format,
 					       fb->modifier);
 
 	plane_config->size = fb->pitches[0] * aligned_height;
@@ -12151,7 +12148,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 		return -EBUSY;
 
 	/* Can't change pixel format via MI display flips. */
-	if (fb->pixel_format != crtc->primary->fb->pixel_format)
+	if (fb->format->format != crtc->primary->fb->format->format)
 		return -EINVAL;
 
 	/*
@@ -12845,7 +12842,7 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,
 		DRM_DEBUG_KMS("[PLANE:%d:%s] FB:%d, fb = %ux%u format = %s\n",
 			      plane->base.id, plane->name,
 			      fb->base.id, fb->width, fb->height,
-			      drm_get_format_name(fb->pixel_format, &format_name));
+			      drm_get_format_name(fb->format->format, &format_name));
 		if (INTEL_GEN(dev_priv) >= 9)
 			DRM_DEBUG_KMS("\tscaler:%d src %dx%d+%d+%d dst %dx%d+%d+%d\n",
 				      state->scaler_id,
drivers/gpu/drm/i915/intel_fbdev.c +1 -1
index 3f60a4f6f078..570c07d59d1a 100644
@@ -632,7 +632,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 
 		cur_size = intel_crtc->config->base.adjusted_mode.crtc_vdisplay;
 		cur_size = intel_fb_align_height(dev, cur_size,
-						 fb->base.pixel_format,
+						 fb->base.format->format,
 						 fb->base.modifier);
 		cur_size *= fb->base.pitches[0];
 		DRM_DEBUG_KMS("pipe %c area: %dx%d, bpp: %d, size: %d\n",
drivers/gpu/drm/i915/intel_overlay.c +1 -1
index ce3667c18e18..568d194435fd 100644
@@ -667,7 +667,7 @@ static void update_colorkey(struct intel_overlay *overlay,
 	if (overlay->color_key_enabled)
 		flags |= DST_KEY_ENABLE;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_C8:
 		key = 0;
 		flags |= CLK_RGB8I_MASK;
drivers/gpu/drm/i915/intel_pm.c +5 -5
index 318cd7bdd785..2387fb8546a7 100644
@@ -3232,7 +3232,7 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
 	struct drm_framebuffer *fb = pstate->fb;
 	uint32_t down_scale_amount, data_rate;
 	uint32_t width = 0, height = 0;
-	unsigned format = fb ? fb->pixel_format : DRM_FORMAT_XRGB8888;
+	unsigned format = fb ? fb->format->format : DRM_FORMAT_XRGB8888;
 
 	if (!intel_pstate->base.visible)
 		return 0;
@@ -3323,7 +3323,7 @@ skl_ddb_min_alloc(const struct drm_plane_state *pstate,
 		return 0;
 
 	/* For packed formats, no y-plane, return 0 */
-	if (y && fb->pixel_format != DRM_FORMAT_NV12)
+	if (y && fb->format->format != DRM_FORMAT_NV12)
 		return 0;
 
 	/* For Non Y-tile return 8-blocks */
@@ -3338,12 +3338,12 @@ skl_ddb_min_alloc(const struct drm_plane_state *pstate,
 		swap(src_w, src_h);
 
 	/* Halve UV plane width and height for NV12 */
-	if (fb->pixel_format == DRM_FORMAT_NV12 && !y) {
+	if (fb->format->format == DRM_FORMAT_NV12 && !y) {
 		src_w /= 2;
 		src_h /= 2;
 	}
 
-	if (fb->pixel_format == DRM_FORMAT_NV12 && !y)
+	if (fb->format->format == DRM_FORMAT_NV12 && !y)
 		plane_bpp = fb->format->cpp[1];
 	else
 		plane_bpp = fb->format->cpp[0];
@@ -3610,7 +3610,7 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 	plane_pixel_rate = skl_adjusted_plane_pixel_rate(cstate, intel_pstate);
 
 	if (drm_rotation_90_or_270(pstate->rotation)) {
-		int cpp = (fb->pixel_format == DRM_FORMAT_NV12) ?
+		int cpp = (fb->format->format == DRM_FORMAT_NV12) ?
 			fb->format->cpp[1] :
 			fb->format->cpp[0];
 
drivers/gpu/drm/i915/intel_sprite.c +6 -6
index b46c1794d3ac..ff766c0cb873 100644
@@ -223,7 +223,7 @@ skl_update_plane(struct drm_plane *drm_plane,
 		PLANE_CTL_PIPE_GAMMA_ENABLE |
 		PLANE_CTL_PIPE_CSC_ENABLE;
 
-	plane_ctl |= skl_plane_ctl_format(fb->pixel_format);
+	plane_ctl |= skl_plane_ctl_format(fb->format->format);
 	plane_ctl |= skl_plane_ctl_tiling(fb->modifier);
 
 	plane_ctl |= skl_plane_ctl_rotation(rotation);
@@ -357,7 +357,7 @@ vlv_update_plane(struct drm_plane *dplane,
 
 	sprctl = SP_ENABLE;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_YUYV:
 		sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_YUYV;
 		break;
@@ -443,7 +443,7 @@ vlv_update_plane(struct drm_plane *dplane,
 		sprctl |= SP_SOURCE_KEY;
 
 	if (IS_CHERRYVIEW(dev_priv) && pipe == PIPE_B)
-		chv_update_csc(intel_plane, fb->pixel_format);
+		chv_update_csc(intel_plane, fb->format->format);
 
 	I915_WRITE(SPSTRIDE(pipe, plane), fb->pitches[0]);
 	I915_WRITE(SPPOS(pipe, plane), (crtc_y << 16) | crtc_x);
@@ -502,7 +502,7 @@ ivb_update_plane(struct drm_plane *plane,
 
 	sprctl = SPRITE_ENABLE;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_XBGR8888:
 		sprctl |= SPRITE_FORMAT_RGBX888 | SPRITE_RGB_ORDER_RGBX;
 		break;
@@ -640,7 +640,7 @@ ilk_update_plane(struct drm_plane *plane,
 
 	dvscntr = DVS_ENABLE;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_XBGR8888:
 		dvscntr |= DVS_FORMAT_RGBX888 | DVS_RGB_ORDER_XBGR;
 		break;
@@ -866,7 +866,7 @@ intel_check_sprite_plane(struct drm_plane *plane,
 		src_y = src->y1 >> 16;
 		src_h = drm_rect_height(src) >> 16;
 
-		if (format_is_yuv(fb->pixel_format)) {
+		if (format_is_yuv(fb->format->format)) {
 			src_x &= ~1;
 			src_w &= ~1;
 
drivers/gpu/drm/imx/ipuv3-plane.c +20 -20
index e74a0ad52950..76fcc5f0d9e1 100644
@@ -77,7 +77,7 @@ drm_plane_state_to_eba(struct drm_plane_state *state)
 	BUG_ON(!cma_obj);
 
 	return cma_obj->paddr + fb->offsets[0] + fb->pitches[0] * y +
-	       drm_format_plane_cpp(fb->pixel_format, 0) * x;
+	       drm_format_plane_cpp(fb->format->format, 0) * x;
 }
 
 static inline unsigned long
@@ -92,11 +92,11 @@ drm_plane_state_to_ubo(struct drm_plane_state *state)
 	cma_obj = drm_fb_cma_get_gem_obj(fb, 1);
 	BUG_ON(!cma_obj);
 
-	x /= drm_format_horz_chroma_subsampling(fb->pixel_format);
-	y /= drm_format_vert_chroma_subsampling(fb->pixel_format);
+	x /= drm_format_horz_chroma_subsampling(fb->format->format);
+	y /= drm_format_vert_chroma_subsampling(fb->format->format);
 
 	return cma_obj->paddr + fb->offsets[1] + fb->pitches[1] * y +
-	       drm_format_plane_cpp(fb->pixel_format, 1) * x - eba;
+	       drm_format_plane_cpp(fb->format->format, 1) * x - eba;
 }
 
 static inline unsigned long
@@ -111,11 +111,11 @@ drm_plane_state_to_vbo(struct drm_plane_state *state)
 	cma_obj = drm_fb_cma_get_gem_obj(fb, 2);
 	BUG_ON(!cma_obj);
 
-	x /= drm_format_horz_chroma_subsampling(fb->pixel_format);
-	y /= drm_format_vert_chroma_subsampling(fb->pixel_format);
+	x /= drm_format_horz_chroma_subsampling(fb->format->format);
+	y /= drm_format_vert_chroma_subsampling(fb->format->format);
 
 	return cma_obj->paddr + fb->offsets[2] + fb->pitches[2] * y +
-	       drm_format_plane_cpp(fb->pixel_format, 2) * x - eba;
+	       drm_format_plane_cpp(fb->format->format, 2) * x - eba;
 }
 
 void ipu_plane_put_resources(struct ipu_plane *ipu_plane)
@@ -281,7 +281,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
 	 */
 	if (old_fb && (state->src_w != old_state->src_w ||
 			      state->src_h != old_state->src_h ||
-			      fb->pixel_format != old_fb->pixel_format))
+			      fb->format->format != old_fb->format->format))
 		crtc_state->mode_changed = true;
 
 	eba = drm_plane_state_to_eba(state);
@@ -295,7 +295,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
 	if (old_fb && fb->pitches[0] != old_fb->pitches[0])
 		crtc_state->mode_changed = true;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_YUV420:
 	case DRM_FORMAT_YVU420:
 	case DRM_FORMAT_YUV422:
@@ -315,7 +315,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
 		if (vbo & 0x7 || vbo > 0xfffff8)
 			return -EINVAL;
 
-		if (old_fb && (fb->pixel_format == old_fb->pixel_format)) {
+		if (old_fb && (fb->format->format == old_fb->format->format)) {
 			old_vbo = drm_plane_state_to_vbo(old_state);
 			if (vbo != old_vbo)
 				crtc_state->mode_changed = true;
@@ -332,7 +332,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
 		if (ubo & 0x7 || ubo > 0xfffff8)
 			return -EINVAL;
 
-		if (old_fb && (fb->pixel_format == old_fb->pixel_format)) {
+		if (old_fb && (fb->format->format == old_fb->format->format)) {
 			old_ubo = drm_plane_state_to_ubo(old_state);
 			if (ubo != old_ubo)
 				crtc_state->mode_changed = true;
@@ -348,8 +348,8 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
 		 * The x/y offsets must be even in case of horizontal/vertical
 		 * chroma subsampling.
 		 */
-		hsub = drm_format_horz_chroma_subsampling(fb->pixel_format);
-		vsub = drm_format_vert_chroma_subsampling(fb->pixel_format);
+		hsub = drm_format_horz_chroma_subsampling(fb->format->format);
+		vsub = drm_format_vert_chroma_subsampling(fb->format->format);
 		if (((state->src_x >> 16) & (hsub - 1)) ||
 		    ((state->src_y >> 16) & (vsub - 1)))
 			return -EINVAL;
@@ -392,13 +392,13 @@ static void ipu_plane_atomic_update(struct drm_plane *plane,
 		ipu_dp_set_global_alpha(ipu_plane->dp, true, 0, true);
 		break;
 	case IPU_DP_FLOW_SYNC_FG:
-		ics = ipu_drm_fourcc_to_colorspace(state->fb->pixel_format);
+		ics = ipu_drm_fourcc_to_colorspace(state->fb->format->format);
 		ipu_dp_setup_channel(ipu_plane->dp, ics,
 					IPUV3_COLORSPACE_UNKNOWN);
 		ipu_dp_set_window_pos(ipu_plane->dp, state->crtc_x,
 					state->crtc_y);
 		/* Enable local alpha on partial plane */
-		switch (state->fb->pixel_format) {
+		switch (state->fb->format->format) {
 		case DRM_FORMAT_ARGB1555:
 		case DRM_FORMAT_ABGR1555:
 		case DRM_FORMAT_RGBA5551:
@@ -421,11 +421,11 @@ static void ipu_plane_atomic_update(struct drm_plane *plane,
 	ipu_cpmem_zero(ipu_plane->ipu_ch);
 	ipu_cpmem_set_resolution(ipu_plane->ipu_ch, state->src_w >> 16,
 					state->src_h >> 16);
-	ipu_cpmem_set_fmt(ipu_plane->ipu_ch, state->fb->pixel_format);
+	ipu_cpmem_set_fmt(ipu_plane->ipu_ch, state->fb->format->format);
 	ipu_cpmem_set_high_priority(ipu_plane->ipu_ch);
 	ipu_idmac_set_double_buffer(ipu_plane->ipu_ch, 1);
 	ipu_cpmem_set_stride(ipu_plane->ipu_ch, state->fb->pitches[0]);
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_YUV420:
 	case DRM_FORMAT_YVU420:
 	case DRM_FORMAT_YUV422:
@@ -434,9 +434,9 @@ static void ipu_plane_atomic_update(struct drm_plane *plane,
 	case DRM_FORMAT_YVU444:
 		ubo = drm_plane_state_to_ubo(state);
 		vbo = drm_plane_state_to_vbo(state);
-		if (fb->pixel_format == DRM_FORMAT_YVU420 ||
-		    fb->pixel_format == DRM_FORMAT_YVU422 ||
-		    fb->pixel_format == DRM_FORMAT_YVU444)
+		if (fb->format->format == DRM_FORMAT_YVU420 ||
+		    fb->format->format == DRM_FORMAT_YVU422 ||
+		    fb->format->format == DRM_FORMAT_YVU444)
 			swap(ubo, vbo);
 
 		ipu_cpmem_set_yuv_planar_full(ipu_plane->ipu_ch,
drivers/gpu/drm/mediatek/mtk_drm_plane.c +1 -1
index c461a232cbf5..daf049bbe878 100644
@@ -133,7 +133,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
 	mtk_gem = to_mtk_gem_obj(gem);
 	addr = mtk_gem->dma_addr;
 	pitch = fb->pitches[0];
-	format = fb->pixel_format;
+	format = fb->format->format;
 
 	addr += (plane->state->src.x1 >> 16) * drm_format_plane_cpp(format, 0);
 	addr += (plane->state->src.y1 >> 16) * pitch;
drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c +1 -1
index 911e4690d36a..53619d07677e 100644
@@ -43,7 +43,7 @@ enum mdp4_frame_format mdp4_get_frame_format(struct drm_framebuffer *fb)
 	if (fb->modifier == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE)
 		is_tile = true;
 
-	if (fb->pixel_format == DRM_FORMAT_NV12 && is_tile)
+	if (fb->format->format == DRM_FORMAT_NV12 && is_tile)
 		return FRAME_TILE_YCBCR_420;
 
 	return FRAME_LINEAR;
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +2 -2
index 81c0562ab489..fb32d4563d92 100644
@@ -340,7 +340,7 @@ static int mdp5_plane_atomic_check(struct drm_plane *plane,
 	if (plane_enabled(state) && plane_enabled(old_state)) {
 		/* we cannot change SMP block configuration during scanout: */
 		bool full_modeset = false;
-		if (state->fb->pixel_format != old_state->fb->pixel_format) {
+		if (state->fb->format->format != old_state->fb->format->format) {
 			DBG("%s: pixel_format change!", mdp5_plane->name);
 			full_modeset = true;
 		}
@@ -703,7 +703,7 @@ static int mdp5_plane_mode_set(struct drm_plane *plane,
 	unsigned long flags;
 	int ret;
 
-	nplanes = drm_format_num_planes(fb->pixel_format);
+	nplanes = drm_format_num_planes(fb->format->format);
 
 	/* bad formats should already be rejected: */
 	if (WARN_ON(nplanes > pipe2nclients(pipe)))
drivers/gpu/drm/msm/msm_fb.c +5 -5
index 9614ed405808..5b579248fbaa 100644
@@ -41,7 +41,7 @@ static int msm_framebuffer_create_handle(struct drm_framebuffer *fb,
 static void msm_framebuffer_destroy(struct drm_framebuffer *fb)
 {
 	struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-	int i, n = drm_format_num_planes(fb->pixel_format);
+	int i, n = drm_format_num_planes(fb->format->format);
 
 	DBG("destroy: FB ID: %d (%p)", fb->base.id, fb);
 
@@ -65,10 +65,10 @@ static const struct drm_framebuffer_funcs msm_framebuffer_funcs = {
 void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 {
 	struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-	int i, n = drm_format_num_planes(fb->pixel_format);
+	int i, n = drm_format_num_planes(fb->format->format);
 
 	seq_printf(m, "fb: %dx%d@%4.4s (%2d, ID:%d)\n",
-			fb->width, fb->height, (char *)&fb->pixel_format,
+			fb->width, fb->height, (char *)&fb->format->format,
 			drm_framebuffer_read_refcount(fb), fb->base.id);
 
 	for (i = 0; i < n; i++) {
@@ -87,7 +87,7 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 int msm_framebuffer_prepare(struct drm_framebuffer *fb, int id)
 {
 	struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-	int ret, i, n = drm_format_num_planes(fb->pixel_format);
+	int ret, i, n = drm_format_num_planes(fb->format->format);
 	uint32_t iova;
 
 	for (i = 0; i < n; i++) {
@@ -103,7 +103,7 @@ int msm_framebuffer_prepare(struct drm_framebuffer *fb, int id)
 void msm_framebuffer_cleanup(struct drm_framebuffer *fb, int id)
 {
 	struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-	int i, n = drm_format_num_planes(fb->pixel_format);
+	int i, n = drm_format_num_planes(fb->format->format);
 
 	for (i = 0; i < n; i++)
 		msm_gem_put_iova(msm_fb->planes[i], id);
drivers/gpu/drm/nouveau/dispnv04/overlay.c +4 -4
index a79514d440b3..6275c270df25 100644
@@ -145,16 +145,16 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	nvif_wr32(dev, NV_PVIDEO_POINT_OUT(flip), crtc_y << 16 | crtc_x);
 	nvif_wr32(dev, NV_PVIDEO_SIZE_OUT(flip), crtc_h << 16 | crtc_w);
 
-	if (fb->pixel_format != DRM_FORMAT_UYVY)
+	if (fb->format->format != DRM_FORMAT_UYVY)
 		format |= NV_PVIDEO_FORMAT_COLOR_LE_CR8YB8CB8YA8;
-	if (fb->pixel_format == DRM_FORMAT_NV12)
+	if (fb->format->format == DRM_FORMAT_NV12)
 		format |= NV_PVIDEO_FORMAT_PLANAR;
 	if (nv_plane->iturbt_709)
 		format |= NV_PVIDEO_FORMAT_MATRIX_ITURBT709;
 	if (nv_plane->colorkey & (1 << 24))
 		format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY;
 
-	if (fb->pixel_format == DRM_FORMAT_NV12) {
+	if (fb->format->format == DRM_FORMAT_NV12) {
 		nvif_wr32(dev, NV_PVIDEO_UVPLANE_BASE(flip), 0);
 		nvif_wr32(dev, NV_PVIDEO_UVPLANE_OFFSET_BUFF(flip),
 			nv_fb->nvbo->bo.offset + fb->offsets[1]);
@@ -411,7 +411,7 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 
 	if (nv_plane->colorkey & (1 << 24))
 		overlay |= 0x10;
-	if (fb->pixel_format == DRM_FORMAT_YUYV)
+	if (fb->format->format == DRM_FORMAT_YUYV)
 		overlay |= 0x100;
 
 	nvif_wr32(dev, NV_PVIDEO_OVERLAY, overlay);
drivers/gpu/drm/nouveau/nv50_display.c +2 -2
index d3bd428023ea..4fd313ee46b3 100644
@@ -1153,7 +1153,7 @@ nv50_curs_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
 	if (asyw->state.fb->width != asyw->state.fb->height)
 		return -EINVAL;
 
-	switch (asyw->state.fb->pixel_format) {
+	switch (asyw->state.fb->format->format) {
 	case DRM_FORMAT_ARGB8888: asyh->curs.format = 1; break;
 	default:
 		WARN_ON(1);
@@ -1438,7 +1438,7 @@ nv50_base_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
 	asyh->base.w = asyw->state.fb->width;
 	asyh->base.h = asyw->state.fb->height;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_C8         : asyw->image.format = 0x1e; break;
 	case DRM_FORMAT_RGB565     : asyw->image.format = 0xe8; break;
 	case DRM_FORMAT_XRGB1555   :
drivers/gpu/drm/omapdrm/omap_fb.c +5 -5
index 9875c99be009..d2742772b9d8 100644
@@ -107,7 +107,7 @@ static int omap_framebuffer_create_handle(struct drm_framebuffer *fb,
 static void omap_framebuffer_destroy(struct drm_framebuffer *fb)
 {
 	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	int i, n = drm_format_num_planes(fb->pixel_format);
+	int i, n = drm_format_num_planes(fb->format->format);
 
 	DBG("destroy: FB ID: %d (%p)", fb->base.id, fb);
 
@@ -252,7 +252,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
 int omap_framebuffer_pin(struct drm_framebuffer *fb)
 {
 	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	int ret, i, n = drm_format_num_planes(fb->pixel_format);
+	int ret, i, n = drm_format_num_planes(fb->format->format);
 
 	mutex_lock(&omap_fb->lock);
 
@@ -292,7 +292,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
 void omap_framebuffer_unpin(struct drm_framebuffer *fb)
 {
 	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	int i, n = drm_format_num_planes(fb->pixel_format);
+	int i, n = drm_format_num_planes(fb->format->format);
 
 	mutex_lock(&omap_fb->lock);
 
@@ -343,10 +343,10 @@ struct drm_connector *omap_framebuffer_get_next_connector(
 void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 {
 	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	int i, n = drm_format_num_planes(fb->pixel_format);
+	int i, n = drm_format_num_planes(fb->format->format);
 
 	seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height,
-			(char *)&fb->pixel_format);
+			(char *)&fb->format->format);
 
 	for (i = 0; i < n; i++) {
 		struct plane *plane = &omap_fb->planes[i];
drivers/gpu/drm/radeon/atombios_crtc.c +4 -4
index 8eeffc5324b2..b2ff986546a0 100644
@@ -1195,7 +1195,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 	radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL);
 	radeon_bo_unreserve(rbo);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_8BPP) |
 			     EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_INDEXED));
@@ -1261,7 +1261,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
@@ -1511,7 +1511,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
 	radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL);
 	radeon_bo_unreserve(rbo);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format =
 		    AVIVO_D1GRPH_CONTROL_DEPTH_8BPP |
@@ -1564,7 +1564,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
drivers/gpu/drm/rcar-du/rcar_du_plane.c +2 -2
index a74f8ed8ca2e..dcde6288da6c 100644
@@ -567,10 +567,10 @@ static int rcar_du_plane_atomic_check(struct drm_plane *plane,
 		return -EINVAL;
 	}
 
-	rstate->format = rcar_du_format_info(state->fb->pixel_format);
+	rstate->format = rcar_du_format_info(state->fb->format->format);
 	if (rstate->format == NULL) {
 		dev_dbg(rcdu->dev, "%s: unsupported format %08x\n", __func__,
-			state->fb->pixel_format);
+			state->fb->format->format);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +2 -2
index 83ebd162f3ef..b5bfbe50bd87 100644
@@ -201,10 +201,10 @@ static int rcar_du_vsp_plane_atomic_check(struct drm_plane *plane,
 		return -EINVAL;
 	}
 
-	rstate->format = rcar_du_format_info(state->fb->pixel_format);
+	rstate->format = rcar_du_format_info(state->fb->format->format);
 	if (rstate->format == NULL) {
 		dev_dbg(rcdu->dev, "%s: unsupported format %08x\n", __func__,
-			state->fb->pixel_format);
+			state->fb->format->format);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +11 -11
index c7eba305c488..f8c6f74edc80 100644
@@ -668,7 +668,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
 	if (!state->visible)
 		return 0;
 
-	ret = vop_convert_format(fb->pixel_format);
+	ret = vop_convert_format(fb->format->format);
 	if (ret < 0)
 		return ret;
 
@@ -676,7 +676,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
 	 * Src.x1 can be odd when do clip, but yuv plane start point
 	 * need align with 2 pixel.
 	 */
-	if (is_yuv_support(fb->pixel_format) && ((state->src.x1 >> 16) % 2))
+	if (is_yuv_support(fb->format->format) && ((state->src.x1 >> 16) % 2))
 		return -EINVAL;
 
 	return 0;
@@ -749,21 +749,21 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 	dsp_sty = dest->y1 + crtc->mode.vtotal - crtc->mode.vsync_start;
 	dsp_st = dsp_sty << 16 | (dsp_stx & 0xffff);
 
-	offset = (src->x1 >> 16) * drm_format_plane_cpp(fb->pixel_format, 0);
+	offset = (src->x1 >> 16) * drm_format_plane_cpp(fb->format->format, 0);
 	offset += (src->y1 >> 16) * fb->pitches[0];
 	dma_addr = rk_obj->dma_addr + offset + fb->offsets[0];
 
-	format = vop_convert_format(fb->pixel_format);
+	format = vop_convert_format(fb->format->format);
 
 	spin_lock(&vop->reg_lock);
 
 	VOP_WIN_SET(vop, win, format, format);
 	VOP_WIN_SET(vop, win, yrgb_vir, fb->pitches[0] >> 2);
 	VOP_WIN_SET(vop, win, yrgb_mst, dma_addr);
-	if (is_yuv_support(fb->pixel_format)) {
-		int hsub = drm_format_horz_chroma_subsampling(fb->pixel_format);
-		int vsub = drm_format_vert_chroma_subsampling(fb->pixel_format);
-		int bpp = drm_format_plane_cpp(fb->pixel_format, 1);
+	if (is_yuv_support(fb->format->format)) {
+		int hsub = drm_format_horz_chroma_subsampling(fb->format->format);
+		int vsub = drm_format_vert_chroma_subsampling(fb->format->format);
+		int bpp = drm_format_plane_cpp(fb->format->format, 1);
 
 		uv_obj = rockchip_fb_get_gem_obj(fb, 1);
 		rk_uv_obj = to_rockchip_obj(uv_obj);
@@ -779,16 +779,16 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 	if (win->phy->scl)
 		scl_vop_cal_scl_fac(vop, win, actual_w, actual_h,
 				    drm_rect_width(dest), drm_rect_height(dest),
-				    fb->pixel_format);
+				    fb->format->format);
 
 	VOP_WIN_SET(vop, win, act_info, act_info);
 	VOP_WIN_SET(vop, win, dsp_info, dsp_info);
 	VOP_WIN_SET(vop, win, dsp_st, dsp_st);
 
-	rb_swap = has_rb_swapped(fb->pixel_format);
+	rb_swap = has_rb_swapped(fb->format->format);
 	VOP_WIN_SET(vop, win, rb_swap, rb_swap);
 
-	if (is_alpha_support(fb->pixel_format)) {
+	if (is_alpha_support(fb->format->format)) {
 		VOP_WIN_SET(vop, win, dst_alpha_ctl,
 			    DST_FACTOR_M0(ALPHA_SRC_INVERSE));
 		val = SRC_ALPHA_EN(1) | SRC_COLOR_M0(ALPHA_SRC_PRE_MUL) |
drivers/gpu/drm/shmobile/shmob_drm_crtc.c +3 -3
index 6547b1db460a..2494410435a1 100644
@@ -174,7 +174,7 @@ static void shmob_drm_crtc_start(struct shmob_drm_crtc *scrtc)
 	if (scrtc->started)
 		return;
 
-	format = shmob_drm_format_info(crtc->primary->fb->pixel_format);
+	format = shmob_drm_format_info(crtc->primary->fb->format->format);
 	if (WARN_ON(format == NULL))
 		return;
 
@@ -376,10 +376,10 @@ static int shmob_drm_crtc_mode_set(struct drm_crtc *crtc,
 	const struct shmob_drm_format_info *format;
 	void *cache;
 
-	format = shmob_drm_format_info(crtc->primary->fb->pixel_format);
+	format = shmob_drm_format_info(crtc->primary->fb->format->format);
 	if (format == NULL) {
 		dev_dbg(sdev->dev, "mode_set: unsupported format %08x\n",
-			crtc->primary->fb->pixel_format);
+			crtc->primary->fb->format->format);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/shmobile/shmob_drm_plane.c +2 -2
index 1805bb23b113..2023a93cee2b 100644
@@ -183,10 +183,10 @@ shmob_drm_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 	struct shmob_drm_device *sdev = plane->dev->dev_private;
 	const struct shmob_drm_format_info *format;
 
-	format = shmob_drm_format_info(fb->pixel_format);
+	format = shmob_drm_format_info(fb->format->format);
 	if (format == NULL) {
 		dev_dbg(sdev->dev, "update_plane: unsupported format %08x\n",
-			fb->pixel_format);
+			fb->format->format);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/sti/sti_gdp.c +5 -5
index 81df3097b545..33821dda79df 100644
@@ -636,10 +636,10 @@ static int sti_gdp_atomic_check(struct drm_plane *drm_plane,
 	src_w = clamp_val(state->src_w >> 16, 0, GAM_GDP_SIZE_MAX);
 	src_h = clamp_val(state->src_h >> 16, 0, GAM_GDP_SIZE_MAX);
 
-	format = sti_gdp_fourcc2format(fb->pixel_format);
+	format = sti_gdp_fourcc2format(fb->format->format);
 	if (format == -1) {
 		DRM_ERROR("Format not supported by GDP %.4s\n",
-			  (char *)&fb->pixel_format);
+			  (char *)&fb->format->format);
 		return -EINVAL;
 	}
 
@@ -745,7 +745,7 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
 	/* build the top field */
 	top_field->gam_gdp_agc = GAM_GDP_AGC_FULL_RANGE;
 	top_field->gam_gdp_ctl = WAIT_NEXT_VSYNC;
-	format = sti_gdp_fourcc2format(fb->pixel_format);
+	format = sti_gdp_fourcc2format(fb->format->format);
 	top_field->gam_gdp_ctl |= format;
 	top_field->gam_gdp_ctl |= sti_gdp_get_alpharange(format);
 	top_field->gam_gdp_ppt &= ~GAM_GDP_PPT_IGNORE;
@@ -753,11 +753,11 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
 	cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
 
 	DRM_DEBUG_DRIVER("drm FB:%d format:%.4s phys@:0x%lx\n", fb->base.id,
-			 (char *)&fb->pixel_format,
+			 (char *)&fb->format->format,
 			 (unsigned long)cma_obj->paddr);
 
 	/* pixel memory location */
-	bpp = drm_format_plane_cpp(fb->pixel_format, 0);
+	bpp = drm_format_plane_cpp(fb->format->format, 0);
 	top_field->gam_gdp_pml = (u32)cma_obj->paddr + fb->offsets[0];
 	top_field->gam_gdp_pml += src_x * bpp;
 	top_field->gam_gdp_pml += src_y * fb->pitches[0];
drivers/gpu/drm/sti/sti_hqvdp.c +1 -1
index f88130f2eb48..becf10d255c4 100644
@@ -1147,7 +1147,7 @@ static void sti_hqvdp_atomic_update(struct drm_plane *drm_plane,
 	cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
 
 	DRM_DEBUG_DRIVER("drm FB:%d format:%.4s phys@:0x%lx\n", fb->base.id,
-			 (char *)&fb->pixel_format,
+			 (char *)&fb->format->format,
 			 (unsigned long)cma_obj->paddr);
 
 	/* Buffer planes address */
drivers/gpu/drm/sun4i/sun4i_backend.c +3 -2
index 2e08f969bb64..8719acf745c2 100644
@@ -189,7 +189,8 @@ int sun4i_backend_update_layer_formats(struct sun4i_backend *backend,
 	DRM_DEBUG_DRIVER("Switching display backend interlaced mode %s\n",
 			 interlaced ? "on" : "off");
 
-	ret = sun4i_backend_drm_format_to_layer(plane, fb->pixel_format, &val);
+	ret = sun4i_backend_drm_format_to_layer(plane, fb->format->format,
+						&val);
 	if (ret) {
 		DRM_DEBUG_DRIVER("Invalid format\n");
 		return val;
@@ -218,7 +219,7 @@ int sun4i_backend_update_layer_buffer(struct sun4i_backend *backend,
 	DRM_DEBUG_DRIVER("Using GEM @ %pad\n", &gem->paddr);
 
 	/* Compute the start of the displayed memory */
-	bpp = drm_format_plane_cpp(fb->pixel_format, 0);
+	bpp = drm_format_plane_cpp(fb->format->format, 0);
 	paddr = gem->paddr + fb->offsets[0];
 	paddr += (state->src_x >> 16) * bpp;
 	paddr += (state->src_y >> 16) * fb->pitches[0];
drivers/gpu/drm/tegra/dc.c +3 -3
index 3af157a2d40c..4121d0c2aac8 100644
@@ -511,7 +511,7 @@ static int tegra_plane_atomic_check(struct drm_plane *plane,
 	if (!state->crtc)
 		return 0;
 
-	err = tegra_dc_format(state->fb->pixel_format, &plane_state->format,
+	err = tegra_dc_format(state->fb->format->format, &plane_state->format,
 			      &plane_state->swap);
 	if (err < 0)
 		return err;
@@ -531,7 +531,7 @@ static int tegra_plane_atomic_check(struct drm_plane *plane,
 	 * error out if the user tries to display a framebuffer with such a
 	 * configuration.
 	 */
-	if (drm_format_num_planes(state->fb->pixel_format) > 2) {
+	if (drm_format_num_planes(state->fb->format->format) > 2) {
 		if (state->fb->pitches[2] != state->fb->pitches[1]) {
 			DRM_ERROR("unsupported UV-plane configuration\n");
 			return -EINVAL;
@@ -576,7 +576,7 @@ static void tegra_plane_atomic_update(struct drm_plane *plane,
 	window.format = state->format;
 	window.swap = state->swap;
 
-	for (i = 0; i < drm_format_num_planes(fb->pixel_format); i++) {
+	for (i = 0; i < drm_format_num_planes(fb->format->format); i++) {
 		struct tegra_bo *bo = tegra_fb_get_plane(fb, i);
 
 		window.base[i] = bo->paddr + fb->offsets[i];
drivers/gpu/drm/tegra/fb.c +1 -1
index 2a1bf92403b8..1ea5c39a4411 100644
@@ -32,7 +32,7 @@ struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer,
 {
 	struct tegra_fb *fb = to_tegra_fb(framebuffer);
 
-	if (index >= drm_format_num_planes(framebuffer->pixel_format))
+	if (index >= drm_format_num_planes(framebuffer->format->format))
 		return NULL;
 
 	return fb->planes[index];
drivers/gpu/drm/tilcdc/tilcdc_crtc.c +2 -2
index 822531ebd4b0..d00c59e115ff 100644
@@ -79,7 +79,7 @@ static void set_scanout(struct drm_crtc *crtc, struct drm_framebuffer *fb)
 
 	start = gem->paddr + fb->offsets[0] +
 		crtc->y * fb->pitches[0] +
-		crtc->x * drm_format_plane_cpp(fb->pixel_format, 0);
+		crtc->x * drm_format_plane_cpp(fb->format->format, 0);
 
 	end = start + (crtc->mode.vdisplay * fb->pitches[0]);
 
@@ -459,7 +459,7 @@ static void tilcdc_crtc_mode_set_nofb(struct drm_crtc *crtc)
 	if (info->tft_alt_mode)
 		reg |= LCDC_TFT_ALT_ENABLE;
 	if (priv->rev == 2) {
-		switch (fb->pixel_format) {
+		switch (fb->format->format) {
 		case DRM_FORMAT_BGR565:
 		case DRM_FORMAT_RGB565:
 			break;
drivers/gpu/drm/tilcdc/tilcdc_plane.c +2 -2
index 8a6a50d74aff..5a303a81ac96 100644
@@ -69,7 +69,7 @@ static int tilcdc_plane_atomic_check(struct drm_plane *plane,
 	}
 
 	pitch = crtc_state->mode.hdisplay *
-		drm_format_plane_cpp(state->fb->pixel_format, 0);
+		drm_format_plane_cpp(state->fb->format->format, 0);
 	if (state->fb->pitches[0] != pitch) {
 		dev_err(plane->dev->dev,
 			"Invalid pitch: fb and crtc widths must be the same");
@@ -77,7 +77,7 @@ static int tilcdc_plane_atomic_check(struct drm_plane *plane,
 	}
 
 	if (state->fb && old_state->fb &&
-	    state->fb->pixel_format != old_state->fb->pixel_format) {
+	    state->fb->format->format != old_state->fb->format->format) {
 		dev_dbg(plane->dev->dev,
 			"%s(): pixel format change requires mode_change\n",
 			__func__);
drivers/gpu/drm/vc4/vc4_plane.c +3 -3
index 881bf489478b..59be9e7c26de 100644
@@ -295,7 +295,7 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
 	struct drm_framebuffer *fb = state->fb;
 	struct drm_gem_cma_object *bo = drm_fb_cma_get_gem_obj(fb, 0);
 	u32 subpixel_src_mask = (1 << 16) - 1;
-	u32 format = fb->pixel_format;
+	u32 format = fb->format->format;
 	int num_planes = drm_format_num_planes(format);
 	u32 h_subsample = 1;
 	u32 v_subsample = 1;
@@ -369,7 +369,7 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
 	 */
 	if (vc4_state->crtc_x < 0) {
 		for (i = 0; i < num_planes; i++) {
-			u32 cpp = drm_format_plane_cpp(fb->pixel_format, i);
+			u32 cpp = drm_format_plane_cpp(fb->format->format, i);
 			u32 subs = ((i == 0) ? 1 : h_subsample);
 
 			vc4_state->offsets[i] += (cpp *
@@ -496,7 +496,7 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
 	struct vc4_plane_state *vc4_state = to_vc4_plane_state(state);
 	struct drm_framebuffer *fb = state->fb;
 	u32 ctl0_offset = vc4_state->dlist_count;
-	const struct hvs_format *format = vc4_get_hvs_format(fb->pixel_format);
+	const struct hvs_format *format = vc4_get_hvs_format(fb->format->format);
 	int num_planes = drm_format_num_planes(format->drm);
 	u32 scl0, scl1;
 	u32 lbm_size;
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0 -2
index eb8e36462961..91e30c9abff0 100644
@@ -590,7 +590,6 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
 	vfbs->base.base.dev = dev;
 	/* XXX get the first 4 from the surface info */
 	vfbs->base.base.format = drm_format_info(pixel_format);
-	vfbs->base.base.pixel_format = pixel_format;
 	vfbs->base.base.pitches[0] = mode_cmd->pitch;
 	vfbs->base.base.width = mode_cmd->width;
 	vfbs->base.base.height = mode_cmd->height;
@@ -897,7 +896,6 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
 
 	vfbd->base.base.dev = dev;
 	vfbd->base.base.format = drm_format_info(pixel_format);
-	vfbd->base.base.pixel_format = pixel_format;
 	vfbd->base.base.pitches[0] = mode_cmd->pitch;
 	vfbd->base.base.width = mode_cmd->width;
 	vfbd->base.base.height = mode_cmd->height;
drivers/gpu/drm/zte/zx_plane.c +1 -1
index 546eb92a94e8..e4530ca263a9 100644
@@ -146,7 +146,7 @@ static void zx_gl_plane_atomic_update(struct drm_plane *plane,
 	if (!fb)
 		return;
 
-	format = fb->pixel_format;
+	format = fb->format->format;
 	stride = fb->pitches[0];
 
 	src_x = plane->state->src_x >> 16;
include/drm/drm_framebuffer.h +0 -4
index 4efc5066475a..2734a87b2120 100644
@@ -175,10 +175,6 @@ struct drm_framebuffer {
 	 */
 	int flags;
 	/**
-	 * @pixel_format: DRM FOURCC code describing the pixel format.
-	 */
-	uint32_t pixel_format; /* fourcc format */
-	/**
 	 * @hot_x: X coordinate of the cursor hotspot. Used by the legacy cursor
 	 * IOCTL when the driver supports cursor through a DRM_PLANE_TYPE_CURSOR
 	 * universal plane.
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 32/32
#50 lore raw

Re: [PATCH 32/32] drm: Nuke fb->pixel_format

Quoted 105 lines · On Thu, Nov 17, 2016 at 11:14 AM, <[email protected]> wrote:

From: Ville Syrjälä <[email protected]>

Replace uses of fb->bits_per_pixel with fb->format->format. Less duplicated information is a good thing.

Note that coccinelle failed to eliminate the
"/* fourcc format */" comment from drm_framebuffer.h, so I had to do that part manually.

@@
struct drm_framebuffer *fb;
expression E;
@@

 drm_helper_mode_fill_fb_struct(...) {
        ...
-       fb->pixel_format = E;
        ...

}

@@
struct vmw_framebuffer_surface *vfb;
expression E;
@@
- vfb->base.base.pixel_format = E;

@@
struct vmw_framebuffer_dmabuf *vfb;
expression E;
@@
- vfb->base.base.pixel_format = E;

@@
struct drm_framebuffer *fb;
expression E;
@@

 i9xx_get_initial_plane_config(...) {
        ...
-       fb->pixel_format = E;
        ...

}

@@
struct drm_framebuffer *fb;
expression E;
@@

 ironlake_get_initial_plane_config(...) {
        ...
-       fb->pixel_format = E;
        ...

}

@@
struct drm_framebuffer *fb;
expression E;
@@

 skylake_get_initial_plane_config(...) {
        ...
-       fb->pixel_format = E;
        ...

}

@@
struct drm_framebuffer *fb;
@@
- fb->pixel_format
+ fb->format->format

@@
struct intel_framebuffer *fb;
@@
- fb->base.pixel_format
+ fb->base.format->format

@@
struct drm_plane_state *state;
@@
- state->fb->pixel_format
+ state->fb->format->format

@@
struct drm_plane_state state;
@@
- state.fb->pixel_format
+ state.fb->format->format

@@
struct drm_crtc *crtc;
@@
- crtc->primary->fb->pixel_format
+ crtc->primary->fb->format->format

@@
struct drm_mode_set *set;
@@
- set->fb->pixel_format
+ set->fb->format->format

@@
struct drm_mode_set *set;
@@
- set->crtc->primary->fb->pixel_format
+ set->crtc->primary->fb->format->format

@@
@@

Quoted 7 lines
 struct drm_framebuffer {
         ...
-        uint32_t pixel_format;
         ...

};

Patches 13, 18, 19, 22, 28, 30, 31, 32 are:

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#51 lore raw

Re: [PATCH 32/32] drm: Nuke fb->pixel_format

In reply to [email protected]

Hi Ville,

Thank you for the patch.

Quoted 3 lines · On Thursday 17 Nov 2016 18:14:31 [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Replace uses of fb->bits_per_pixel with fb->format->format.

I assume you mean fb->pixel_format.

Quoted 5 lines

Less duplicated information is a good thing.

Note that coccinelle failed to eliminate the
"/* fourcc format */" comment from drm_framebuffer.h, so I had to do that part manually.

[snip]

Quoted 59 lines
---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c          |  4 +--
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c          |  4 +--
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c           |  4 +--
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c           |  4 +--
 drivers/gpu/drm/arc/arcpgu_crtc.c               |  2 +-
 drivers/gpu/drm/arm/hdlcd_crtc.c                |  4 +--
 drivers/gpu/drm/arm/malidp_planes.c             | 10 +++----
 drivers/gpu/drm/armada/armada_crtc.c            |  2 +-
 drivers/gpu/drm/armada/armada_overlay.c         |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 22 +++++++-------
 drivers/gpu/drm/drm_atomic.c                    |  6 ++--
 drivers/gpu/drm/drm_crtc.c                      |  4 +--
 drivers/gpu/drm/drm_crtc_helper.c               |  4 +--
 drivers/gpu/drm/drm_fb_cma_helper.c             |  2 +-
 drivers/gpu/drm/drm_framebuffer.c               |  2 +-
 drivers/gpu/drm/drm_modeset_helper.c            |  1 -
 drivers/gpu/drm/drm_plane.c                     |  6 ++--
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c   |  2 +-
 drivers/gpu/drm/exynos/exynos7_drm_decon.c      |  2 +-
 drivers/gpu/drm/exynos/exynos_drm_fimd.c        |  2 +-
 drivers/gpu/drm/exynos/exynos_mixer.c           |  8 ++---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c     |  4 +--
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c |  6 ++--
 drivers/gpu/drm/i915/i915_debugfs.c             |  3 +-
 drivers/gpu/drm/i915/intel_atomic_plane.c       |  4 +--
 drivers/gpu/drm/i915/intel_display.c            | 33 ++++++++++----------
 drivers/gpu/drm/i915/intel_fbdev.c              |  2 +-
 drivers/gpu/drm/i915/intel_overlay.c            |  2 +-
 drivers/gpu/drm/i915/intel_pm.c                 | 10 +++----
 drivers/gpu/drm/i915/intel_sprite.c             | 12 ++++----
 drivers/gpu/drm/imx/ipuv3-plane.c               | 40 +++++++++-------------
 drivers/gpu/drm/mediatek/mtk_drm_plane.c        |  2 +-
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c       |  2 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c       |  4 +--
 drivers/gpu/drm/msm/msm_fb.c                    | 10 +++----
 drivers/gpu/drm/nouveau/dispnv04/overlay.c      |  8 ++---
 drivers/gpu/drm/nouveau/nv50_display.c          |  4 +--
 drivers/gpu/drm/omapdrm/omap_fb.c               | 10 +++----
 drivers/gpu/drm/radeon/atombios_crtc.c          |  8 ++---
 drivers/gpu/drm/rcar-du/rcar_du_plane.c         |  4 +--
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c           |  4 +--
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c     | 22 +++++++-------
 drivers/gpu/drm/shmobile/shmob_drm_crtc.c       |  6 ++--
 drivers/gpu/drm/shmobile/shmob_drm_plane.c      |  4 +--
 drivers/gpu/drm/sti/sti_gdp.c                   | 10 +++----
 drivers/gpu/drm/sti/sti_hqvdp.c                 |  2 +-
 drivers/gpu/drm/sun4i/sun4i_backend.c           |  5 ++--
 drivers/gpu/drm/tegra/dc.c                      |  6 ++--
 drivers/gpu/drm/tegra/fb.c                      |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c            |  4 +--
 drivers/gpu/drm/tilcdc/tilcdc_plane.c           |  4 +--
 drivers/gpu/drm/vc4/vc4_plane.c                 |  6 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c             |  2 --
 drivers/gpu/drm/zte/zx_plane.c                  |  2 +-
 include/drm/drm_framebuffer.h                   |  4 ---
 56 files changed, 171 insertions(+), 179 deletions(-)

[snip]

drivers/gpu/drm/drm_crtc_helper.c int drm_crtc_helper_set_config(struct drm_mode_set *set) · line 593

Quoted 13 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_crtc_helper.c index 5d2cb138eba6..94bce0b462aa 100644

drivers/gpu/drm/drm_crtc_helper.c +2 -2
@@ -588,8 +588,8 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
 if (set->crtc->primary->fb == NULL) {
 			DRM_DEBUG_KMS("crtc has no fb, full mode set\n");
 			mode_changed = true;
-		} else if (set->fb->pixel_format !=
-			   set->crtc->primary->fb->pixel_format) {
+		} else if (set->fb->format->format !=
+			   set->crtc->primary->fb->format->format) {
 			mode_changed = true;

You could also compare set->fb->format != set->crtc->primary->fb->format which should be slightly more efficient.

Quoted 2 lines
drivers/gpu/drm/drm_crtc_helper.c +0 -0
 		} else
 			fb_changed = true;

[snip]

drivers/gpu/drm/drm_framebuffer.c int drm_framebuffer_init(struct drm_device *dev, struct · line 637

Quoted 10 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_framebuffer.c index 98c054098808..e48c9e7fa78e 100644

drivers/gpu/drm/drm_framebuffer.c +1 -1
@@ -634,7 +634,7 @@ int drm_framebuffer_init(struct drm_device *dev, struct
 drm_framebuffer *fb, INIT_LIST_HEAD(&fb->filp_head);
 	if (WARN_ON_ONCE(fb->dev != dev)) {
 		fb->dev = dev;
-		fb->format = drm_format_info(fb->pixel_format);
+		fb->format = drm_format_info(fb->format->format);

This is an interesting one :-) If fb->format is NULL you will crash, and if it isn't this is a no-op.

Quoted 2 lines
drivers/gpu/drm/drm_framebuffer.c +0 -0
 	}
 	fb->funcs = funcs;

[snip]

drivers/gpu/drm/i915/i915_debugfs.c static void intel_plane_info(struct seq_file *m, · line 3045

Quoted 10 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_debugfs.c index ee272ec8732c..e571e9a37ac4 100644

drivers/gpu/drm/i915/i915_debugfs.c +0 -1
@@ -3042,7 +3042,8 @@ static void intel_plane_info(struct seq_file *m,
 struct intel_crtc *intel_crtc) state = plane->state;
 
 		if (state->fb) {
-			drm_get_format_name(state->fb->pixel_format, 

&format_name);

drivers/gpu/drm/i915/i915_debugfs.c static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) · line 3046

Quoted 2 lines
drivers/gpu/drm/i915/i915_debugfs.c +2 -0
+			drm_get_format_name(state->fb->format->format,
+					    &format_name);

(randomly picking a driver for this comment)

As a candidate for another patch series, what would you think about storing format names in the format info structure, and getting rid of the drm_get_format_name() function ? It might increase the kernel size a bit though, but I don't think that's an issue.

Quoted 3 lines
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
 		} else {
 			sprintf(format_name.str, "N/A");
 		}

[snip]

Quoted 5 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_display.c index 6c889f0e8e0f..f5f9f1422d69 100644

drivers/gpu/drm/i915/intel_display.c +0 -0

[snip]

drivers/gpu/drm/i915/intel_display.c static int intel_crtc_page_flip(struct drm_crtc · line 12151

Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +1 -1
@@ -12151,7 +12148,7 @@ static int intel_crtc_page_flip(struct drm_crtc
 *crtc, return -EBUSY;
 
 	/* Can't change pixel format via MI display flips. */
-	if (fb->pixel_format != crtc->primary->fb->pixel_format)
+	if (fb->format->format != crtc->primary->fb->format->format)

You can write this

	fb->format != crtc->primary->fb->format
Quoted 1 line
drivers/gpu/drm/i915/intel_display.c +0 -0
 		return -EINVAL;

[snip]

drivers/gpu/drm/imx/ipuv3-plane.c drm_plane_state_to_eba(struct drm_plane_state *state) · line 80

Quoted 10 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/imx/ipuv3-plane.c index e74a0ad52950..76fcc5f0d9e1 100644

drivers/gpu/drm/imx/ipuv3-plane.c +1 -1
@@ -77,7 +77,7 @@ drm_plane_state_to_eba(struct drm_plane_state *state)
 	BUG_ON(!cma_obj);
 
 	return cma_obj->paddr + fb->offsets[0] + fb->pitches[0] * y +
-	       drm_format_plane_cpp(fb->pixel_format, 0) * x;
+	       drm_format_plane_cpp(fb->format->format, 0) * x;

You should use fb->format->cpp[0]. Likewise for the other format information fields accessed in this driver.

Quoted 34 lines
drivers/gpu/drm/imx/ipuv3-plane.c +6 -6
 }
 
 static inline unsigned long
@@ -92,11 +92,11 @@ drm_plane_state_to_ubo(struct drm_plane_state *state)
 	cma_obj = drm_fb_cma_get_gem_obj(fb, 1);
 	BUG_ON(!cma_obj);
 
-	x /= drm_format_horz_chroma_subsampling(fb->pixel_format);
-	y /= drm_format_vert_chroma_subsampling(fb->pixel_format);
+	x /= drm_format_horz_chroma_subsampling(fb->format->format);
+	y /= drm_format_vert_chroma_subsampling(fb->format->format);
 
 	return cma_obj->paddr + fb->offsets[1] + fb->pitches[1] * y +
-	       drm_format_plane_cpp(fb->pixel_format, 1) * x - eba;
+	       drm_format_plane_cpp(fb->format->format, 1) * x - eba;
 }
 
 static inline unsigned long
@@ -111,11 +111,11 @@ drm_plane_state_to_vbo(struct drm_plane_state *state)
 	cma_obj = drm_fb_cma_get_gem_obj(fb, 2);
 	BUG_ON(!cma_obj);
 
-	x /= drm_format_horz_chroma_subsampling(fb->pixel_format);
-	y /= drm_format_vert_chroma_subsampling(fb->pixel_format);
+	x /= drm_format_horz_chroma_subsampling(fb->format->format);
+	y /= drm_format_vert_chroma_subsampling(fb->format->format);
 
 	return cma_obj->paddr + fb->offsets[2] + fb->pitches[2] * y +
-	       drm_format_plane_cpp(fb->pixel_format, 2) * x - eba;
+	       drm_format_plane_cpp(fb->format->format, 2) * x - eba;
 }
 
 void ipu_plane_put_resources(struct ipu_plane *ipu_plane)

drivers/gpu/drm/imx/ipuv3-plane.c static int ipu_plane_atomic_check(struct drm_plane · line 284

Quoted 5 lines
drivers/gpu/drm/imx/ipuv3-plane.c +1 -1
@@ -281,7 +281,7 @@ static int ipu_plane_atomic_check(struct drm_plane
 *plane, */
 	if (old_fb && (state->src_w != old_state->src_w ||
 			      state->src_h != old_state->src_h ||
-			      fb->pixel_format != old_fb->pixel_format))
+			      fb->format->format != old_fb->format->format))
	fb->format != old_fb->format

Likewise for the other locations in this driver.

[snip]

drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c static int mdp5_plane_atomic_check(struct drm_plane · line 344

Quoted 12 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c index
81c0562ab489..fb32d4563d92 100644

drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +1 -1
@@ -340,7 +340,7 @@ static int mdp5_plane_atomic_check(struct drm_plane
 *plane, if (plane_enabled(state) && plane_enabled(old_state)) {
 		/* we cannot change SMP block configuration during scanout: */
 		bool full_modeset = false;
-		if (state->fb->pixel_format != old_state->fb->pixel_format) {
+		if (state->fb->format->format != old_state->fb->format-
 format) {

Ditto.

drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c static int mdp5_plane_mode_set(struct drm_plane *plane, · line 706

Quoted 9 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +0 -0
 			DBG("%s: pixel_format change!", mdp5_plane->name);
 			full_modeset = true;
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +1 -1
 		}
@@ -703,7 +703,7 @@ static int mdp5_plane_mode_set(struct drm_plane *plane,
 	unsigned long flags;
 	int ret;
 
-	nplanes = drm_format_num_planes(fb->pixel_format);
+	nplanes = drm_format_num_planes(fb->format->format);
	fb->format->num_planes
Quoted 11 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +0 -0
 	/* bad formats should already be rejected: */
 	if (WARN_ON(nplanes > pipe2nclients(pipe)))
drivers/gpu/drm/msm/msm_fb.c +0 -0
index 9614ed405808..5b579248fbaa 100644
@@ -41,7 +41,7 @@ static int msm_framebuffer_create_handle(struct

drm_framebuffer *fb, static void msm_framebuffer_destroy(struct drm_framebuffer *fb)
{

drivers/gpu/drm/msm/msm_fb.c static int msm_framebuffer_create_handle(struct drm_framebuffer *fb, · line 44

Quoted 3 lines
drivers/gpu/drm/msm/msm_fb.c +1 -1
 	struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-	int i, n = drm_format_num_planes(fb->pixel_format);
+	int i, n = drm_format_num_planes(fb->format->format);

Same here and below.

Quoted 34 lines
drivers/gpu/drm/msm/msm_fb.c +0 -0
 	DBG("destroy: FB ID: %d (%p)", fb->base.id, fb);
@@ -65,10 +65,10 @@ static const struct drm_framebuffer_funcs

msm_framebuffer_funcs = { void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m) {

drivers/gpu/drm/msm/msm_fb.c +3 -3
 	struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-	int i, n = drm_format_num_planes(fb->pixel_format);
+	int i, n = drm_format_num_planes(fb->format->format);
 
 	seq_printf(m, "fb: %dx%d@%4.4s (%2d, ID:%d)\n",
-			fb->width, fb->height, (char *)&fb->pixel_format,
+			fb->width, fb->height, (char *)&fb->format->format,
 			drm_framebuffer_read_refcount(fb), fb->base.id);
 
 	for (i = 0; i < n; i++) {
@@ -87,7 +87,7 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb,
 struct seq_file *m) int msm_framebuffer_prepare(struct drm_framebuffer *fb,
 int id)
 {
 	struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-	int ret, i, n = drm_format_num_planes(fb->pixel_format);
+	int ret, i, n = drm_format_num_planes(fb->format->format);
 	uint32_t iova;
 
drivers/gpu/drm/msm/msm_fb.c +1 -1
 	for (i = 0; i < n; i++) {
@@ -103,7 +103,7 @@ int msm_framebuffer_prepare(struct drm_framebuffer *fb,
 int id) void msm_framebuffer_cleanup(struct drm_framebuffer *fb, int id)
 {
 	struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
-	int i, n = drm_format_num_planes(fb->pixel_format);
+	int i, n = drm_format_num_planes(fb->format->format);
 
 	for (i = 0; i < n; i++)
 		msm_gem_put_iova(msm_fb->planes[i], id);

[snip]

drivers/gpu/drm/omapdrm/omap_fb.c static int omap_framebuffer_create_handle(struct drm_framebuffer *fb, · line 110

Quoted 11 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/omapdrm/omap_fb.c index 9875c99be009..d2742772b9d8 100644

drivers/gpu/drm/omapdrm/omap_fb.c +0 -0
@@ -107,7 +107,7 @@ static int omap_framebuffer_create_handle(struct

drm_framebuffer *fb, static void omap_framebuffer_destroy(struct drm_framebuffer *fb)
{

drivers/gpu/drm/omapdrm/omap_fb.c +1 -1
 	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	int i, n = drm_format_num_planes(fb->pixel_format);
+	int i, n = drm_format_num_planes(fb->format->format);
	fb->format->num_planes

Same comment for the other locations below.

Quoted 33 lines
drivers/gpu/drm/omapdrm/omap_fb.c +4 -4
 	DBG("destroy: FB ID: %d (%p)", fb->base.id, fb);
@@ -252,7 +252,7 @@ void omap_framebuffer_update_scanout(struct
 drm_framebuffer *fb, int omap_framebuffer_pin(struct drm_framebuffer *fb)
 {
 	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	int ret, i, n = drm_format_num_planes(fb->pixel_format);
+	int ret, i, n = drm_format_num_planes(fb->format->format);
 
 	mutex_lock(&omap_fb->lock);
 
@@ -292,7 +292,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
 void omap_framebuffer_unpin(struct drm_framebuffer *fb)
 {
 	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	int i, n = drm_format_num_planes(fb->pixel_format);
+	int i, n = drm_format_num_planes(fb->format->format);
 
 	mutex_lock(&omap_fb->lock);
 
@@ -343,10 +343,10 @@ struct drm_connector
 *omap_framebuffer_get_next_connector( void omap_framebuffer_describe(struct
 drm_framebuffer *fb, struct seq_file *m) {
 	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	int i, n = drm_format_num_planes(fb->pixel_format);
+	int i, n = drm_format_num_planes(fb->format->format);
 
 	seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height,
-			(char *)&fb->pixel_format);
+			(char *)&fb->format->format);
 
 	for (i = 0; i < n; i++) {
 		struct plane *plane = &omap_fb->planes[i];

[snip]

Quoted 5 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index c7eba305c488..f8c6f74edc80 100644

drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0 -0

[snip]

drivers/gpu/drm/rockchip/rockchip_drm_vop.c static void vop_plane_atomic_update(struct drm_plane · line 752

Quoted 6 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +1 -1
@@ -749,21 +749,21 @@ static void vop_plane_atomic_update(struct drm_plane
 *plane, dsp_sty = dest->y1 + crtc->mode.vtotal - crtc->mode.vsync_start;
 dsp_st = dsp_sty << 16 | (dsp_stx & 0xffff);
 
-	offset = (src->x1 >> 16) * drm_format_plane_cpp(fb->pixel_format, 0);
+	offset = (src->x1 >> 16) * drm_format_plane_cpp(fb->format->format, 

0);

fb->format->cpp[0]

Same comment for the other fields accessed below.

Quoted 26 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +4 -5
 	offset += (src->y1 >> 16) * fb->pitches[0];
 	dma_addr = rk_obj->dma_addr + offset + fb->offsets[0];
 
-	format = vop_convert_format(fb->pixel_format);
+	format = vop_convert_format(fb->format->format);
 
 	spin_lock(&vop->reg_lock);
 
 	VOP_WIN_SET(vop, win, format, format);
 	VOP_WIN_SET(vop, win, yrgb_vir, fb->pitches[0] >> 2);
 	VOP_WIN_SET(vop, win, yrgb_mst, dma_addr);
-	if (is_yuv_support(fb->pixel_format)) {
-		int hsub = drm_format_horz_chroma_subsampling(fb-
 pixel_format);
-		int vsub = drm_format_vert_chroma_subsampling(fb-
 pixel_format);
-		int bpp = drm_format_plane_cpp(fb->pixel_format, 1);
+	if (is_yuv_support(fb->format->format)) {
+		int hsub = drm_format_horz_chroma_subsampling(fb->format-
 format);
+		int vsub = drm_format_vert_chroma_subsampling(fb->format-

format);

drivers/gpu/drm/rockchip/rockchip_drm_vop.c +1 -0
+		int bpp = drm_format_plane_cpp(fb->format->format, 1);
 
 		uv_obj = rockchip_fb_get_gem_obj(fb, 1);
 		rk_uv_obj = to_rockchip_obj(uv_obj);

[snip]

Quoted 4 lines
drivers/gpu/drm/sti/sti_gdp.c +0 -0
index 81df3097b545..33821dda79df 100644

[snip]

drivers/gpu/drm/sti/sti_gdp.c static void sti_gdp_atomic_update(struct drm_plane · line 760

Quoted 11 lines
drivers/gpu/drm/sti/sti_gdp.c +2 -2
@@ -753,11 +753,11 @@ static void sti_gdp_atomic_update(struct drm_plane
 *drm_plane, cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
 
 	DRM_DEBUG_DRIVER("drm FB:%d format:%.4s phys@:0x%lx\n", fb->base.id,
-			 (char *)&fb->pixel_format,
+			 (char *)&fb->format->format,
 			 (unsigned long)cma_obj->paddr);
 
 	/* pixel memory location */
-	bpp = drm_format_plane_cpp(fb->pixel_format, 0);
+	bpp = drm_format_plane_cpp(fb->format->format, 0);

fb->format->cpp[0]

Quoted 10 lines
drivers/gpu/drm/sti/sti_gdp.c +0 -0
 	top_field->gam_gdp_pml = (u32)cma_obj->paddr + fb->offsets[0];
 	top_field->gam_gdp_pml += src_x * bpp;
 	top_field->gam_gdp_pml += src_y * fb->pitches[0];
(quoted diff) +0 -0

b/drivers/gpu/drm/sun4i/sun4i_backend.c index 2e08f969bb64..8719acf745c2 100644

drivers/gpu/drm/sun4i/sun4i_backend.c +0 -0

[snip]

drivers/gpu/drm/sun4i/sun4i_backend.c int sun4i_backend_update_layer_buffer(struct · line 223

Quoted 7 lines
drivers/gpu/drm/sun4i/sun4i_backend.c +1 -1
@@ -218,7 +219,7 @@ int sun4i_backend_update_layer_buffer(struct
 sun4i_backend *backend, DRM_DEBUG_DRIVER("Using GEM @ %pad\n",
 &gem->paddr);
 
 	/* Compute the start of the displayed memory */
-	bpp = drm_format_plane_cpp(fb->pixel_format, 0);
+	bpp = drm_format_plane_cpp(fb->format->format, 0);

Ditto.

Quoted 7 lines
drivers/gpu/drm/sun4i/sun4i_backend.c +0 -0
 	paddr = gem->paddr + fb->offsets[0];
 	paddr += (state->src_x >> 16) * bpp;
drivers/gpu/drm/sun4i/sun4i_backend.c +0 -0
 	paddr += (state->src_y >> 16) * fb->pitches[0];
drivers/gpu/drm/tegra/dc.c +0 -0
index 3af157a2d40c..4121d0c2aac8 100644

[snip]

drivers/gpu/drm/tegra/dc.c static int tegra_plane_atomic_check(struct drm_plane · line 534

Quoted 6 lines
drivers/gpu/drm/tegra/dc.c +1 -1
@@ -531,7 +531,7 @@ static int tegra_plane_atomic_check(struct drm_plane
 *plane, * error out if the user tries to display a framebuffer with such a
 * configuration.
 	 */
-	if (drm_format_num_planes(state->fb->pixel_format) > 2) {
+	if (drm_format_num_planes(state->fb->format->format) > 2) {

state->fb->format->num_planes

drivers/gpu/drm/tegra/dc.c static void tegra_plane_atomic_update(struct drm_plane · line 579

Quoted 9 lines
drivers/gpu/drm/tegra/dc.c +1 -1
 		if (state->fb->pitches[2] != state->fb->pitches[1]) {
 			DRM_ERROR("unsupported UV-plane configuration\n");
 			return -EINVAL;
@@ -576,7 +576,7 @@ static void tegra_plane_atomic_update(struct drm_plane
 *plane, window.format = state->format;
 	window.swap = state->swap;
 
-	for (i = 0; i < drm_format_num_planes(fb->pixel_format); i++) {
+	for (i = 0; i < drm_format_num_planes(fb->format->format); i++) {

Same here.

drivers/gpu/drm/tegra/fb.c struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer · line 35

Quoted 13 lines
drivers/gpu/drm/tegra/dc.c +0 -0
 		struct tegra_bo *bo = tegra_fb_get_plane(fb, i);
 
 		window.base[i] = bo->paddr + fb->offsets[i];
drivers/gpu/drm/tegra/fb.c +1 -1
index 2a1bf92403b8..1ea5c39a4411 100644
@@ -32,7 +32,7 @@ struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer
 *framebuffer, {
 	struct tegra_fb *fb = to_tegra_fb(framebuffer);
 
-	if (index >= drm_format_num_planes(framebuffer->pixel_format))
+	if (index >= drm_format_num_planes(framebuffer->format->format))

And here.

Quoted 9 lines
drivers/gpu/drm/tegra/fb.c +0 -0
 		return NULL;
 
 	return fb->planes[index];
(quoted diff) +0 -0

b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c index 822531ebd4b0..d00c59e115ff 100644

drivers/gpu/drm/tilcdc/tilcdc_crtc.c static void set_scanout(struct drm_crtc *crtc, struct · line 83

Quoted 6 lines
drivers/gpu/drm/tilcdc/tilcdc_crtc.c +1 -1
@@ -79,7 +79,7 @@ static void set_scanout(struct drm_crtc *crtc, struct
 drm_framebuffer *fb)
 
 	start = gem->paddr + fb->offsets[0] +
 		crtc->y * fb->pitches[0] +
-		crtc->x * drm_format_plane_cpp(fb->pixel_format, 0);
+		crtc->x * drm_format_plane_cpp(fb->format->format, 0);

I think you know what to do by now :-)

Quoted 2 lines
drivers/gpu/drm/tilcdc/tilcdc_crtc.c +0 -0
 	end = start + (crtc->mode.vdisplay * fb->pitches[0]);

[snip]

drivers/gpu/drm/tilcdc/tilcdc_plane.c static int tilcdc_plane_atomic_check(struct drm_plane · line 72

Quoted 11 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/tilcdc/tilcdc_plane.c index 8a6a50d74aff..5a303a81ac96 100644

drivers/gpu/drm/tilcdc/tilcdc_plane.c +1 -1
@@ -69,7 +69,7 @@ static int tilcdc_plane_atomic_check(struct drm_plane
 *plane, }
 
 	pitch = crtc_state->mode.hdisplay *
-		drm_format_plane_cpp(state->fb->pixel_format, 0);
+		drm_format_plane_cpp(state->fb->format->format, 0);

Ditto.

drivers/gpu/drm/tilcdc/tilcdc_plane.c static int tilcdc_plane_atomic_check(struct drm_plane · line 80

Quoted 9 lines
drivers/gpu/drm/tilcdc/tilcdc_plane.c +1 -1
 	if (state->fb->pitches[0] != pitch) {
 		dev_err(plane->dev->dev,
 			"Invalid pitch: fb and crtc widths must be the same");
@@ -77,7 +77,7 @@ static int tilcdc_plane_atomic_check(struct drm_plane
 *plane, }
 
 	if (state->fb && old_state->fb &&
-	    state->fb->pixel_format != old_state->fb->pixel_format) {
+	    state->fb->format->format != old_state->fb->format->format) {

state->fb->format != old_state->fb->format

Quoted 7 lines
drivers/gpu/drm/tilcdc/tilcdc_plane.c +0 -0
 		dev_dbg(plane->dev->dev,
 			"%s(): pixel format change requires mode_change\n",
 			__func__);
(quoted diff) +0 -0

b/drivers/gpu/drm/vc4/vc4_plane.c index 881bf489478b..59be9e7c26de 100644

drivers/gpu/drm/vc4/vc4_plane.c +0 -0

[snip]

drivers/gpu/drm/vc4/vc4_plane.c static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state) · line 372

Quoted 6 lines
drivers/gpu/drm/vc4/vc4_plane.c +0 -0
@@ -369,7 +369,7 @@ static int vc4_plane_setup_clipping_and_scaling(struct

drm_plane_state *state) */

drivers/gpu/drm/vc4/vc4_plane.c +1 -1
 	if (vc4_state->crtc_x < 0) {
 		for (i = 0; i < num_planes; i++) {
-			u32 cpp = drm_format_plane_cpp(fb->pixel_format, i);
+			u32 cpp = drm_format_plane_cpp(fb->format->format, i);

fb->format->cpp[i]

Quoted 3 lines
drivers/gpu/drm/vc4/vc4_plane.c +0 -0
 			u32 subs = ((i == 0) ? 1 : h_subsample);
 
 			vc4_state->offsets[i] += (cpp *

[snip]

Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel