All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/37] drm: Deduplicate fb format information (v2)
@ 2016-11-18 19:52 ville.syrjala
  2016-11-18 19:52 ` [PATCH 01/37] drm/i915: Add local 'fb' variables ville.syrjala
                   ` (38 more replies)
  0 siblings, 39 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel
  Cc: Ben Widawsky, Gerd Hoffmann, Paulo Zanoni, Sinclair Yeh,
	Liviu Dudau, intel-gfx, Alexey Brodkin, Thomas Hellstrom,
	Christian König, linux-graphics-maintainer,
	Laurent Pinchart, Mali DP Maintainers, Alex Deucher, Dave Airlie,
	Ben Skeggs

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Second installment of my effort to remove the duplicated
depth/bpp/pixel_format from drm_framebuffer and just use
struct drm_format_info instead.

I tried to address all of the review feedback, and collect
up all the r-bs I already got. Thanks for the review, guys.

Changes since the last version are roughly:
* drm_framebuffer_init() now fails if the fb isn't properly prepared
* Applied mode cocciry all over to use fb->format more extensively
* Dropped a few i915 specific patches that were taken care of the
  previous item
* Took up Laurent's idea that we can just compare the fb->format
  pointers instead of comparing the fb->format->format values
* Added a new .get_format_info() hooks for drivers to provide custom
  format information + an quick example patch how we'd hook it up
  for i915 render compression support

Link to the previous version:
https://lists.freedesktop.org/archives/dri-devel/2016-November/124135.html

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

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Ben Widawsky <ben@bwidawsk.net>
Cc: Brian Starkey <brian.starkey@arm.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: intel-gfx@lists.freedesktop.org
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-graphics-maintainer@vmware.com
Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Mali DP Maintainers <malidp@foss.arm.com>
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Sinclair Yeh <syeh@vmware.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>

Ville Syrjälä (37):
  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: Reject fbs w/o format info in drm_framebuffer_init()
  drm: Replace drm_format_num_planes() with fb->format->num_planes
  drm/i915: Eliminate the ugly 'fb?:' constructs from the ilk/skl wm
    code
  drm: Replace drm_format_plane_cpp() with fb->format->cpp[]
  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: 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
  drm: Replace 'format->format' comparisons to just 'format' comparisons
  drm: Eliminate the useless "non-RGB fb" debug message
  drm: Add mode_config .get_format_info() hook
  drm/i915: Implement .get_format_info() hook for CCS

 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         |   6 +-
 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               |   3 +-
 drivers/gpu/drm/drm_fb_cma_helper.c             |  13 ++-
 drivers/gpu/drm/drm_fb_helper.c                 |  10 +--
 drivers/gpu/drm/drm_fourcc.c                    |  25 ++++++
 drivers/gpu/drm/drm_framebuffer.c               |  62 +++++++++++--
 drivers/gpu/drm/drm_modeset_helper.c            |  22 +----
 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            | 115 ++++++++++++++++--------
 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                 |  67 +++++++-------
 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        |   4 +-
 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                 |   8 +-
 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                  |   4 +-
 include/drm/drm_fourcc.h                        |   6 ++
 include/drm/drm_framebuffer.h                   |  27 +++---
 include/drm/drm_mode_config.h                   |  15 ++++
 include/drm/drm_modeset_helper.h                |   3 +-
 include/uapi/drm/drm_fourcc.h                   |   3 +
 110 files changed, 641 insertions(+), 470 deletions(-)

-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

* [PATCH 01/37] drm/i915: Add local 'fb' variables
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-30 14:44   ` Daniel Vetter
  2016-11-18 19:52 ` [PATCH 02/37] drm/radeon: " ville.syrjala
                   ` (37 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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.

Cc: intel-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_overlay.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_overlay.c b/drivers/gpu/drm/i915/intel_overlay.c
index fd0e4dac7cc1..ce3667c18e18 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -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;
 	}
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 02/37] drm/radeon: Add local 'fb' variables
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
  2016-11-18 19:52 ` [PATCH 01/37] drm/i915: Add local 'fb' variables ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-18 19:52 ` [PATCH 03/37] drm/radeon: Use DIV_ROUND_UP() ville.syrjala
                   ` (36 subsequent siblings)
  38 siblings, 0 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Laurent Pinchart, Christian König

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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 <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/radeon/r100.c               | 10 ++++++++--
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c |  3 ++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index f5e84f4b58e6..984b35f43554 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -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;
 		}
 	}
 
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index d0de4022fff9..bb5346812de4 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -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

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 03/37] drm/radeon: Use DIV_ROUND_UP()
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
  2016-11-18 19:52 ` [PATCH 01/37] drm/i915: Add local 'fb' variables ville.syrjala
  2016-11-18 19:52 ` [PATCH 02/37] drm/radeon: " ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-18 19:52 ` [PATCH 04/37] drm/mgag200: Add local 'fb' variable ville.syrjala
                   ` (35 subsequent siblings)
  38 siblings, 0 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Laurent Pinchart, Christian König

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index bb5346812de4..31c03e32a6b5 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -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

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 04/37] drm/mgag200: Add local 'fb' variable
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (2 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 03/37] drm/radeon: Use DIV_ROUND_UP() ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-30 14:45   ` Daniel Vetter
  2016-11-18 19:52 ` [PATCH 05/37] drm/ast: Add local 'fb' variables ville.syrjala
                   ` (34 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Dave Airlie, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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: Dave Airlie <airlied@redhat.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/mgag200/mgag200_mode.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
index 6b21cb27e1cc..bdac288ab16d 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -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;
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 05/37] drm/ast: Add local 'fb' variables
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (3 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 04/37] drm/mgag200: Add local 'fb' variable ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-30 14:47   ` Daniel Vetter
  2016-11-18 19:52 ` [PATCH 06/37] drm/gma500: Add some " ville.syrjala
                   ` (33 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Dave Airlie, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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: Dave Airlie <airlied@redhat.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/ast/ast_mode.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 5957c3e659fe..deb3684ccaf8 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -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:
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 06/37] drm/gma500: Add some local 'fb' variables
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (4 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 05/37] drm/ast: Add local 'fb' variables ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-30 14:49   ` Daniel Vetter
  2016-11-18 19:52 ` [PATCH 07/37] drm/cirrus: " ville.syrjala
                   ` (32 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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 <patrik.r.jakobsson@gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 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(-)

diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
index 1a1cf7a3b5ef..05b9a4ceb58d 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/mdfld_intel_display.c b/drivers/gpu/drm/gma500/mdfld_intel_display.c
index 92e3f93ee682..e80895285e94 100644
--- a/drivers/gpu/drm/gma500/mdfld_intel_display.c
+++ b/drivers/gpu/drm/gma500/mdfld_intel_display.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
index da9fd34b9550..a51896544d91 100644
--- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
+++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
@@ -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;
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 07/37] drm/cirrus: Add some local 'fb' variables
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (5 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 06/37] drm/gma500: Add some " ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-30 14:50   ` Daniel Vetter
  2016-11-18 19:52 ` [PATCH 08/37] drm/arcpgu: Add " ville.syrjala
                   ` (31 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Dave Airlie, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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: Dave Airlie <airlied@redhat.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/cirrus/cirrus_mode.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c b/drivers/gpu/drm/cirrus/cirrus_mode.c
index 17c915d9a03e..f2297acae235 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -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 */
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 08/37] drm/arcpgu: Add local 'fb' variables
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (6 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 07/37] drm/cirrus: " ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-21 15:30   ` Alexey Brodkin
  2016-11-23 16:00   ` Alexey Brodkin
  2016-11-18 19:52 ` [PATCH 09/37] drm/arm: " ville.syrjala
                   ` (30 subsequent siblings)
  38 siblings, 2 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Alexey Brodkin, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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.

Cc: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/arc/arcpgu_crtc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index 7130b044b004..5c26c5f126a3 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -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;
 
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 09/37] drm/arm: Add local 'fb' variables
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (7 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 08/37] drm/arcpgu: Add " ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-18 20:30   ` Brian Starkey
  2016-11-21 11:51   ` Liviu Dudau
  2016-11-18 19:52 ` [PATCH 10/37] drm/nouveau: Fix crtc->primary->fb vs. drm_fb fail ville.syrjala
                   ` (29 subsequent siblings)
  38 siblings, 2 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Mali DP Maintainers, Liviu Dudau, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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 <liviu.dudau@arm.com>
Cc: Brian Starkey <brian.starkey@arm.com>
Cc: Mali DP Maintainers <malidp@foss.arm.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/arm/hdlcd_crtc.c    | 18 ++++++++++--------
 drivers/gpu/drm/arm/malidp_planes.c |  6 +++---
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
index bbaa55add2d2..8a0fee03aa39 100644
--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
@@ -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);
 }
diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
index 63eec8f37cfc..ee7f7663a307 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -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;
 
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 10/37] drm/nouveau: Fix crtc->primary->fb vs. drm_fb fail
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (8 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 09/37] drm/arm: " ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-30 14:56   ` Daniel Vetter
  2016-11-18 19:52 ` [PATCH 11/37] drm/nouveau: Add local 'fb' variables ville.syrjala
                   ` (28 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart, Ben Skeggs

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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.

Cc: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 59d1d1c5de5f..7c6c66f177df 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -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,
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 11/37] drm/nouveau: Add local 'fb' variables
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (9 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 10/37] drm/nouveau: Fix crtc->primary->fb vs. drm_fb fail ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-30 14:57   ` Daniel Vetter
  2016-11-18 19:52 ` [PATCH 12/37] drm/vmwgfx: Populate fb->dev before drm_framebuffer_init() ville.syrjala
                   ` (27 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart, Ben Skeggs

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 5 +++--
 drivers/gpu/drm/nouveau/dispnv04/dfp.c  | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 7c6c66f177df..8286b8ffe109 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/dfp.c b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
index c2947ef7d4fc..945607b3cd41 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dfp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
@@ -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 {
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 12/37] drm/vmwgfx: Populate fb->dev before drm_framebuffer_init()
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (10 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 11/37] drm/nouveau: Add local 'fb' variables ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-21 17:10   ` Sinclair Yeh
  2016-11-22 13:53   ` [PATCH v2 " ville.syrjala
  2016-11-18 19:52 ` [PATCH 13/37] drm: Pass 'dev' to drm_helper_mode_fill_fb_struct() ville.syrjala
                   ` (26 subsequent siblings)
  38 siblings, 2 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Thomas Hellstrom, linux-graphics-maintainer, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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().

Cc: linux-graphics-maintainer@vmware.com
Cc: Sinclair Yeh <syeh@vmware.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index e3f68cc9bb4b..7d92ab56961b 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -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;
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 13/37] drm: Pass 'dev' to drm_helper_mode_fill_fb_struct()
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (11 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 12/37] drm/vmwgfx: Populate fb->dev before drm_framebuffer_init() ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-12-14 20:48   ` [PATCH v2 " ville.syrjala
  2016-11-18 19:52 ` [PATCH 14/37] drm/vmwgfx: Populate fb->pixel_format ville.syrjala
                   ` (25 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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);

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 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(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 741144fcc7bc..d492cf84ddc1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -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;
diff --git a/drivers/gpu/drm/armada/armada_fb.c b/drivers/gpu/drm/armada/armada_fb.c
index f03c212b754d..2a7eb6817c36 100644
--- a/drivers/gpu/drm/armada/armada_fb.c
+++ b/drivers/gpu/drm/armada/armada_fb.c
@@ -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) {
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index 904beaa932d0..d85af0ff2653 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -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) {
diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c
index 099a3c688c26..ceb1fecf02dd 100644
--- a/drivers/gpu/drm/bochs/bochs_mm.c
+++ b/drivers/gpu/drm/bochs/bochs_mm.c
@@ -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) {
diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c b/drivers/gpu/drm/cirrus/cirrus_main.c
index 2c3c0d4072ce..52d901fa8687 100644
--- a/drivers/gpu/drm/cirrus/cirrus_main.c
+++ b/drivers/gpu/drm/cirrus/cirrus_main.c
@@ -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) {
diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
index 81b3558302b5..570f5c6063f3 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -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];
diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index cc232ac6c950..285ffcba0fe8 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -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;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c
index 23cce0a3f5fc..68d414227533 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fb.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c
@@ -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) {
diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index 4071b2d1e8cf..6d89ed760941 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -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) {
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index bd2c99e2e523..12af936a402d 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -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);
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
index 147df85399ab..d4246c9dceae 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
@@ -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;
 
diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c
index e79cbc25ae3c..95d628b9457e 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -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) {
diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c
index 95cf8fe72ee5..9614ed405808 100644
--- a/drivers/gpu/drm/msm/msm_fb.c
+++ b/drivers/gpu/drm/msm/msm_fb.c
@@ -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) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 5698687bc197..a46d893aaafa 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -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);
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index 5f3337f1e9aa..9875c99be009 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -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) {
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index a61c0d460ec2..bcbad877ce4f 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -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;
 }
 
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index e7409e8a9f87..6285355eb5d5 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -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;
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
index 0f6eda023bd0..d5e1f8627d38 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
@@ -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];
diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index e4a5ab0a9677..a0096493f51c 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -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];
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index 167f42c67c7c..fefd87f422ec 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
index 58048709c34e..8b80fdd0e0a8 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -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;
diff --git a/include/drm/drm_modeset_helper.h b/include/drm/drm_modeset_helper.h
index b8051d5abe10..cb0ec92e11e6 100644
--- a/include/drm/drm_modeset_helper.h
+++ b/include/drm/drm_modeset_helper.h
@@ -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,
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 14/37] drm/vmwgfx: Populate fb->pixel_format
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (12 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 13/37] drm: Pass 'dev' to drm_helper_mode_fill_fb_struct() ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-21 17:10   ` Sinclair Yeh
  2016-11-18 19:52 ` [PATCH 15/37] drm/qxl: Call drm_helper_mode_fill_fb_struct() before drm_framebuffer_init() ville.syrjala
                   ` (24 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Thomas Hellstrom, linux-graphics-maintainer, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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.

Cc: linux-graphics-maintainer@vmware.com
Cc: Sinclair Yeh <syeh@vmware.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 7d92ab56961b..5788913ca8f9 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -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;
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 15/37] drm/qxl: Call drm_helper_mode_fill_fb_struct() before drm_framebuffer_init()
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (13 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 14/37] drm/vmwgfx: Populate fb->pixel_format ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-18 19:52 ` [PATCH 16/37] drm/virtio: " ville.syrjala
                   ` (23 subsequent siblings)
  38 siblings, 0 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Dave Airlie, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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().

Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/qxl/qxl_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index bcbad877ce4f..9e2c92b9d12e 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -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;
 }
 
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 16/37] drm/virtio: Call drm_helper_mode_fill_fb_struct() before drm_framebuffer_init()
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (14 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 15/37] drm/qxl: Call drm_helper_mode_fill_fb_struct() before drm_framebuffer_init() ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-30 15:32   ` Daniel Vetter
  2016-11-18 19:52 ` [PATCH 17/37] drm/i915: Set fb->dev early on for inherited fbs ville.syrjala
                   ` (22 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Dave Airlie, Laurent Pinchart, Gerd Hoffmann

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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 <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/virtio/virtgpu_display.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
index 8b80fdd0e0a8..fad5a1cc5903 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -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;
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 17/37] drm/i915: Set fb->dev early on for inherited fbs
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (15 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 16/37] drm/virtio: " ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-30 15:36   ` Daniel Vetter
  2016-11-18 19:52 ` [PATCH v2 18/37] drm: Populate fb->dev from drm_helper_mode_fill_fb_struct() ville.syrjala
                   ` (21 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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.

Cc: intel-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 12af936a402d..74a638c8de61 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -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;
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH v2 18/37] drm: Populate fb->dev from drm_helper_mode_fill_fb_struct()
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (16 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 17/37] drm/i915: Set fb->dev early on for inherited fbs ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-18 19:52 ` [PATCH v2 19/37] drm: Store a pointer to drm_format_info under drm_framebuffer ville.syrjala
                   ` (20 subsequent siblings)
  38 siblings, 0 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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().

v2: Reject fbs with invalid fb->dev (Laurent)

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)
---
 drivers/gpu/drm/drm_framebuffer.c    | 5 ++++-
 drivers/gpu/drm/drm_modeset_helper.c | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index cbf0c893f426..f397565d3c20 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -631,8 +631,11 @@ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
 {
 	int ret;
 
+	if (WARN_ON_ONCE(fb->dev != dev))
+		return -EINVAL;
+
 	INIT_LIST_HEAD(&fb->filp_head);
-	fb->dev = dev;
+
 	fb->funcs = funcs;
 
 	ret = drm_mode_object_get_reg(dev, &fb->base, DRM_MODE_OBJECT_FB,
diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index 285ffcba0fe8..57a319e3f780 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -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++) {
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH v2 19/37] drm: Store a pointer to drm_format_info under drm_framebuffer
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (17 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH v2 18/37] drm: Populate fb->dev from drm_helper_mode_fill_fb_struct() ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-19  2:33   ` Laurent Pinchart
  2016-11-18 19:52 ` [PATCH 20/37] drm/vmwgfx: Populate fb->format correctly ville.syrjala
                   ` (19 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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

v2: Don't populate the fb->format pointer in drm_framebuffer_init().
    instead we'll treat a NULL format as an error later

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)
---
 drivers/gpu/drm/drm_modeset_helper.c | 1 +
 include/drm/drm_framebuffer.h        | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index 57a319e3f780..1aa5e3bcc8a1 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -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++) {
diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
index b3141a0e609b..741b3a994d1f 100644
--- a/include/drm/drm_framebuffer.h
+++ b/include/drm/drm_framebuffer.h
@@ -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;
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 20/37] drm/vmwgfx: Populate fb->format correctly
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (18 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH v2 19/37] drm: Store a pointer to drm_format_info under drm_framebuffer ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-30 15:40   ` Daniel Vetter
  2016-11-30 15:52   ` Daniel Vetter
  2016-11-18 19:52 ` [PATCH 21/37] drm/i915: Populate fb->format early for inherited fbs ville.syrjala
                   ` (18 subsequent siblings)
  38 siblings, 2 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Thomas Hellstrom, linux-graphics-maintainer, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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

Cc: linux-graphics-maintainer@vmware.com
Cc: Sinclair Yeh <syeh@vmware.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 5788913ca8f9..77f936e3056e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -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;
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 21/37] drm/i915: Populate fb->format early for inherited fbs
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (19 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 20/37] drm/vmwgfx: Populate fb->format correctly ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-30 15:42   ` Daniel Vetter
  2016-11-18 19:52 ` [PATCH 22/37] drm: Reject fbs w/o format info in drm_framebuffer_init() ville.syrjala
                   ` (17 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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.

Cc: intel-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 74a638c8de61..c45da6766fff 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -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)) {
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 22/37] drm: Reject fbs w/o format info in drm_framebuffer_init()
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (20 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 21/37] drm/i915: Populate fb->format early for inherited fbs ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-19  2:36   ` Laurent Pinchart
  2016-11-18 19:52 ` [PATCH 23/37] drm: Replace drm_format_num_planes() with fb->format->num_planes ville.syrjala
                   ` (16 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Any framebuffer that doesn't have proper format information when
drm_framebuffer_init() is called is a bug. Let's warn and return
an error to avoid oopsing the kernel later due to dereferencing the
NULL fb->format pointer.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_framebuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index f397565d3c20..892976d974e5 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -631,7 +631,7 @@ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
 {
 	int ret;
 
-	if (WARN_ON_ONCE(fb->dev != dev))
+	if (WARN_ON_ONCE(fb->dev != dev || !fb->format))
 		return -EINVAL;
 
 	INIT_LIST_HEAD(&fb->filp_head);
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 23/37] drm: Replace drm_format_num_planes() with fb->format->num_planes
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (21 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 22/37] drm: Reject fbs w/o format info in drm_framebuffer_init() ville.syrjala
@ 2016-11-18 19:52 ` ville.syrjala
  2016-11-19  2:41   ` Laurent Pinchart
  2016-12-14 21:30   ` [PATCH v2 " ville.syrjala
  2016-11-18 19:53 ` [PATCH 24/37] drm/i915: Eliminate the ugly 'fb?:' constructs from the ilk/skl wm code ville.syrjala
                   ` (15 subsequent siblings)
  38 siblings, 2 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:52 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Replace drm_format_num_planes(fb->pixel_format) with just
fb->format->num_planes. Avoids the expensive format info lookup.

@@
struct drm_framebuffer *a;
struct drm_framebuffer b;
@@
(
- drm_format_num_planes(a->pixel_format)
+ a->format->num_planes
|
- drm_format_num_planes(b.pixel_format)
+ b.format->num_planes
)

@@
struct drm_plane_state *a;
struct drm_plane_state b;
@@
(
- drm_format_num_planes(a->fb->pixel_format)
+ a->fb->format->num_planes
|
- drm_format_num_planes(b.fb->pixel_format)
+ b.fb->format->num_planes
)

@@
struct drm_framebuffer *a;
identifier T;
@@
  T = a->pixel_format
<+...
- drm_format_num_planes(T)
+ a->format->num_planes
...+>

@@
struct drm_framebuffer b;
identifier T;
@@
  T = b.pixel_format
<+...
- drm_format_num_planes(T)
+ b.format->num_planes
...+>

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/arm/malidp_planes.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 | 2 +-
 drivers/gpu/drm/drm_atomic.c                    | 2 +-
 drivers/gpu/drm/i915/intel_display.c            | 2 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c       | 2 +-
 drivers/gpu/drm/msm/msm_fb.c                    | 8 ++++----
 drivers/gpu/drm/omapdrm/omap_fb.c               | 8 ++++----
 drivers/gpu/drm/tegra/dc.c                      | 4 ++--
 drivers/gpu/drm/tegra/fb.c                      | 2 +-
 drivers/gpu/drm/vc4/vc4_plane.c                 | 2 +-
 12 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
index ee7f7663a307..533ee2fa64be 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -116,7 +116,7 @@ static int malidp_de_plane_check(struct drm_plane *plane,
 	if (ms->format == MALIDP_INVALID_FORMAT_ID)
 		return -EINVAL;
 
-	ms->n_planes = drm_format_num_planes(fb->pixel_format);
+	ms->n_planes = fb->format->num_planes;
 	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",
diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
index 152b4e716269..903fff422e92 100644
--- a/drivers/gpu/drm/armada/armada_overlay.c
+++ b/drivers/gpu/drm/armada/armada_overlay.c
@@ -184,7 +184,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 
 		pixel_format = fb->pixel_format;
 		hsub = drm_format_horz_chroma_subsampling(pixel_format);
-		num_planes = drm_format_num_planes(pixel_format);
+		num_planes = fb->format->num_planes;
 
 		/*
 		 * Annoyingly, shifting a YUYV-format image by one pixel
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c
index 377e43cea9dd..63dfdbf34f80 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c
@@ -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 = fb->format->num_planes;
 
 	if (nplanes > layer->max_planes)
 		return;
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index 246ed1e33d8a..f97ae75f9e63 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -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 = fb->format->num_planes;
 	if (state->nplanes > ATMEL_HLCDC_MAX_PLANES)
 		return -EINVAL;
 
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 85466cc67819..cb6ab0106b0b 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -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",
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index c45da6766fff..c19d8bdf46d8 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -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++) {
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index 81c0562ab489..8c985c8e23f2 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -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 = fb->format->num_planes;
 
 	/* bad formats should already be rejected: */
 	if (WARN_ON(nplanes > pipe2nclients(pipe)))
diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c
index 9614ed405808..5cad5e9a07c9 100644
--- a/drivers/gpu/drm/msm/msm_fb.c
+++ b/drivers/gpu/drm/msm/msm_fb.c
@@ -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 = fb->format->num_planes;
 
 	DBG("destroy: FB ID: %d (%p)", fb->base.id, fb);
 
@@ -65,7 +65,7 @@ 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 = fb->format->num_planes;
 
 	seq_printf(m, "fb: %dx%d@%4.4s (%2d, ID:%d)\n",
 			fb->width, fb->height, (char *)&fb->pixel_format,
@@ -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 = fb->format->num_planes;
 	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 = fb->format->num_planes;
 
 	for (i = 0; i < n; i++)
 		msm_gem_put_iova(msm_fb->planes[i], id);
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index 9875c99be009..c6ef457b9fca 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -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 = fb->format->num_planes;
 
 	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 = fb->format->num_planes;
 
 	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 = fb->format->num_planes;
 
 	mutex_lock(&omap_fb->lock);
 
@@ -343,7 +343,7 @@ 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 = fb->format->num_planes;
 
 	seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height,
 			(char *)&fb->pixel_format);
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 4010d69cbd08..b60c306190e9 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -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 (state->fb->format->num_planes > 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 < fb->format->num_planes; i++) {
 		struct tegra_bo *bo = tegra_fb_get_plane(fb, i);
 
 		window.base[i] = bo->paddr + fb->offsets[i];
diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index a0096493f51c..8a4aea211e94 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -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 >= framebuffer->format->num_planes)
 		return NULL;
 
 	return fb->planes[index];
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
index 881bf489478b..a7fb581c7c55 100644
--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -296,7 +296,7 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
 	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;
-	int num_planes = drm_format_num_planes(format);
+	int num_planes = fb->format->num_planes;
 	u32 h_subsample = 1;
 	u32 v_subsample = 1;
 	int i;
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 24/37] drm/i915: Eliminate the ugly 'fb?:' constructs from the ilk/skl wm code
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (22 preceding siblings ...)
  2016-11-18 19:52 ` [PATCH 23/37] drm: Replace drm_format_num_planes() with fb->format->num_planes ville.syrjala
@ 2016-11-18 19:53 ` ville.syrjala
  2016-11-30 15:51   ` [Intel-gfx] " Daniel Vetter
  2016-11-18 19:53 ` [PATCH 25/37] drm: Replace drm_format_plane_cpp() with fb->format->cpp[] ville.syrjala
                   ` (14 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:53 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Don't access plane_state->fb until we know the plane to be visible.
It it's visible, it will have an fb, and thus we don't have to
consider the NULL fb case. Makes the code look nicer.

Cc: intel-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_pm.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index bbb1eaf1e6db..8ba7413872dd 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -1781,13 +1781,14 @@ static uint32_t ilk_compute_pri_wm(const struct intel_crtc_state *cstate,
 				   uint32_t mem_value,
 				   bool is_lp)
 {
-	int cpp = pstate->base.fb ?
-		drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0;
 	uint32_t method1, method2;
+	int cpp;
 
 	if (!cstate->base.active || !pstate->base.visible)
 		return 0;
 
+	cpp = drm_format_plane_cpp(pstate->base.fb->pixel_format, 0);
+
 	method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value);
 
 	if (!is_lp)
@@ -1809,13 +1810,14 @@ static uint32_t ilk_compute_spr_wm(const struct intel_crtc_state *cstate,
 				   const struct intel_plane_state *pstate,
 				   uint32_t mem_value)
 {
-	int cpp = pstate->base.fb ?
-		drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0;
 	uint32_t method1, method2;
+	int cpp;
 
 	if (!cstate->base.active || !pstate->base.visible)
 		return 0;
 
+	cpp = drm_format_plane_cpp(pstate->base.fb->pixel_format, 0);
+
 	method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value);
 	method2 = ilk_wm_method2(ilk_pipe_pixel_rate(cstate),
 				 cstate->base.adjusted_mode.crtc_htotal,
@@ -1853,12 +1855,13 @@ static uint32_t ilk_compute_fbc_wm(const struct intel_crtc_state *cstate,
 				   const struct intel_plane_state *pstate,
 				   uint32_t pri_val)
 {
-	int cpp = pstate->base.fb ?
-		drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0;
+	int cpp;
 
 	if (!cstate->base.active || !pstate->base.visible)
 		return 0;
 
+	cpp = drm_format_plane_cpp(pstate->base.fb->pixel_format, 0);
+
 	return ilk_wm_fbc(pri_val, drm_rect_width(&pstate->base.dst), cpp);
 }
 
@@ -3229,13 +3232,17 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
 			     int y)
 {
 	struct intel_plane_state *intel_pstate = to_intel_plane_state(pstate);
-	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;
+	struct drm_framebuffer *fb;
+	u32 format;
 
 	if (!intel_pstate->base.visible)
 		return 0;
+
+	fb = pstate->fb;
+	format = fb->pixel_format;
+
 	if (pstate->plane->type == DRM_PLANE_TYPE_CURSOR)
 		return 0;
 	if (y && format != DRM_FORMAT_NV12)
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 25/37] drm: Replace drm_format_plane_cpp() with fb->format->cpp[]
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (23 preceding siblings ...)
  2016-11-18 19:53 ` [PATCH 24/37] drm/i915: Eliminate the ugly 'fb?:' constructs from the ilk/skl wm code ville.syrjala
@ 2016-11-18 19:53 ` ville.syrjala
  2016-11-19  2:44   ` Laurent Pinchart
  2016-12-14 21:30   ` [PATCH v2 " ville.syrjala
  2016-11-18 19:53 ` [PATCH 26/37] drm/fb_cma_helper: Replace drm_format_info() with fb->format ville.syrjala
                   ` (13 subsequent siblings)
  38 siblings, 2 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Replace drm_format_plane_cpp(fb->pixel_format) with just
fb->format->cpp[]. Avoids the expensive format info lookup.

@@
struct drm_framebuffer *a;
struct drm_framebuffer b;
expression E;
@@
(
- drm_format_plane_cpp(a->pixel_format, E)
+ a->format->cpp[E]
|
- drm_format_plane_cpp(b.pixel_format, E)
+ b.format->cpp[E]
)

@@
struct drm_plane_state *a;
struct drm_plane_state b;
expression E;
@@
(
- drm_format_plane_cpp(a->fb->pixel_format, E)
+ a->fb->format->cpp[E]
|
- drm_format_plane_cpp(b.fb->pixel_format, E)
+ b.fb->format->cpp[E]
)

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

@@
struct drm_framebuffer b;
identifier T;
expression E;
@@
  T = b.pixel_format
<+...
- drm_format_plane_cpp(T, E)
+ b.format->cpp[E]
...+>

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/arm/hdlcd_crtc.c                |  2 +-
 drivers/gpu/drm/armada/armada_overlay.c         |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c |  2 +-
 drivers/gpu/drm/i915/intel_display.c            | 16 +++++-----
 drivers/gpu/drm/i915/intel_pm.c                 | 42 ++++++++++++-------------
 drivers/gpu/drm/i915/intel_sprite.c             |  2 +-
 drivers/gpu/drm/imx/ipuv3-plane.c               |  6 ++--
 drivers/gpu/drm/mediatek/mtk_drm_plane.c        |  2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c     |  4 +--
 drivers/gpu/drm/sti/sti_gdp.c                   |  2 +-
 drivers/gpu/drm/sun4i/sun4i_backend.c           |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c            |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_plane.c           |  2 +-
 drivers/gpu/drm/vc4/vc4_plane.c                 |  2 +-
 drivers/gpu/drm/zte/zx_plane.c                  |  2 +-
 15 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
index 8a0fee03aa39..5c19c25729cb 100644
--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
@@ -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);
+		fb->format->cpp[0];
 
 	hdlcd = plane->dev->dev_private;
 	hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_LENGTH, fb->pitches[0]);
diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
index 903fff422e92..e2ad408c2f24 100644
--- a/drivers/gpu/drm/armada/armada_overlay.c
+++ b/drivers/gpu/drm/armada/armada_overlay.c
@@ -197,7 +197,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 		for (i = 0; i < num_planes; i++)
 			addr[i] = obj->dev_addr + fb->offsets[i] +
 				  src_y * fb->pitches[i] +
-				  src_x * drm_format_plane_cpp(pixel_format, i);
+				  src_x * fb->format->cpp[i];
 		for (; i < ARRAY_SIZE(addr); i++)
 			addr[i] = 0;
 
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index f97ae75f9e63..3e00512ef187 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -672,7 +672,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
 		int xdiv = i ? hsub : 1;
 		int ydiv = i ? vsub : 1;
 
-		state->bpp[i] = drm_format_plane_cpp(fb->pixel_format, i);
+		state->bpp[i] = fb->format->cpp[i];
 		if (!state->bpp[i])
 			return -EINVAL;
 
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index c19d8bdf46d8..8f63fd38deee 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -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 {
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 8ba7413872dd..f94fe998b0ee 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -652,7 +652,7 @@ static void pineview_update_wm(struct intel_crtc *unused_crtc)
 			&crtc->config->base.adjusted_mode;
 		const struct drm_framebuffer *fb =
 			crtc->base.primary->state->fb;
-		int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+		int cpp = fb->format->cpp[0];
 		int clock = adjusted_mode->crtc_clock;
 
 		/* Display SR */
@@ -727,7 +727,7 @@ static bool g4x_compute_wm0(struct drm_i915_private *dev_priv,
 	clock = adjusted_mode->crtc_clock;
 	htotal = adjusted_mode->crtc_htotal;
 	hdisplay = crtc->config->pipe_src_w;
-	cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+	cpp = fb->format->cpp[0];
 
 	/* Use the small buffer method to calculate plane watermark */
 	entries = ((clock * cpp / 1000) * display_latency_ns) / 1000;
@@ -816,7 +816,7 @@ static bool g4x_compute_srwm(struct drm_i915_private *dev_priv,
 	clock = adjusted_mode->crtc_clock;
 	htotal = adjusted_mode->crtc_htotal;
 	hdisplay = crtc->config->pipe_src_w;
-	cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+	cpp = fb->format->cpp[0];
 
 	line_time_us = max(htotal * 1000 / clock, 1);
 	line_count = (latency_ns / line_time_us + 1000) / 1000;
@@ -963,7 +963,7 @@ static uint16_t vlv_compute_wm_level(struct intel_plane *plane,
 	if (!state->base.visible)
 		return 0;
 
-	cpp = drm_format_plane_cpp(state->base.fb->pixel_format, 0);
+	cpp = state->base.fb->format->cpp[0];
 	clock = crtc->config->base.adjusted_mode.crtc_clock;
 	htotal = crtc->config->base.adjusted_mode.crtc_htotal;
 	width = crtc->config->pipe_src_w;
@@ -1004,7 +1004,7 @@ static void vlv_compute_fifo(struct intel_crtc *crtc)
 
 		if (state->base.visible) {
 			wm_state->num_active_planes++;
-			total_rate += drm_format_plane_cpp(state->base.fb->pixel_format, 0);
+			total_rate += state->base.fb->format->cpp[0];
 		}
 	}
 
@@ -1023,7 +1023,7 @@ static void vlv_compute_fifo(struct intel_crtc *crtc)
 			continue;
 		}
 
-		rate = drm_format_plane_cpp(state->base.fb->pixel_format, 0);
+		rate = state->base.fb->format->cpp[0];
 		plane->wm.fifo_size = fifo_size * rate / total_rate;
 		fifo_left -= plane->wm.fifo_size;
 	}
@@ -1455,7 +1455,7 @@ static void i965_update_wm(struct intel_crtc *unused_crtc)
 		int clock = adjusted_mode->crtc_clock;
 		int htotal = adjusted_mode->crtc_htotal;
 		int hdisplay = crtc->config->pipe_src_w;
-		int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+		int cpp = fb->format->cpp[0];
 		unsigned long line_time_us;
 		int entries;
 
@@ -1541,7 +1541,7 @@ static void i9xx_update_wm(struct intel_crtc *unused_crtc)
 		if (IS_GEN2(dev_priv))
 			cpp = 4;
 		else
-			cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+			cpp = fb->format->cpp[0];
 
 		planea_wm = intel_calculate_wm(adjusted_mode->crtc_clock,
 					       wm_info, fifo_size, cpp,
@@ -1568,7 +1568,7 @@ static void i9xx_update_wm(struct intel_crtc *unused_crtc)
 		if (IS_GEN2(dev_priv))
 			cpp = 4;
 		else
-			cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+			cpp = fb->format->cpp[0];
 
 		planeb_wm = intel_calculate_wm(adjusted_mode->crtc_clock,
 					       wm_info, fifo_size, cpp,
@@ -1621,7 +1621,7 @@ static void i9xx_update_wm(struct intel_crtc *unused_crtc)
 		if (IS_I915GM(dev_priv) || IS_I945GM(dev_priv))
 			cpp = 4;
 		else
-			cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+			cpp = fb->format->cpp[0];
 
 		line_time_us = max(htotal * 1000 / clock, 1);
 
@@ -1787,7 +1787,7 @@ static uint32_t ilk_compute_pri_wm(const struct intel_crtc_state *cstate,
 	if (!cstate->base.active || !pstate->base.visible)
 		return 0;
 
-	cpp = drm_format_plane_cpp(pstate->base.fb->pixel_format, 0);
+	cpp = pstate->base.fb->format->cpp[0];
 
 	method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value);
 
@@ -1816,7 +1816,7 @@ static uint32_t ilk_compute_spr_wm(const struct intel_crtc_state *cstate,
 	if (!cstate->base.active || !pstate->base.visible)
 		return 0;
 
-	cpp = drm_format_plane_cpp(pstate->base.fb->pixel_format, 0);
+	cpp = pstate->base.fb->format->cpp[0];
 
 	method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value);
 	method2 = ilk_wm_method2(ilk_pipe_pixel_rate(cstate),
@@ -1860,7 +1860,7 @@ static uint32_t ilk_compute_fbc_wm(const struct intel_crtc_state *cstate,
 	if (!cstate->base.active || !pstate->base.visible)
 		return 0;
 
-	cpp = drm_format_plane_cpp(pstate->base.fb->pixel_format, 0);
+	cpp = pstate->base.fb->format->cpp[0];
 
 	return ilk_wm_fbc(pri_val, drm_rect_width(&pstate->base.dst), cpp);
 }
@@ -3258,13 +3258,13 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
 	if (format == DRM_FORMAT_NV12) {
 		if (y)  /* y-plane data rate */
 			data_rate = width * height *
-				drm_format_plane_cpp(format, 0);
+				fb->format->cpp[0];
 		else    /* uv-plane data rate */
 			data_rate = (width / 2) * (height / 2) *
-				drm_format_plane_cpp(format, 1);
+				fb->format->cpp[1];
 	} else {
 		/* for packed formats */
-		data_rate = width * height * drm_format_plane_cpp(format, 0);
+		data_rate = width * height * fb->format->cpp[0];
 	}
 
 	down_scale_amount = skl_plane_downscale_amount(intel_pstate);
@@ -3351,9 +3351,9 @@ skl_ddb_min_alloc(const struct drm_plane_state *pstate,
 	}
 
 	if (fb->pixel_format == DRM_FORMAT_NV12 && !y)
-		plane_bpp = drm_format_plane_cpp(fb->pixel_format, 1);
+		plane_bpp = fb->format->cpp[1];
 	else
-		plane_bpp = drm_format_plane_cpp(fb->pixel_format, 0);
+		plane_bpp = fb->format->cpp[0];
 
 	if (drm_rotation_90_or_270(pstate->rotation)) {
 		switch (plane_bpp) {
@@ -3613,13 +3613,13 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 	if (drm_rotation_90_or_270(pstate->rotation))
 		swap(width, height);
 
-	cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+	cpp = fb->format->cpp[0];
 	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) ?
-			drm_format_plane_cpp(fb->pixel_format, 1) :
-			drm_format_plane_cpp(fb->pixel_format, 0);
+			fb->format->cpp[1] :
+			fb->format->cpp[0];
 
 		switch (cpp) {
 		case 1:
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 8f131a08d440..b46c1794d3ac 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -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);
 
diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c
index e74a0ad52950..f44a83656310 100644
--- a/drivers/gpu/drm/imx/ipuv3-plane.c
+++ b/drivers/gpu/drm/imx/ipuv3-plane.c
@@ -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;
+	       fb->format->cpp[0] * x;
 }
 
 static inline unsigned long
@@ -96,7 +96,7 @@ drm_plane_state_to_ubo(struct drm_plane_state *state)
 	y /= drm_format_vert_chroma_subsampling(fb->pixel_format);
 
 	return cma_obj->paddr + fb->offsets[1] + fb->pitches[1] * y +
-	       drm_format_plane_cpp(fb->pixel_format, 1) * x - eba;
+	       fb->format->cpp[1] * x - eba;
 }
 
 static inline unsigned long
@@ -115,7 +115,7 @@ drm_plane_state_to_vbo(struct drm_plane_state *state)
 	y /= drm_format_vert_chroma_subsampling(fb->pixel_format);
 
 	return cma_obj->paddr + fb->offsets[2] + fb->pitches[2] * y +
-	       drm_format_plane_cpp(fb->pixel_format, 2) * x - eba;
+	       fb->format->cpp[2] * x - eba;
 }
 
 void ipu_plane_put_resources(struct ipu_plane *ipu_plane)
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index c461a232cbf5..71421923c592 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -135,7 +135,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
 	pitch = fb->pitches[0];
 	format = fb->pixel_format;
 
-	addr += (plane->state->src.x1 >> 16) * drm_format_plane_cpp(format, 0);
+	addr += (plane->state->src.x1 >> 16) * fb->format->cpp[0];
 	addr += (plane->state->src.y1 >> 16) * pitch;
 
 	state->pending.enable = true;
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index c7eba305c488..50e085e74214 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -749,7 +749,7 @@ 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) * fb->format->cpp[0];
 	offset += (src->y1 >> 16) * fb->pitches[0];
 	dma_addr = rk_obj->dma_addr + offset + fb->offsets[0];
 
@@ -763,7 +763,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 	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);
+		int bpp = fb->format->cpp[1];
 
 		uv_obj = rockchip_fb_get_gem_obj(fb, 1);
 		rk_uv_obj = to_rockchip_obj(uv_obj);
diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
index 81df3097b545..58316bd6d7d6 100644
--- a/drivers/gpu/drm/sti/sti_gdp.c
+++ b/drivers/gpu/drm/sti/sti_gdp.c
@@ -757,7 +757,7 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
 			 (unsigned long)cma_obj->paddr);
 
 	/* pixel memory location */
-	bpp = drm_format_plane_cpp(fb->pixel_format, 0);
+	bpp = fb->format->cpp[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];
diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 2e08f969bb64..a606207d4e25 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -218,7 +218,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 = fb->format->cpp[0];
 	paddr = gem->paddr + fb->offsets[0];
 	paddr += (state->src_x >> 16) * bpp;
 	paddr += (state->src_y >> 16) * fb->pitches[0];
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 822531ebd4b0..38972e3d652e 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -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 * fb->format->cpp[0];
 
 	end = start + (crtc->mode.vdisplay * fb->pitches[0]);
 
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
index 8a6a50d74aff..c0fc874e91cf 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
@@ -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);
+		state->fb->format->cpp[0];
 	if (state->fb->pitches[0] != pitch) {
 		dev_err(plane->dev->dev,
 			"Invalid pitch: fb and crtc widths must be the same");
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
index a7fb581c7c55..f84f6bddd015 100644
--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -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 = fb->format->cpp[i];
 			u32 subs = ((i == 0) ? 1 : h_subsample);
 
 			vc4_state->offsets[i] += (cpp *
diff --git a/drivers/gpu/drm/zte/zx_plane.c b/drivers/gpu/drm/zte/zx_plane.c
index 546eb92a94e8..72d27b0a48b2 100644
--- a/drivers/gpu/drm/zte/zx_plane.c
+++ b/drivers/gpu/drm/zte/zx_plane.c
@@ -159,7 +159,7 @@ static void zx_gl_plane_atomic_update(struct drm_plane *plane,
 	dst_w = plane->state->crtc_w;
 	dst_h = plane->state->crtc_h;
 
-	bpp = drm_format_plane_cpp(format, 0);
+	bpp = fb->format->cpp[0];
 
 	cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
 	paddr = cma_obj->paddr + fb->offsets[0];
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 26/37] drm/fb_cma_helper: Replace drm_format_info() with fb->format
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (24 preceding siblings ...)
  2016-11-18 19:53 ` [PATCH 25/37] drm: Replace drm_format_plane_cpp() with fb->format->cpp[] ville.syrjala
@ 2016-11-18 19:53 ` ville.syrjala
  2016-11-18 19:53 ` [PATCH 27/37] drm/nouveau: Use fb->format rather than drm_format_info() ville.syrjala
                   ` (12 subsequent siblings)
  38 siblings, 0 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/drm_fb_cma_helper.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
index 570f5c6063f3..0dc3f5bcbf48 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -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);
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 27/37] drm/nouveau: Use fb->format rather than drm_format_info()
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (25 preceding siblings ...)
  2016-11-18 19:53 ` [PATCH 26/37] drm/fb_cma_helper: Replace drm_format_info() with fb->format ville.syrjala
@ 2016-11-18 19:53 ` ville.syrjala
  2016-11-30 15:59   ` Daniel Vetter
  2016-11-18 19:53 ` [PATCH 28/37] drm/i915: Store a pointer to the pixel format info for fbc ville.syrjala
                   ` (11 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart, Ben Skeggs

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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

Cc: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/nouveau/nv50_display.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index a9855a4ec532..d3bd428023ea 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -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   :
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 28/37] drm/i915: Store a pointer to the pixel format info for fbc
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (26 preceding siblings ...)
  2016-11-18 19:53 ` [PATCH 27/37] drm/nouveau: Use fb->format rather than drm_format_info() ville.syrjala
@ 2016-11-18 19:53 ` ville.syrjala
  2016-11-30 16:07   ` [Intel-gfx] " Daniel Vetter
  2016-11-18 19:53 ` [PATCH 29/37] drm: Add drm_framebuffer_plane_{width,height}() ville.syrjala
                   ` (10 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:53 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Laurent Pinchart, Paulo Zanoni

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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.

Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h  |  4 ++--
 drivers/gpu/drm/i915/intel_fbc.c | 14 +++++++-------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index be67aeece749..692b79e056be 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -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;
diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
index 62f215b12eb5..659cebc3bfd2 100644
--- a/drivers/gpu/drm/i915/intel_fbc.c
+++ b/drivers/gpu/drm/i915/intel_fbc.c
@@ -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;
 
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 29/37] drm: Add drm_framebuffer_plane_{width,height}()
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (27 preceding siblings ...)
  2016-11-18 19:53 ` [PATCH 28/37] drm/i915: Store a pointer to the pixel format info for fbc ville.syrjala
@ 2016-11-18 19:53 ` ville.syrjala
  2016-11-18 19:53 ` [PATCH 30/37] drm/i915: Use drm_framebuffer_plane_{width, height}() where possible ville.syrjala
                   ` (9 subsequent siblings)
  38 siblings, 0 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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).

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/drm_framebuffer.c | 44 +++++++++++++++++++++++++++++++++++++++
 include/drm/drm_framebuffer.h     |  6 ++++++
 2 files changed, 50 insertions(+)

diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 892976d974e5..22071d7e3420 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -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);
diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
index 741b3a994d1f..cdcfb86b3f74 100644
--- a/include/drm/drm_framebuffer.h
+++ b/include/drm/drm_framebuffer.h
@@ -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
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 30/37] drm/i915: Use drm_framebuffer_plane_{width, height}() where possible
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (28 preceding siblings ...)
  2016-11-18 19:53 ` [PATCH 29/37] drm: Add drm_framebuffer_plane_{width,height}() ville.syrjala
@ 2016-11-18 19:53 ` ville.syrjala
  2016-11-30 16:04   ` Daniel Vetter
  2016-11-30 16:06   ` [Intel-gfx] " Daniel Vetter
  2016-11-18 19:53 ` [PATCH 31/37] drm: Nuke fb->depth ville.syrjala
                   ` (8 subsequent siblings)
  38 siblings, 2 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:53 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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

Cc: intel-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 8f63fd38deee..5d8db436c557 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -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);
 
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 31/37] drm: Nuke fb->depth
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (29 preceding siblings ...)
  2016-11-18 19:53 ` [PATCH 30/37] drm/i915: Use drm_framebuffer_plane_{width, height}() where possible ville.syrjala
@ 2016-11-18 19:53 ` ville.syrjala
  2016-11-30 16:01   ` Daniel Vetter
  2016-12-14 21:31   ` [PATCH v2 " ville.syrjala
  2016-11-18 19:53 ` [PATCH v2 32/37] drm: Nuke fb->bits_per_pixel ville.syrjala
                   ` (7 subsequent siblings)
  38 siblings, 2 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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;
@@
- fb.depth
+ fb.format->depth

@@
struct drm_framebuffer *fb;
@@
- 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;
	 ...
 };

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 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(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index f1c9e59a7c87..f24c91b699a9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -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);
diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c
index c5dc06a55883..3a58fb600b05 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -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",
diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
index d6f5ec64c667..f751792a3c7c 100644
--- a/drivers/gpu/drm/ast/ast_fb.c
+++ b/drivers/gpu/drm/ast/ast_fb.c
@@ -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;
diff --git a/drivers/gpu/drm/bochs/bochs_fbdev.c b/drivers/gpu/drm/bochs/bochs_fbdev.c
index da790a1c302a..0317c3df6a22 100644
--- a/drivers/gpu/drm/bochs/bochs_fbdev.c
+++ b/drivers/gpu/drm/bochs/bochs_fbdev.c
@@ -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);
 
diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 3a6309d7d8e4..3cac8a03cf4f 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
index 0dc3f5bcbf48..181a9eafe34a 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 14547817566d..755e3b6e9710 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 22071d7e3420..556a92359c96 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -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) {
diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index 1aa5e3bcc8a1..e5d19e5fc341 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index 9f35deb56170..e68a46f112f6 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/accel_2d.c b/drivers/gpu/drm/gma500/accel_2d.c
index 0d2bb1682508..c51d9259c7a7 100644
--- a/drivers/gpu/drm/gma500/accel_2d.c
+++ b/drivers/gpu/drm/gma500/accel_2d.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index 6d89ed760941..a93b59ce6b41 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
index 05b9a4ceb58d..5b852ad152ae 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/mdfld_intel_display.c b/drivers/gpu/drm/gma500/mdfld_intel_display.c
index e80895285e94..3be3111825cd 100644
--- a/drivers/gpu/drm/gma500/mdfld_intel_display.c
+++ b/drivers/gpu/drm/gma500/mdfld_intel_display.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
index a51896544d91..569810d47786 100644
--- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
+++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
@@ -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;
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index b7f42c448a44..ebcba97616ab 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -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));
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index beb08982dc0b..b726483a460d 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -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.
diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c
index 88dd2214114d..19a78b6b5a1a 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -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);
 
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
index bdac288ab16d..3180db5e81cb 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -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;
diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index d29f5e82a410..3af969d8e8db 100644
--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 8286b8ffe109..480e3ab477fd 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -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,
diff --git a/drivers/gpu/drm/nouveau/dispnv04/dfp.c b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
index 945607b3cd41..2e5bb2afda7c 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dfp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
@@ -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 {
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 2f2a3dcd4ad7..5600f6c64497 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -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) */
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c
index 8d8ac173f55d..aed99a0fc44b 100644
--- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
index 7e305d8a4146..e41b3322f433 100644
--- a/drivers/gpu/drm/qxl/qxl_fb.c
+++ b/drivers/gpu/drm/qxl/qxl_fb.c
@@ -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:
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c
index 899b6a1644bd..6c10a83f3362 100644
--- a/drivers/gpu/drm/radeon/radeon_fb.c
+++ b/drivers/gpu/drm/radeon/radeon_fb.c
@@ -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);
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
index 8f639c8597a5..52d1fdf9f9da 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index b8be3ee4d3b8..d2893f65341a 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -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));
 	}
diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index 8a4aea211e94..8df7783cecc2 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -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 +
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index fefd87f422ec..e21a3ed3ab2b 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -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",
diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c b/drivers/gpu/drm/virtio/virtgpu_fb.c
index dd21f950e129..9d0da42cc420 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fb.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fb.c
@@ -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);
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
index d2d93959b119..b6e4add09f44 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
@@ -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;
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 77f936e3056e..2ce4743701f1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -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;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
index 23ec673d5e16..a3a839a3d441 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
@@ -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. */
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
index f42359084adc..38d7b8a2b78e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
@@ -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;
diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
index cdcfb86b3f74..9b9772998db6 100644
--- a/include/drm/drm_framebuffer.h
+++ b/include/drm/drm_framebuffer.h
@@ -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
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH v2 32/37] drm: Nuke fb->bits_per_pixel
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (30 preceding siblings ...)
  2016-11-18 19:53 ` [PATCH 31/37] drm: Nuke fb->depth ville.syrjala
@ 2016-11-18 19:53 ` ville.syrjala
  2016-12-14 21:32   ` [PATCH v3 " ville.syrjala
  2016-11-18 19:53 ` [PATCH v2 33/37] drm: Nuke fb->pixel_format ville.syrjala
                   ` (6 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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)

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)
---
 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(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index 65a954cb69ed..9c8f33780257 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -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);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index d807e876366b..72ba3a50452b 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -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);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index bc9f2f423270..aa64d9c1a8c8 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -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);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index 4ae59914bc32..ecf6c68b8f43 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -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);
diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index a51f8cbcfe26..c69a5ea54f23 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -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;
 
diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c
index 3a58fb600b05..78335100cbc3 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
index f751792a3c7c..b085140fae95 100644
--- a/drivers/gpu/drm/ast/ast_fb.c
+++ b/drivers/gpu/drm/ast/ast_fb.c
@@ -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;
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index deb3684ccaf8..0cf5e0ab5015 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -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:
diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 3cac8a03cf4f..79a5cd108245 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c b/drivers/gpu/drm/cirrus/cirrus_mode.c
index f2297acae235..e78a7a295cef 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 755e3b6e9710..01e6ddf6680f 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 556a92359c96..94ddab41f24f 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -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) ||
diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index e5d19e5fc341..3c44409244dc 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -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;
diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index 6ca1f3117fe8..e8ce4a318586 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -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;
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index f4d5a2133777..58dc9a5196bc 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -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)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index e68a46f112f6..d8808158d418 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index e2e405170d35..0029065979b8 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -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)
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index edb20a34c66c..b313e61aab65 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -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 &&
diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index a93b59ce6b41..6bf33ba055b3 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
index 5b852ad152ae..d1c5642b1c1e 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/mdfld_intel_display.c b/drivers/gpu/drm/gma500/mdfld_intel_display.c
index 3be3111825cd..63c6e08600ae 100644
--- a/drivers/gpu/drm/gma500/mdfld_intel_display.c
+++ b/drivers/gpu/drm/gma500/mdfld_intel_display.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
index 569810d47786..0fff269d3fe6 100644
--- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
+++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
@@ -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;
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index ebcba97616ab..ee272ec8732c 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -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);
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 5d8db436c557..6c889f0e8e0f 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -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])
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index b726483a460d..3f60a4f6f078 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -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);
diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c
index 19a78b6b5a1a..1a665e1671b8 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -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;
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
index 3180db5e81cb..1e039cfddedf 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 480e3ab477fd..a72754d73c84 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index a46d893aaafa..317ac38fc613 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -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 */
diff --git a/drivers/gpu/drm/qxl/qxl_draw.c b/drivers/gpu/drm/qxl/qxl_draw.c
index 9b728edf1b49..4d8681e84e68 100644
--- a/drivers/gpu/drm/qxl/qxl_draw.c
+++ b/drivers/gpu/drm/qxl/qxl_draw.c
@@ -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;
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 05f4ebe31ce2..0d7f84f7d71d 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -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);
 
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 984b35f43554..e3399310d41d 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -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];
 		}
 	}
 
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 6285355eb5d5..aea8b62835a4 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -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;
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index 31c03e32a6b5..ce6cb6666212 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -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;
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index b60c306190e9..642dcff87e34 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -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 */
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index d2893f65341a..e289dbc6ad82 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -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));
 	}
 
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index e21a3ed3ab2b..b8dc06d68777 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -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;
diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c b/drivers/gpu/drm/virtio/virtgpu_fb.c
index 9d0da42cc420..61254b991265 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fb.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fb.c
@@ -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);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
index b6e4add09f44..4d9ab16fb909 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
@@ -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;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 2ce4743701f1..eb8e36462961 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -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;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
index a3a839a3d441..3806148e1bdb 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
@@ -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. */
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
index 38d7b8a2b78e..d4268efc37d2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
@@ -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];
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
index 94ad8d2acf9a..b27cd18ee66a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
@@ -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;
diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
index 9b9772998db6..4efc5066475a 100644
--- a/include/drm/drm_framebuffer.h
+++ b/include/drm/drm_framebuffer.h
@@ -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.
 	 */
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH v2 33/37] drm: Nuke fb->pixel_format
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (31 preceding siblings ...)
  2016-11-18 19:53 ` [PATCH v2 32/37] drm: Nuke fb->bits_per_pixel ville.syrjala
@ 2016-11-18 19:53 ` ville.syrjala
  2016-11-19  2:55   ` Laurent Pinchart
  2016-12-14 21:32   ` [PATCH v3 " ville.syrjala
  2016-11-18 19:53 ` [PATCH 34/37] drm: Replace 'format->format' comparisons to just 'format' comparisons ville.syrjala
                   ` (5 subsequent siblings)
  38 siblings, 2 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Replace uses of fb->pixel_format 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 *a;
struct drm_framebuffer b;
@@
(
- a->pixel_format
+ a->format->format
|
- b.pixel_format
+ b.format->format
)

@@
struct drm_plane_state *a;
struct drm_plane_state b;
@@
(
- a->fb->pixel_format
+ a->fb->format->format
|
- b.fb->pixel_format
+ b.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
|
- set->crtc->primary->fb->pixel_format
+ set->crtc->primary->fb->format->format
)

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

v2: Fix commit message (Laurent)
    Rebase due to earlier removal of many fb->pixel_format uses,
    including the 'fb->format = drm_format_info(fb->format->format);'
    snafu

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)
---
 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                |  2 +-
 drivers/gpu/drm/arm/malidp_planes.c             |  8 +++---
 drivers/gpu/drm/armada/armada_crtc.c            |  2 +-
 drivers/gpu/drm/armada/armada_overlay.c         |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 18 ++++++-------
 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_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               | 34 ++++++++++++-------------
 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       |  2 +-
 drivers/gpu/drm/msm/msm_fb.c                    |  2 +-
 drivers/gpu/drm/nouveau/dispnv04/overlay.c      |  8 +++---
 drivers/gpu/drm/nouveau/nv50_display.c          |  4 +--
 drivers/gpu/drm/omapdrm/omap_fb.c               |  2 +-
 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     | 18 ++++++-------
 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                   |  8 +++---
 drivers/gpu/drm/sti/sti_hqvdp.c                 |  2 +-
 drivers/gpu/drm/sun4i/sun4i_backend.c           |  3 ++-
 drivers/gpu/drm/tegra/dc.c                      |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c            |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_plane.c           |  2 +-
 drivers/gpu/drm/vc4/vc4_plane.c                 |  4 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c             |  2 --
 drivers/gpu/drm/zte/zx_plane.c                  |  2 +-
 include/drm/drm_framebuffer.h                   |  4 ---
 53 files changed, 143 insertions(+), 151 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index 9c8f33780257..575f010a3112 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index 72ba3a50452b..9f325f4e018c 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index aa64d9c1a8c8..6975a78f733b 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index ecf6c68b8f43..bfdfda50f0e7 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index 5c26c5f126a3..ad9a95916f1f 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -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;
 
diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
index 5c19c25729cb..5d8e29f6815d 100644
--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
@@ -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)
diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
index 533ee2fa64be..eff2fe47e26a 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -112,7 +112,7 @@ 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;
 
@@ -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;
 
diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index c69a5ea54f23..52e139dc9e38 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -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);
diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
index e2ad408c2f24..fe12fe139eb4 100644
--- a/drivers/gpu/drm/armada/armada_overlay.c
+++ b/drivers/gpu/drm/armada/armada_overlay.c
@@ -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 = fb->format->num_planes;
 
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index 3e00512ef187..bd2791c4b002 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -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;
 
@@ -664,8 +664,8 @@ 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;
@@ -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)
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index cb6ab0106b0b..a3e4a0dc8fb4 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -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");
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 90931e039731..7e814741f7f3 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -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;
 			}
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 5d2cb138eba6..94bce0b462aa 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
index 181a9eafe34a..aab4465307ed 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -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: ",
diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index 3c44409244dc..639e474e7d43 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -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);
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 419ac313c36f..ac1e06df7280 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -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;
diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index e8ce4a318586..c5c01628c715 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -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;
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index 58dc9a5196bc..f9ab19e205e2 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -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;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 0029065979b8..745cfbdf6b39 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -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)
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index b313e61aab65..a106046e0c93 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -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 ||
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
index a99f48847420..0a20723aa6e1 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
@@ -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;
diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
index afc2b5d2d5f0..2f0c2e1c6110 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
@@ -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;
 
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index ee272ec8732c..e571e9a37ac4 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -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");
 		}
diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
index dbe9fb41ae53..e049838159a1 100644
--- a/drivers/gpu/drm/i915/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
@@ -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;
 
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 6c889f0e8e0f..f5f9f1422d69 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -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,
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index 3f60a4f6f078..570c07d59d1a 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -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",
diff --git a/drivers/gpu/drm/i915/intel_overlay.c b/drivers/gpu/drm/i915/intel_overlay.c
index ce3667c18e18..568d194435fd 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -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;
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index f94fe998b0ee..5f35bd7131e1 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -3241,7 +3241,7 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
 		return 0;
 
 	fb = pstate->fb;
-	format = fb->pixel_format;
+	format = fb->format->format;
 
 	if (pstate->plane->type == DRM_PLANE_TYPE_CURSOR)
 		return 0;
@@ -3330,7 +3330,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 */
@@ -3345,12 +3345,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];
@@ -3617,7 +3617,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];
 
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index b46c1794d3ac..ff766c0cb873 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -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;
 
diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c
index f44a83656310..0b945f077344 100644
--- a/drivers/gpu/drm/imx/ipuv3-plane.c
+++ b/drivers/gpu/drm/imx/ipuv3-plane.c
@@ -92,8 +92,8 @@ 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 +
 	       fb->format->cpp[1] * x - eba;
@@ -111,8 +111,8 @@ 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 +
 	       fb->format->cpp[2] * x - eba;
@@ -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,
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index 71421923c592..e405e89ed5e5 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -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) * fb->format->cpp[0];
 	addr += (plane->state->src.y1 >> 16) * pitch;
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
index 911e4690d36a..53619d07677e 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
@@ -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;
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index 8c985c8e23f2..b90e9e497260 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -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;
 		}
diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c
index 5cad5e9a07c9..a39c91569d58 100644
--- a/drivers/gpu/drm/msm/msm_fb.c
+++ b/drivers/gpu/drm/msm/msm_fb.c
@@ -68,7 +68,7 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 	int i, n = fb->format->num_planes;
 
 	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++) {
diff --git a/drivers/gpu/drm/nouveau/dispnv04/overlay.c b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
index a79514d440b3..6275c270df25 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/overlay.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index d3bd428023ea..4fd313ee46b3 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -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   :
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index c6ef457b9fca..bd6b94c38613 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -346,7 +346,7 @@ void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 	int i, n = fb->format->num_planes;
 
 	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];
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 0d7f84f7d71d..3c492a0aa6bd 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index a74f8ed8ca2e..dcde6288da6c 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index 83ebd162f3ef..b5bfbe50bd87 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 50e085e74214..fb5f001f51c3 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -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;
@@ -753,16 +753,16 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 	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);
+	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 = fb->format->cpp[1];
 
 		uv_obj = rockchip_fb_get_gem_obj(fb, 1);
@@ -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) |
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
index 6547b1db460a..2494410435a1 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_plane.c b/drivers/gpu/drm/shmobile/shmob_drm_plane.c
index 1805bb23b113..2023a93cee2b 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_plane.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_plane.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
index 58316bd6d7d6..877d053d86f4 100644
--- a/drivers/gpu/drm/sti/sti_gdp.c
+++ b/drivers/gpu/drm/sti/sti_gdp.c
@@ -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,7 +753,7 @@ 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 */
diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c
index f88130f2eb48..becf10d255c4 100644
--- a/drivers/gpu/drm/sti/sti_hqvdp.c
+++ b/drivers/gpu/drm/sti/sti_hqvdp.c
@@ -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 */
diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
index a606207d4e25..a278e1f44661 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -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;
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 642dcff87e34..7561a95a54e3 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -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;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 38972e3d652e..f10499ab4bec 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -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;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
index c0fc874e91cf..4b7519dfd1b9 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
@@ -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__);
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
index f84f6bddd015..110d1518f5d5 100644
--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -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 = fb->format->num_planes;
 	u32 h_subsample = 1;
 	u32 v_subsample = 1;
@@ -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;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index eb8e36462961..91e30c9abff0 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -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;
diff --git a/drivers/gpu/drm/zte/zx_plane.c b/drivers/gpu/drm/zte/zx_plane.c
index 72d27b0a48b2..b634b090cdc1 100644
--- a/drivers/gpu/drm/zte/zx_plane.c
+++ b/drivers/gpu/drm/zte/zx_plane.c
@@ -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;
diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
index 4efc5066475a..2734a87b2120 100644
--- a/include/drm/drm_framebuffer.h
+++ b/include/drm/drm_framebuffer.h
@@ -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.
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 34/37] drm: Replace 'format->format' comparisons to just 'format' comparisons
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (32 preceding siblings ...)
  2016-11-18 19:53 ` [PATCH v2 33/37] drm: Nuke fb->pixel_format ville.syrjala
@ 2016-11-18 19:53 ` ville.syrjala
  2016-11-19  2:56   ` Laurent Pinchart
  2016-11-18 19:53 ` [PATCH 35/37] drm: Eliminate the useless "non-RGB fb" debug message ville.syrjala
                   ` (4 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Rather than compare the format u32s of two format infos, we can direclty
compare the format info pointers themselves. Noramlly all the ->format
pointers all point to somwehere in the big array, so this is a valid
way to test for equality.

Also drivers may want to point ->format at a private format info struct
instead (eg. for special compressed formats with extra planes), so
just comparing the pixel format values wouldn't necessaritly even work.
But comparing the pointers will also take care of that case.

@@
struct drm_framebuffer *a;
struct drm_framebuffer *b;
@@
(
- a->format->format != b->format->format
+ a->format != b->format
|
- a->format->format == b->format->format
+ a->format == b->format
)

@@
struct drm_plane_state *a;
struct drm_plane_state *b;
@@
(
- a->fb->format->format != b->fb->format->format
+ a->fb->format != b->fb->format
|
- a->fb->format->format == b->fb->format->format
+ a->fb->format == b->fb->format
)

@@
struct drm_crtc *crtc;
struct drm_framebuffer *x;
@@
(
- crtc->primary->fb->format->format != x->format->format
+ crtc->primary->fb->format != x->format
|
- x->format->format != crtc->primary->fb->format->format
+ x->format != crtc->primary->fb->format
)

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

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/armada/armada_crtc.c      | 2 +-
 drivers/gpu/drm/drm_crtc_helper.c         | 3 +--
 drivers/gpu/drm/drm_plane.c               | 2 +-
 drivers/gpu/drm/i915/intel_display.c      | 2 +-
 drivers/gpu/drm/imx/ipuv3-plane.c         | 6 +++---
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 2 +-
 drivers/gpu/drm/tilcdc/tilcdc_plane.c     | 2 +-
 7 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index 52e139dc9e38..baebf3775f60 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -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->format->format != crtc->primary->fb->format->format)
+	if (fb->format != crtc->primary->fb->format)
 		return -EINVAL;
 
 	work = kmalloc(sizeof(*work), GFP_KERNEL);
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 94bce0b462aa..9d007f5f9732 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -588,8 +588,7 @@ 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->format->format !=
-			   set->crtc->primary->fb->format->format) {
+		} else if (set->fb->format != set->crtc->primary->fb->format) {
 			mode_changed = true;
 		} else
 			fb_changed = true;
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index ac1e06df7280..1d90520457d7 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -854,7 +854,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 	if (ret)
 		goto out;
 
-	if (crtc->primary->fb->format->format != fb->format->format) {
+	if (crtc->primary->fb->format != fb->format) {
 		DRM_DEBUG_KMS("Page flip is not allowed to change frame buffer format.\n");
 		ret = -EINVAL;
 		goto out;
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index f5f9f1422d69..7b7135be3b9e 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -12148,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->format->format != crtc->primary->fb->format->format)
+	if (fb->format != crtc->primary->fb->format)
 		return -EINVAL;
 
 	/*
diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c
index 0b945f077344..8b5294d47cee 100644
--- a/drivers/gpu/drm/imx/ipuv3-plane.c
+++ b/drivers/gpu/drm/imx/ipuv3-plane.c
@@ -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->format->format != old_fb->format->format))
+			      fb->format != old_fb->format))
 		crtc_state->mode_changed = true;
 
 	eba = drm_plane_state_to_eba(state);
@@ -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->format->format == old_fb->format->format)) {
+		if (old_fb && (fb->format == old_fb->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->format->format == old_fb->format->format)) {
+		if (old_fb && (fb->format == old_fb->format)) {
 			old_ubo = drm_plane_state_to_ubo(old_state);
 			if (ubo != old_ubo)
 				crtc_state->mode_changed = true;
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index b90e9e497260..6ecc6bc1f531 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -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->format->format != old_state->fb->format->format) {
+		if (state->fb->format != old_state->fb->format) {
 			DBG("%s: pixel_format change!", mdp5_plane->name);
 			full_modeset = true;
 		}
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
index 4b7519dfd1b9..ba0d66c0d8ac 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
@@ -77,7 +77,7 @@ static int tilcdc_plane_atomic_check(struct drm_plane *plane,
 	}
 
 	if (state->fb && old_state->fb &&
-	    state->fb->format->format != old_state->fb->format->format) {
+	    state->fb->format != old_state->fb->format) {
 		dev_dbg(plane->dev->dev,
 			"%s(): pixel format change requires mode_change\n",
 			__func__);
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 35/37] drm: Eliminate the useless "non-RGB fb" debug message
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (33 preceding siblings ...)
  2016-11-18 19:53 ` [PATCH 34/37] drm: Replace 'format->format' comparisons to just 'format' comparisons ville.syrjala
@ 2016-11-18 19:53 ` ville.syrjala
  2016-11-19  2:57   ` Laurent Pinchart
  2016-11-18 19:53 ` [PATCH 36/37] drm: Add mode_config .get_format_info() hook ville.syrjala
                   ` (3 subsequent siblings)
  38 siblings, 1 reply; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

No point in spamming the log whenever a non-RGB fb is being
constructed. And since there's nothing to do anymore that
fb->bits_per_pixel and fb->depth are gone, we can just kill
off this entire piece of code.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_modeset_helper.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index 639e474e7d43..5b051859b8d3 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -72,21 +72,10 @@ 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;
 	int i;
 
-	info = drm_format_info(mode_cmd->pixel_format);
-	if (!info || !info->depth) {
-		struct drm_format_name_buf format_name;
-
-		DRM_DEBUG_KMS("non-RGB pixel format %s\n",
-		              drm_get_format_name(mode_cmd->pixel_format,
-		                                  &format_name));
-	} else {
-	}
-
 	fb->dev = dev;
-	fb->format = info;
+	fb->format = drm_format_info(mode_cmd->pixel_format);
 	fb->width = mode_cmd->width;
 	fb->height = mode_cmd->height;
 	for (i = 0; i < 4; i++) {
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 36/37] drm: Add mode_config .get_format_info() hook
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (34 preceding siblings ...)
  2016-11-18 19:53 ` [PATCH 35/37] drm: Eliminate the useless "non-RGB fb" debug message ville.syrjala
@ 2016-11-18 19:53 ` ville.syrjala
  2016-11-20  8:13   ` Laurent Pinchart
  2016-11-22 13:41   ` [PATCH v2 " ville.syrjala
  2016-11-18 19:53 ` [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS ville.syrjala
                   ` (2 subsequent siblings)
  38 siblings, 2 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Ben Widawsky, intel-gfx, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Allow drivers to return a custom drm_format_info structure for special
fb layouts. We'll use this for the compression control surface in i915.

Cc: Ben Widawsky <ben@bwidawsk.net>
Cc: intel-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_fb_cma_helper.c  |  2 +-
 drivers/gpu/drm/drm_fourcc.c         | 25 +++++++++++++++++++++++++
 drivers/gpu/drm/drm_framebuffer.c    |  9 +++++++--
 drivers/gpu/drm/drm_modeset_helper.c |  2 +-
 include/drm/drm_fourcc.h             |  6 ++++++
 include/drm/drm_mode_config.h        | 15 +++++++++++++++
 6 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
index aab4465307ed..d7f8876cf5e9 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -186,7 +186,7 @@ struct drm_framebuffer *drm_fb_cma_create_with_funcs(struct drm_device *dev,
 	int ret;
 	int i;
 
-	info = drm_format_info(mode_cmd->pixel_format);
+	info = drm_get_format_info(dev, mode_cmd);
 	if (!info)
 		return ERR_PTR(-EINVAL);
 
diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index 90d2cc8da8eb..7cfaee689f0c 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -199,6 +199,31 @@ const struct drm_format_info *drm_format_info(u32 format)
 EXPORT_SYMBOL(drm_format_info);
 
 /**
+ * drm_format_info - query information for a given framebuffer configuration
+ * @dev: DRM device
+ * @mode_cmd: metadata from the userspace fb creation request
+ *
+ * Returns:
+ * The instance of struct drm_format_info that describes the pixel format, or
+ * NULL if the format is unsupported.
+ */
+const struct drm_format_info *
+drm_get_format_info(struct drm_device *dev,
+		    const struct drm_mode_fb_cmd2 *mode_cmd)
+{
+	const struct drm_format_info *info = NULL;
+
+	if (dev->mode_config.funcs->get_format_info)
+		info = dev->mode_config.funcs->get_format_info(dev, mode_cmd);
+
+	if (!info)
+		info = drm_format_info(mode_cmd->pixel_format);
+
+	return info;
+}
+EXPORT_SYMBOL(drm_get_format_info);
+
+/**
  * drm_format_num_planes - get the number of planes for format
  * @format: pixel format (DRM_FORMAT_*)
  *
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 94ddab41f24f..292930a5dcc2 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -126,11 +126,13 @@ int drm_mode_addfb(struct drm_device *dev,
 	return 0;
 }
 
-static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
+static int framebuffer_check(struct drm_device *dev,
+			     const struct drm_mode_fb_cmd2 *r)
 {
 	const struct drm_format_info *info;
 	int i;
 
+	/* check if the format is supported at all */
 	info = __drm_format_info(r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN);
 	if (!info) {
 		struct drm_format_name_buf format_name;
@@ -140,6 +142,9 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
 		return -EINVAL;
 	}
 
+	/* now let the driver pick its own format info */
+	info = drm_get_format_info(dev, r);
+
 	if (r->width == 0 || r->width % info->hsub) {
 		DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width);
 		return -EINVAL;
@@ -263,7 +268,7 @@ drm_internal_framebuffer_create(struct drm_device *dev,
 		return ERR_PTR(-EINVAL);
 	}
 
-	ret = framebuffer_check(r);
+	ret = framebuffer_check(dev, r);
 	if (ret)
 		return ERR_PTR(ret);
 
diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index 5b051859b8d3..f78df06a940d 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -75,7 +75,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
 	int i;
 
 	fb->dev = dev;
-	fb->format = drm_format_info(mode_cmd->pixel_format);
+	fb->format = drm_get_format_info(dev, mode_cmd);
 	fb->width = mode_cmd->width;
 	fb->height = mode_cmd->height;
 	for (i = 0; i < 4; i++) {
diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
index fcc08da850c8..6942e84b6edd 100644
--- a/include/drm/drm_fourcc.h
+++ b/include/drm/drm_fourcc.h
@@ -25,6 +25,9 @@
 #include <linux/types.h>
 #include <uapi/drm/drm_fourcc.h>
 
+struct drm_device;
+struct drm_mode_fb_cmd2;
+
 /**
  * struct drm_format_info - information about a DRM format
  * @format: 4CC format identifier (DRM_FORMAT_*)
@@ -55,6 +58,9 @@ struct drm_format_name_buf {
 
 const struct drm_format_info *__drm_format_info(u32 format);
 const struct drm_format_info *drm_format_info(u32 format);
+const struct drm_format_info *
+drm_get_format_info(struct drm_device *dev,
+		    const struct drm_mode_fb_cmd2 *mode_cmd);
 uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
 int drm_format_num_planes(uint32_t format);
 int drm_format_plane_cpp(uint32_t format, int plane);
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index bf9991b20611..80bb7e49bf8e 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -34,6 +34,7 @@ struct drm_file;
 struct drm_device;
 struct drm_atomic_state;
 struct drm_mode_fb_cmd2;
+struct drm_format_info;
 
 /**
  * struct drm_mode_config_funcs - basic driver provided mode setting functions
@@ -70,6 +71,20 @@ struct drm_mode_config_funcs {
 					     const struct drm_mode_fb_cmd2 *mode_cmd);
 
 	/**
+	 * @get_format_info:
+	 *
+	 * Allows a driver to return custom format information for special
+	 * fb layouts (eg. ones with auxiliary compresssion control planes).
+	 *
+	 * RETURNS:
+	 *
+	 * The format information specific to the given fb metadata, or
+	 * NULL if none is found.
+	 */
+	const struct drm_format_info *(*get_format_info)(struct drm_device *dev,
+							 const struct drm_mode_fb_cmd2 *mode_cmd);
+
+	/**
 	 * @output_poll_changed:
 	 *
 	 * Callback used by helpers to inform the driver of output configuration
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (35 preceding siblings ...)
  2016-11-18 19:53 ` [PATCH 36/37] drm: Add mode_config .get_format_info() hook ville.syrjala
@ 2016-11-18 19:53 ` ville.syrjala
  2016-11-18 23:31   ` Ben Widawsky
  2016-11-21  8:42   ` [Intel-gfx] " Tvrtko Ursulin
  2016-11-21 11:18 ` [PATCH v2 00/37] drm: Deduplicate fb format information (v2) Christian König
  2016-12-14 21:37 ` Ville Syrjälä
  38 siblings, 2 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-18 19:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Ben Widawsky, intel-gfx, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

By providing our own format information for the CCS formats, we should
be able to make framebuffer_check() do the right thing for the CCS
surface as well.

Note that we'll return the same format info for both Y and Yf tiled
format as that's what happens with the non-CCS Y vs. Yf as well. If
desired, we could potentially return a unique pointer for each
pixel_format+tiling+ccs combination, in which case we immediately be
able to tell if any of that stuff changed by just comparing the
pointers. But that does sound a bit wasteful space wise.

Cc: Ben Widawsky <ben@bwidawsk.net>
Cc: intel-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 37 ++++++++++++++++++++++++++++++++++++
 include/uapi/drm/drm_fourcc.h        |  3 +++
 2 files changed, 40 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 7b7135be3b9e..de6909770c68 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2488,6 +2488,42 @@ static unsigned int intel_fb_modifier_to_tiling(uint64_t fb_modifier)
 	}
 }
 
+static const struct drm_format_info ccs_formats[] = {
+	{ .format = DRM_FORMAT_XRGB8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
+	{ .format = DRM_FORMAT_XBGR8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
+	{ .format = DRM_FORMAT_ARGB8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
+	{ .format = DRM_FORMAT_ABGR8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
+};
+
+static const struct drm_format_info *
+lookup_format_info(const struct drm_format_info formats[],
+		   int num_formats, u32 format)
+{
+	int i;
+
+	for (i = 0; i < num_formats; i++) {
+		if (formats[i].format == format)
+			return &formats[i];
+	}
+
+	return NULL;
+}
+
+static const struct drm_format_info *
+intel_get_format_info(struct drm_device *dev,
+		      const struct drm_mode_fb_cmd2 *cmd)
+{
+	switch (cmd->modifier[0]) {
+	case I915_FORMAT_MOD_Y_TILED_CCS:
+	case I915_FORMAT_MOD_Yf_TILED_CCS:
+		return lookup_format_info(ccs_formats,
+					  ARRAY_SIZE(ccs_formats),
+					  cmd->pixel_format);
+	default:
+		return NULL;
+	}
+}
+
 static int
 intel_fill_fb_info(struct drm_i915_private *dev_priv,
 		   struct drm_framebuffer *fb)
@@ -15922,6 +15958,7 @@ intel_user_framebuffer_create(struct drm_device *dev,
 
 static const struct drm_mode_config_funcs intel_mode_funcs = {
 	.fb_create = intel_user_framebuffer_create,
+	.get_format_info = intel_get_format_info,
 	.output_poll_changed = intel_fbdev_output_poll_changed,
 	.atomic_check = intel_atomic_check,
 	.atomic_commit = intel_atomic_commit,
diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
index a5890bf44c0a..2926d916f199 100644
--- a/include/uapi/drm/drm_fourcc.h
+++ b/include/uapi/drm/drm_fourcc.h
@@ -218,6 +218,9 @@ extern "C" {
  */
 #define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3)
 
+#define I915_FORMAT_MOD_Y_TILED_CCS	fourcc_mod_code(INTEL, 4)
+#define I915_FORMAT_MOD_Yf_TILED_CCS	fourcc_mod_code(INTEL, 5)
+
 /*
  * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks
  *
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* Re: [PATCH 09/37] drm/arm: Add local 'fb' variables
  2016-11-18 19:52 ` [PATCH 09/37] drm/arm: " ville.syrjala
@ 2016-11-18 20:30   ` Brian Starkey
  2016-11-21 11:51   ` Liviu Dudau
  1 sibling, 0 replies; 99+ messages in thread
From: Brian Starkey @ 2016-11-18 20:30 UTC (permalink / raw)
  To: ville.syrjala
  Cc: Mali DP Maintainers, Liviu Dudau, Laurent Pinchart, dri-devel

Hi Ville,

On Fri, Nov 18, 2016 at 09:52:45PM +0200, Ville Syrjälä wrote:
>From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
>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.

lgtm,

Reviewed-by: Brian Starkey <brian.starkey@arm.com>

>
>Cc: Liviu Dudau <liviu.dudau@arm.com>
>Cc: Brian Starkey <brian.starkey@arm.com>
>Cc: Mali DP Maintainers <malidp@foss.arm.com>
>Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>---
> drivers/gpu/drm/arm/hdlcd_crtc.c    | 18 ++++++++++--------
> drivers/gpu/drm/arm/malidp_planes.c |  6 +++---
> 2 files changed, 13 insertions(+), 11 deletions(-)
>
>diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
>index bbaa55add2d2..8a0fee03aa39 100644
>--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
>+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
>@@ -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);
> }
>diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
>index 63eec8f37cfc..ee7f7663a307 100644
>--- a/drivers/gpu/drm/arm/malidp_planes.c
>+++ b/drivers/gpu/drm/arm/malidp_planes.c
>@@ -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;
>
>-- 
>2.7.4
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS
  2016-11-18 19:53 ` [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS ville.syrjala
@ 2016-11-18 23:31   ` Ben Widawsky
  2016-11-21 14:37     ` Ville Syrjälä
  2016-11-21  8:42   ` [Intel-gfx] " Tvrtko Ursulin
  1 sibling, 1 reply; 99+ messages in thread
From: Ben Widawsky @ 2016-11-18 23:31 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, Laurent Pinchart, dri-devel

On 16-11-18 21:53:13, Ville Syrjälä wrote:
>From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
>By providing our own format information for the CCS formats, we should
>be able to make framebuffer_check() do the right thing for the CCS
>surface as well.
>

I was hoping to see that patch as well :-). If you're adding the new fb
modifiers, I think it'd make sense to make it part of this series.
Alternatively, I can take 36, and 37 and make it part of my series, then
integrate that last bit. It's up to you.

>Note that we'll return the same format info for both Y and Yf tiled
>format as that's what happens with the non-CCS Y vs. Yf as well. If
>desired, we could potentially return a unique pointer for each
>pixel_format+tiling+ccs combination, in which case we immediately be
>able to tell if any of that stuff changed by just comparing the
>pointers. But that does sound a bit wasteful space wise.
>
>Cc: Ben Widawsky <ben@bwidawsk.net>
>Cc: intel-gfx@lists.freedesktop.org
>Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

I have a comment below however, you can consider it:
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>

>---
> drivers/gpu/drm/i915/intel_display.c | 37 ++++++++++++++++++++++++++++++++++++
> include/uapi/drm/drm_fourcc.h        |  3 +++
> 2 files changed, 40 insertions(+)
>
>diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
>index 7b7135be3b9e..de6909770c68 100644
>--- a/drivers/gpu/drm/i915/intel_display.c
>+++ b/drivers/gpu/drm/i915/intel_display.c
>@@ -2488,6 +2488,42 @@ static unsigned int intel_fb_modifier_to_tiling(uint64_t fb_modifier)
> 	}
> }
>
>+static const struct drm_format_info ccs_formats[] = {
>+	{ .format = DRM_FORMAT_XRGB8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
>+	{ .format = DRM_FORMAT_XBGR8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
>+	{ .format = DRM_FORMAT_ARGB8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
>+	{ .format = DRM_FORMAT_ABGR8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
>+};
>+
>+static const struct drm_format_info *
>+lookup_format_info(const struct drm_format_info formats[],
>+		   int num_formats, u32 format)
>+{
>+	int i;
>+
>+	for (i = 0; i < num_formats; i++) {
>+		if (formats[i].format == format)
>+			return &formats[i];
>+	}
>+
>+	return NULL;
>+}
>+
>+static const struct drm_format_info *
>+intel_get_format_info(struct drm_device *dev,
>+		      const struct drm_mode_fb_cmd2 *cmd)
>+{
>+	switch (cmd->modifier[0]) {
>+	case I915_FORMAT_MOD_Y_TILED_CCS:
>+	case I915_FORMAT_MOD_Yf_TILED_CCS:
>+		return lookup_format_info(ccs_formats,
>+					  ARRAY_SIZE(ccs_formats),
>+					  cmd->pixel_format);
>+	default:
>+		return NULL;
>+	}
>+}
>+

It sort of seems like somewhat of a waste to provide this if implementations are
allowed to return NULL. It's like saying, "DRM core will check stuff for you if
you provide the info, but you don't have to do it if you don't want to." If
that's the case you may as well provide a driver hook to just do the check, ie.
s/mod_funcs->get_format_info/mode_functs->check_format/

> static int
> intel_fill_fb_info(struct drm_i915_private *dev_priv,
> 		   struct drm_framebuffer *fb)
>@@ -15922,6 +15958,7 @@ intel_user_framebuffer_create(struct drm_device *dev,
>
> static const struct drm_mode_config_funcs intel_mode_funcs = {
> 	.fb_create = intel_user_framebuffer_create,
>+	.get_format_info = intel_get_format_info,
> 	.output_poll_changed = intel_fbdev_output_poll_changed,
> 	.atomic_check = intel_atomic_check,
> 	.atomic_commit = intel_atomic_commit,
>diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
>index a5890bf44c0a..2926d916f199 100644
>--- a/include/uapi/drm/drm_fourcc.h
>+++ b/include/uapi/drm/drm_fourcc.h
>@@ -218,6 +218,9 @@ extern "C" {
>  */
> #define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3)
>
>+#define I915_FORMAT_MOD_Y_TILED_CCS	fourcc_mod_code(INTEL, 4)
>+#define I915_FORMAT_MOD_Yf_TILED_CCS	fourcc_mod_code(INTEL, 5)
>+
> /*
>  * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks
>  *

-- 
Ben Widawsky, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH v2 19/37] drm: Store a pointer to drm_format_info under drm_framebuffer
  2016-11-18 19:52 ` [PATCH v2 19/37] drm: Store a pointer to drm_format_info under drm_framebuffer ville.syrjala
@ 2016-11-19  2:33   ` Laurent Pinchart
  0 siblings, 0 replies; 99+ messages in thread
From: Laurent Pinchart @ 2016-11-19  2:33 UTC (permalink / raw)
  To: ville.syrjala; +Cc: dri-devel

Hi Ville,

Thank you for the patch.

On Friday 18 Nov 2016 21:52:55 ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> To avoid having to look up the format information struct every time,
> let's just store a pointer to it under drm_framebuffer.
> 
> v2: Don't populate the fb->format pointer in drm_framebuffer_init().
>     instead we'll treat a NULL format as an error later
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/drm_modeset_helper.c | 1 +
>  include/drm/drm_framebuffer.h        | 4 ++++
>  2 files changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_modeset_helper.c
> b/drivers/gpu/drm/drm_modeset_helper.c index 57a319e3f780..1aa5e3bcc8a1
> 100644
> --- a/drivers/gpu/drm/drm_modeset_helper.c
> +++ b/drivers/gpu/drm/drm_modeset_helper.c
> @@ -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++) {
> diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
> index b3141a0e609b..741b3a994d1f 100644
> --- a/include/drm/drm_framebuffer.h
> +++ b/include/drm/drm_framebuffer.h
> @@ -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;

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 22/37] drm: Reject fbs w/o format info in drm_framebuffer_init()
  2016-11-18 19:52 ` [PATCH 22/37] drm: Reject fbs w/o format info in drm_framebuffer_init() ville.syrjala
@ 2016-11-19  2:36   ` Laurent Pinchart
  0 siblings, 0 replies; 99+ messages in thread
From: Laurent Pinchart @ 2016-11-19  2:36 UTC (permalink / raw)
  To: ville.syrjala; +Cc: dri-devel

Hi Ville,

Thank you for the patch.

On Friday 18 Nov 2016 21:52:58 ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Any framebuffer that doesn't have proper format information when
> drm_framebuffer_init() is called is a bug. Let's warn and return
> an error to avoid oopsing the kernel later due to dereferencing the
> NULL fb->format pointer.
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/drm_framebuffer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_framebuffer.c
> b/drivers/gpu/drm/drm_framebuffer.c index f397565d3c20..892976d974e5 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -631,7 +631,7 @@ int drm_framebuffer_init(struct drm_device *dev, struct
> drm_framebuffer *fb, {
>  	int ret;
> 
> -	if (WARN_ON_ONCE(fb->dev != dev))
> +	if (WARN_ON_ONCE(fb->dev != dev || !fb->format))
>  		return -EINVAL;
> 
>  	INIT_LIST_HEAD(&fb->filp_head);

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 23/37] drm: Replace drm_format_num_planes() with fb->format->num_planes
  2016-11-18 19:52 ` [PATCH 23/37] drm: Replace drm_format_num_planes() with fb->format->num_planes ville.syrjala
@ 2016-11-19  2:41   ` Laurent Pinchart
  2016-12-14 21:30   ` [PATCH v2 " ville.syrjala
  1 sibling, 0 replies; 99+ messages in thread
From: Laurent Pinchart @ 2016-11-19  2:41 UTC (permalink / raw)
  To: ville.syrjala; +Cc: dri-devel

Hi Ville,

Thank you for the patch.

On Friday 18 Nov 2016 21:52:59 ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Replace drm_format_num_planes(fb->pixel_format) with just
> fb->format->num_planes. Avoids the expensive format info lookup.
> 
> @@
> struct drm_framebuffer *a;
> struct drm_framebuffer b;
> @@
> (
> - drm_format_num_planes(a->pixel_format)
> + a->format->num_planes
> 
> - drm_format_num_planes(b.pixel_format)
> + b.format->num_planes
> )
> 
> @@
> struct drm_plane_state *a;
> struct drm_plane_state b;
> @@
> (
> - drm_format_num_planes(a->fb->pixel_format)
> + a->fb->format->num_planes
> 
> - drm_format_num_planes(b.fb->pixel_format)
> + b.fb->format->num_planes
> )
> 
> @@
> struct drm_framebuffer *a;
> identifier T;
> @@
>   T = a->pixel_format
> <+...
> - drm_format_num_planes(T)
> + a->format->num_planes
> ...+>
> 
> @@
> struct drm_framebuffer b;
> identifier T;
> @@
>   T = b.pixel_format
> <+...
> - drm_format_num_planes(T)
> + b.format->num_planes
> ...+>
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/arm/malidp_planes.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 | 2 +-
>  drivers/gpu/drm/drm_atomic.c                    | 2 +-
>  drivers/gpu/drm/i915/intel_display.c            | 2 +-
>  drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c       | 2 +-
>  drivers/gpu/drm/msm/msm_fb.c                    | 8 ++++----
>  drivers/gpu/drm/omapdrm/omap_fb.c               | 8 ++++----
>  drivers/gpu/drm/tegra/dc.c                      | 4 ++--
>  drivers/gpu/drm/tegra/fb.c                      | 2 +-
>  drivers/gpu/drm/vc4/vc4_plane.c                 | 2 +-
>  12 files changed, 19 insertions(+), 19 deletions(-)

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 25/37] drm: Replace drm_format_plane_cpp() with fb->format->cpp[]
  2016-11-18 19:53 ` [PATCH 25/37] drm: Replace drm_format_plane_cpp() with fb->format->cpp[] ville.syrjala
@ 2016-11-19  2:44   ` Laurent Pinchart
  2016-12-14 21:30   ` [PATCH v2 " ville.syrjala
  1 sibling, 0 replies; 99+ messages in thread
From: Laurent Pinchart @ 2016-11-19  2:44 UTC (permalink / raw)
  To: ville.syrjala; +Cc: dri-devel

Hi Ville,

Thank you for the patch.

On Friday 18 Nov 2016 21:53:01 ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Replace drm_format_plane_cpp(fb->pixel_format) with just
> fb->format->cpp[]. Avoids the expensive format info lookup.
> 
> @@
> struct drm_framebuffer *a;
> struct drm_framebuffer b;
> expression E;
> @@
> (
> - drm_format_plane_cpp(a->pixel_format, E)
> + a->format->cpp[E]
> 
> - drm_format_plane_cpp(b.pixel_format, E)
> + b.format->cpp[E]
> )
> 
> @@
> struct drm_plane_state *a;
> struct drm_plane_state b;
> expression E;
> @@
> (
> - drm_format_plane_cpp(a->fb->pixel_format, E)
> + a->fb->format->cpp[E]
> 
> - drm_format_plane_cpp(b.fb->pixel_format, E)
> + b.fb->format->cpp[E]
> )
> 
> @@
> struct drm_framebuffer *a;
> identifier T;
> expression E;
> @@
>   T = a->pixel_format
> <+...
> - drm_format_plane_cpp(T, E)
> + a->format->cpp[E]
> ...+>
> 
> @@
> struct drm_framebuffer b;
> identifier T;
> expression E;
> @@
>   T = b.pixel_format
> <+...
> - drm_format_plane_cpp(T, E)
> + b.format->cpp[E]
> ...+>
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/arm/hdlcd_crtc.c                |  2 +-
>  drivers/gpu/drm/armada/armada_overlay.c         |  2 +-
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c |  2 +-
>  drivers/gpu/drm/i915/intel_display.c            | 16 +++++-----
>  drivers/gpu/drm/i915/intel_pm.c                 | 42 ++++++++++------------
>  drivers/gpu/drm/i915/intel_sprite.c             |  2 +-
>  drivers/gpu/drm/imx/ipuv3-plane.c               |  6 ++--
>  drivers/gpu/drm/mediatek/mtk_drm_plane.c        |  2 +-
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c     |  4 +--
>  drivers/gpu/drm/sti/sti_gdp.c                   |  2 +-
>  drivers/gpu/drm/sun4i/sun4i_backend.c           |  2 +-
>  drivers/gpu/drm/tilcdc/tilcdc_crtc.c            |  2 +-
>  drivers/gpu/drm/tilcdc/tilcdc_plane.c           |  2 +-
>  drivers/gpu/drm/vc4/vc4_plane.c                 |  2 +-
>  drivers/gpu/drm/zte/zx_plane.c                  |  2 +-
>  15 files changed, 45 insertions(+), 45 deletions(-)

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH v2 33/37] drm: Nuke fb->pixel_format
  2016-11-18 19:53 ` [PATCH v2 33/37] drm: Nuke fb->pixel_format ville.syrjala
@ 2016-11-19  2:55   ` Laurent Pinchart
  2016-12-14 21:32   ` [PATCH v3 " ville.syrjala
  1 sibling, 0 replies; 99+ messages in thread
From: Laurent Pinchart @ 2016-11-19  2:55 UTC (permalink / raw)
  To: ville.syrjala; +Cc: dri-devel

Hi Ville,

Thank you for the patch.

On Friday 18 Nov 2016 21:53:09 ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Replace uses of fb->pixel_format 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 *a;
> struct drm_framebuffer b;
> @@
> (
> - a->pixel_format
> + a->format->format
> 
> - b.pixel_format
> + b.format->format
> )
> 
> @@
> struct drm_plane_state *a;
> struct drm_plane_state b;
> @@
> (
> - a->fb->pixel_format
> + a->fb->format->format
> 
> - b.fb->pixel_format
> + b.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
> 
> - set->crtc->primary->fb->pixel_format
> + set->crtc->primary->fb->format->format
> )
> 
> @@
> @@
>  struct drm_framebuffer {
> 	 ...
> -	 uint32_t pixel_format;
> 	 ...
>  };
> 
> v2: Fix commit message (Laurent)
>     Rebase due to earlier removal of many fb->pixel_format uses,
>     including the 'fb->format = drm_format_info(fb->format->format);'
>     snafu
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  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                |  2 +-
>  drivers/gpu/drm/arm/malidp_planes.c             |  8 +++---
>  drivers/gpu/drm/armada/armada_crtc.c            |  2 +-
>  drivers/gpu/drm/armada/armada_overlay.c         |  2 +-
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 18 ++++++-------
>  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_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               | 34 ++++++++++-----------
>  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       |  2 +-
>  drivers/gpu/drm/msm/msm_fb.c                    |  2 +-
>  drivers/gpu/drm/nouveau/dispnv04/overlay.c      |  8 +++---
>  drivers/gpu/drm/nouveau/nv50_display.c          |  4 +--
>  drivers/gpu/drm/omapdrm/omap_fb.c               |  2 +-
>  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     | 18 ++++++-------
>  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                   |  8 +++---
>  drivers/gpu/drm/sti/sti_hqvdp.c                 |  2 +-
>  drivers/gpu/drm/sun4i/sun4i_backend.c           |  3 ++-
>  drivers/gpu/drm/tegra/dc.c                      |  2 +-
>  drivers/gpu/drm/tilcdc/tilcdc_crtc.c            |  2 +-
>  drivers/gpu/drm/tilcdc/tilcdc_plane.c           |  2 +-
>  drivers/gpu/drm/vc4/vc4_plane.c                 |  4 +--
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c             |  2 --
>  drivers/gpu/drm/zte/zx_plane.c                  |  2 +-
>  include/drm/drm_framebuffer.h                   |  4 ---
>  53 files changed, 143 insertions(+), 151 deletions(-)

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 34/37] drm: Replace 'format->format' comparisons to just 'format' comparisons
  2016-11-18 19:53 ` [PATCH 34/37] drm: Replace 'format->format' comparisons to just 'format' comparisons ville.syrjala
@ 2016-11-19  2:56   ` Laurent Pinchart
  0 siblings, 0 replies; 99+ messages in thread
From: Laurent Pinchart @ 2016-11-19  2:56 UTC (permalink / raw)
  To: ville.syrjala; +Cc: dri-devel

Hi Ville,

Thank you for the patch.

On Friday 18 Nov 2016 21:53:10 ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Rather than compare the format u32s of two format infos, we can direclty
> compare the format info pointers themselves. Noramlly all the ->format
> pointers all point to somwehere in the big array, so this is a valid
> way to test for equality.
> 
> Also drivers may want to point ->format at a private format info struct
> instead (eg. for special compressed formats with extra planes), so
> just comparing the pixel format values wouldn't necessaritly even work.
> But comparing the pointers will also take care of that case.
> 
> @@
> struct drm_framebuffer *a;
> struct drm_framebuffer *b;
> @@
> (
> - a->format->format != b->format->format
> + a->format != b->format
> 
> - a->format->format == b->format->format
> + a->format == b->format
> )
> 
> @@
> struct drm_plane_state *a;
> struct drm_plane_state *b;
> @@
> (
> - a->fb->format->format != b->fb->format->format
> + a->fb->format != b->fb->format
> 
> - a->fb->format->format == b->fb->format->format
> + a->fb->format == b->fb->format
> )
> 
> @@
> struct drm_crtc *crtc;
> struct drm_framebuffer *x;
> @@
> (
> - crtc->primary->fb->format->format != x->format->format
> + crtc->primary->fb->format != x->format
> 
> - x->format->format != crtc->primary->fb->format->format
> + x->format != crtc->primary->fb->format
> )
> 
> @@
> struct drm_mode_set *set;
> @@
> - set->fb->format->format != set->crtc->primary->fb->format->format
> + set->fb->format != set->crtc->primary->fb->format
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/armada/armada_crtc.c      | 2 +-
>  drivers/gpu/drm/drm_crtc_helper.c         | 3 +--
>  drivers/gpu/drm/drm_plane.c               | 2 +-
>  drivers/gpu/drm/i915/intel_display.c      | 2 +-
>  drivers/gpu/drm/imx/ipuv3-plane.c         | 6 +++---
>  drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 2 +-
>  drivers/gpu/drm/tilcdc/tilcdc_plane.c     | 2 +-
>  7 files changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/armada/armada_crtc.c
> b/drivers/gpu/drm/armada/armada_crtc.c index 52e139dc9e38..baebf3775f60
> 100644
> --- a/drivers/gpu/drm/armada/armada_crtc.c
> +++ b/drivers/gpu/drm/armada/armada_crtc.c
> @@ -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->format->format != crtc->primary->fb->format->format)
> +	if (fb->format != crtc->primary->fb->format)
>  		return -EINVAL;
> 
>  	work = kmalloc(sizeof(*work), GFP_KERNEL);
> diff --git a/drivers/gpu/drm/drm_crtc_helper.c
> b/drivers/gpu/drm/drm_crtc_helper.c index 94bce0b462aa..9d007f5f9732 100644
> --- a/drivers/gpu/drm/drm_crtc_helper.c
> +++ b/drivers/gpu/drm/drm_crtc_helper.c
> @@ -588,8 +588,7 @@ 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->format->format !=
> -			   set->crtc->primary->fb->format->format) {
> +		} else if (set->fb->format != set->crtc->primary->fb->format) 
{
>  			mode_changed = true;
>  		} else
>  			fb_changed = true;
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index ac1e06df7280..1d90520457d7 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -854,7 +854,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>  	if (ret)
>  		goto out;
> 
> -	if (crtc->primary->fb->format->format != fb->format->format) {
> +	if (crtc->primary->fb->format != fb->format) {
>  		DRM_DEBUG_KMS("Page flip is not allowed to change frame buffer
> format.\n"); ret = -EINVAL;
>  		goto out;
> diff --git a/drivers/gpu/drm/i915/intel_display.c
> b/drivers/gpu/drm/i915/intel_display.c index f5f9f1422d69..7b7135be3b9e
> 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -12148,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->format->format != crtc->primary->fb->format->format)
> +	if (fb->format != crtc->primary->fb->format)
>  		return -EINVAL;
> 
>  	/*
> diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c
> b/drivers/gpu/drm/imx/ipuv3-plane.c index 0b945f077344..8b5294d47cee 100644
> --- a/drivers/gpu/drm/imx/ipuv3-plane.c
> +++ b/drivers/gpu/drm/imx/ipuv3-plane.c
> @@ -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->format->format != old_fb->format->format))
> +			      fb->format != old_fb->format))
>  		crtc_state->mode_changed = true;
> 
>  	eba = drm_plane_state_to_eba(state);
> @@ -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->format->format == old_fb->format->format)) 
{
> +		if (old_fb && (fb->format == old_fb->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->format->format == old_fb->format->format)) 
{
> +		if (old_fb && (fb->format == old_fb->format)) {
>  			old_ubo = drm_plane_state_to_ubo(old_state);
>  			if (ubo != old_ubo)
>  				crtc_state->mode_changed = true;
> diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
> b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c index
> b90e9e497260..6ecc6bc1f531 100644
> --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
> +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
> @@ -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->format->format != old_state->fb->format-
>format) {
> +		if (state->fb->format != old_state->fb->format) {
>  			DBG("%s: pixel_format change!", mdp5_plane->name);
>  			full_modeset = true;
>  		}
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
> b/drivers/gpu/drm/tilcdc/tilcdc_plane.c index 4b7519dfd1b9..ba0d66c0d8ac
> 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
> @@ -77,7 +77,7 @@ static int tilcdc_plane_atomic_check(struct drm_plane
> *plane, }
> 
>  	if (state->fb && old_state->fb &&
> -	    state->fb->format->format != old_state->fb->format->format) {
> +	    state->fb->format != old_state->fb->format) {
>  		dev_dbg(plane->dev->dev,
>  			"%s(): pixel format change requires mode_change\n",
>  			__func__);

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 35/37] drm: Eliminate the useless "non-RGB fb" debug message
  2016-11-18 19:53 ` [PATCH 35/37] drm: Eliminate the useless "non-RGB fb" debug message ville.syrjala
@ 2016-11-19  2:57   ` Laurent Pinchart
  0 siblings, 0 replies; 99+ messages in thread
From: Laurent Pinchart @ 2016-11-19  2:57 UTC (permalink / raw)
  To: ville.syrjala; +Cc: dri-devel

Hi Ville,

Thank you for the patch.

On Friday 18 Nov 2016 21:53:11 ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> No point in spamming the log whenever a non-RGB fb is being
> constructed. And since there's nothing to do anymore that
> fb->bits_per_pixel and fb->depth are gone, we can just kill
> off this entire piece of code.
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/drm_modeset_helper.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_modeset_helper.c
> b/drivers/gpu/drm/drm_modeset_helper.c index 639e474e7d43..5b051859b8d3
> 100644
> --- a/drivers/gpu/drm/drm_modeset_helper.c
> +++ b/drivers/gpu/drm/drm_modeset_helper.c
> @@ -72,21 +72,10 @@ 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;
>  	int i;
> 
> -	info = drm_format_info(mode_cmd->pixel_format);
> -	if (!info || !info->depth) {
> -		struct drm_format_name_buf format_name;
> -
> -		DRM_DEBUG_KMS("non-RGB pixel format %s\n",
> -		              drm_get_format_name(mode_cmd->pixel_format,
> -		                                  &format_name));
> -	} else {
> -	}
> -
>  	fb->dev = dev;
> -	fb->format = info;
> +	fb->format = drm_format_info(mode_cmd->pixel_format);
>  	fb->width = mode_cmd->width;
>  	fb->height = mode_cmd->height;
>  	for (i = 0; i < 4; i++) {

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 36/37] drm: Add mode_config .get_format_info() hook
  2016-11-18 19:53 ` [PATCH 36/37] drm: Add mode_config .get_format_info() hook ville.syrjala
@ 2016-11-20  8:13   ` Laurent Pinchart
  2016-11-21 13:18     ` Ville Syrjälä
  2016-11-22 13:41   ` [PATCH v2 " ville.syrjala
  1 sibling, 1 reply; 99+ messages in thread
From: Laurent Pinchart @ 2016-11-20  8:13 UTC (permalink / raw)
  To: ville.syrjala; +Cc: Ben Widawsky, intel-gfx, dri-devel

Hi Ville,

Thank you for the patch.

On Friday 18 Nov 2016 21:53:12 ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Allow drivers to return a custom drm_format_info structure for special
> fb layouts. We'll use this for the compression control surface in i915.
> 
> Cc: Ben Widawsky <ben@bwidawsk.net>
> Cc: intel-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_fb_cma_helper.c  |  2 +-
>  drivers/gpu/drm/drm_fourcc.c         | 25 +++++++++++++++++++++++++
>  drivers/gpu/drm/drm_framebuffer.c    |  9 +++++++--
>  drivers/gpu/drm/drm_modeset_helper.c |  2 +-
>  include/drm/drm_fourcc.h             |  6 ++++++
>  include/drm/drm_mode_config.h        | 15 +++++++++++++++
>  6 files changed, 55 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c
> b/drivers/gpu/drm/drm_fb_cma_helper.c index aab4465307ed..d7f8876cf5e9
> 100644
> --- a/drivers/gpu/drm/drm_fb_cma_helper.c
> +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
> @@ -186,7 +186,7 @@ struct drm_framebuffer
> *drm_fb_cma_create_with_funcs(struct drm_device *dev, int ret;
>  	int i;
> 
> -	info = drm_format_info(mode_cmd->pixel_format);
> +	info = drm_get_format_info(dev, mode_cmd);
>  	if (!info)
>  		return ERR_PTR(-EINVAL);
> 
> diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> index 90d2cc8da8eb..7cfaee689f0c 100644
> --- a/drivers/gpu/drm/drm_fourcc.c
> +++ b/drivers/gpu/drm/drm_fourcc.c
> @@ -199,6 +199,31 @@ const struct drm_format_info *drm_format_info(u32
> format) EXPORT_SYMBOL(drm_format_info);
> 
>  /**
> + * drm_format_info - query information for a given framebuffer
> configuration

I assume you meant drm_get_format_info()

> + * @dev: DRM device

Do we need the dev pointer ?

> + * @mode_cmd: metadata from the userspace fb creation request
> + *
> + * Returns:
> + * The instance of struct drm_format_info that describes the pixel format,
> or
> + * NULL if the format is unsupported.

It would be useful to document how this function differs from 
drm_format_info(). I also wonder whether it would make sense to completely 
replace drm_format_info() to avoid keeping two separate but very similar 
functions.

> + */
> +const struct drm_format_info *
> +drm_get_format_info(struct drm_device *dev,
> +		    const struct drm_mode_fb_cmd2 *mode_cmd)
> +{
> +	const struct drm_format_info *info = NULL;
> +
> +	if (dev->mode_config.funcs->get_format_info)
> +		info = dev->mode_config.funcs->get_format_info(dev, mode_cmd);
> +
> +	if (!info)
> +		info = drm_format_info(mode_cmd->pixel_format);
> +
> +	return info;
> +}
> +EXPORT_SYMBOL(drm_get_format_info);
> +
> +/**
>   * drm_format_num_planes - get the number of planes for format
>   * @format: pixel format (DRM_FORMAT_*)
>   *
> diff --git a/drivers/gpu/drm/drm_framebuffer.c
> b/drivers/gpu/drm/drm_framebuffer.c index 94ddab41f24f..292930a5dcc2 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -126,11 +126,13 @@ int drm_mode_addfb(struct drm_device *dev,
>  	return 0;
>  }
> 
> -static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
> +static int framebuffer_check(struct drm_device *dev,
> +			     const struct drm_mode_fb_cmd2 *r)
>  {
>  	const struct drm_format_info *info;
>  	int i;
> 
> +	/* check if the format is supported at all */
>  	info = __drm_format_info(r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN);
>  	if (!info) {
>  		struct drm_format_name_buf format_name;
> @@ -140,6 +142,9 @@ static int framebuffer_check(const struct
> drm_mode_fb_cmd2 *r) return -EINVAL;
>  	}
> 
> +	/* now let the driver pick its own format info */
> +	info = drm_get_format_info(dev, r);
> +
>  	if (r->width == 0 || r->width % info->hsub) {
>  		DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width);
>  		return -EINVAL;
> @@ -263,7 +268,7 @@ drm_internal_framebuffer_create(struct drm_device *dev,
>  		return ERR_PTR(-EINVAL);
>  	}
> 
> -	ret = framebuffer_check(r);
> +	ret = framebuffer_check(dev, r);
>  	if (ret)
>  		return ERR_PTR(ret);
> 
> diff --git a/drivers/gpu/drm/drm_modeset_helper.c
> b/drivers/gpu/drm/drm_modeset_helper.c index 5b051859b8d3..f78df06a940d
> 100644
> --- a/drivers/gpu/drm/drm_modeset_helper.c
> +++ b/drivers/gpu/drm/drm_modeset_helper.c
> @@ -75,7 +75,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device
> *dev, int i;
> 
>  	fb->dev = dev;
> -	fb->format = drm_format_info(mode_cmd->pixel_format);
> +	fb->format = drm_get_format_info(dev, mode_cmd);
>  	fb->width = mode_cmd->width;
>  	fb->height = mode_cmd->height;
>  	for (i = 0; i < 4; i++) {
> diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
> index fcc08da850c8..6942e84b6edd 100644
> --- a/include/drm/drm_fourcc.h
> +++ b/include/drm/drm_fourcc.h
> @@ -25,6 +25,9 @@
>  #include <linux/types.h>
>  #include <uapi/drm/drm_fourcc.h>
> 
> +struct drm_device;
> +struct drm_mode_fb_cmd2;
> +
>  /**
>   * struct drm_format_info - information about a DRM format
>   * @format: 4CC format identifier (DRM_FORMAT_*)
> @@ -55,6 +58,9 @@ struct drm_format_name_buf {
> 
>  const struct drm_format_info *__drm_format_info(u32 format);
>  const struct drm_format_info *drm_format_info(u32 format);
> +const struct drm_format_info *
> +drm_get_format_info(struct drm_device *dev,
> +		    const struct drm_mode_fb_cmd2 *mode_cmd);
>  uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
>  int drm_format_num_planes(uint32_t format);
>  int drm_format_plane_cpp(uint32_t format, int plane);
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index bf9991b20611..80bb7e49bf8e 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -34,6 +34,7 @@ struct drm_file;
>  struct drm_device;
>  struct drm_atomic_state;
>  struct drm_mode_fb_cmd2;
> +struct drm_format_info;
> 
>  /**
>   * struct drm_mode_config_funcs - basic driver provided mode setting
> functions @@ -70,6 +71,20 @@ struct drm_mode_config_funcs {
>  					     const struct drm_mode_fb_cmd2 
*mode_cmd);
> 
>  	/**
> +	 * @get_format_info:
> +	 *
> +	 * Allows a driver to return custom format information for special
> +	 * fb layouts (eg. ones with auxiliary compresssion control planes).
> +	 *
> +	 * RETURNS:
> +	 *
> +	 * The format information specific to the given fb metadata, or
> +	 * NULL if none is found.
> +	 */
> +	const struct drm_format_info *(*get_format_info)(struct drm_device 
*dev,
> +							 const struct 
drm_mode_fb_cmd2 *mode_cmd);
> +
> +	/**
>  	 * @output_poll_changed:
>  	 *
>  	 * Callback used by helpers to inform the driver of output 
configuration

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Intel-gfx] [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS
  2016-11-18 19:53 ` [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS ville.syrjala
  2016-11-18 23:31   ` Ben Widawsky
@ 2016-11-21  8:42   ` Tvrtko Ursulin
  2016-11-21 13:27     ` Ville Syrjälä
  1 sibling, 1 reply; 99+ messages in thread
From: Tvrtko Ursulin @ 2016-11-21  8:42 UTC (permalink / raw)
  To: ville.syrjala, dri-devel; +Cc: Ben Widawsky, intel-gfx, Laurent Pinchart


Hi,

On 18/11/2016 19:53, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> By providing our own format information for the CCS formats, we should
> be able to make framebuffer_check() do the right thing for the CCS
> surface as well.
>
> Note that we'll return the same format info for both Y and Yf tiled
> format as that's what happens with the non-CCS Y vs. Yf as well. If
> desired, we could potentially return a unique pointer for each
> pixel_format+tiling+ccs combination, in which case we immediately be
> able to tell if any of that stuff changed by just comparing the
> pointers. But that does sound a bit wasteful space wise.
>
> Cc: Ben Widawsky <ben@bwidawsk.net>
> Cc: intel-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 37 ++++++++++++++++++++++++++++++++++++
>  include/uapi/drm/drm_fourcc.h        |  3 +++
>  2 files changed, 40 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 7b7135be3b9e..de6909770c68 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -2488,6 +2488,42 @@ static unsigned int intel_fb_modifier_to_tiling(uint64_t fb_modifier)
>  	}
>  }
>
> +static const struct drm_format_info ccs_formats[] = {
> +	{ .format = DRM_FORMAT_XRGB8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
> +	{ .format = DRM_FORMAT_XBGR8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
> +	{ .format = DRM_FORMAT_ARGB8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
> +	{ .format = DRM_FORMAT_ABGR8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
> +};
> +
> +static const struct drm_format_info *
> +lookup_format_info(const struct drm_format_info formats[],
> +		   int num_formats, u32 format)
> +{
> +	int i;
> +
> +	for (i = 0; i < num_formats; i++) {
> +		if (formats[i].format == format)
> +			return &formats[i];
> +	}
> +
> +	return NULL;
> +}
> +
> +static const struct drm_format_info *
> +intel_get_format_info(struct drm_device *dev,
> +		      const struct drm_mode_fb_cmd2 *cmd)
> +{
> +	switch (cmd->modifier[0]) {
> +	case I915_FORMAT_MOD_Y_TILED_CCS:
> +	case I915_FORMAT_MOD_Yf_TILED_CCS:
> +		return lookup_format_info(ccs_formats,
> +					  ARRAY_SIZE(ccs_formats),
> +					  cmd->pixel_format);
> +	default:
> +		return NULL;
> +	}
> +}
> +
>  static int
>  intel_fill_fb_info(struct drm_i915_private *dev_priv,
>  		   struct drm_framebuffer *fb)
> @@ -15922,6 +15958,7 @@ intel_user_framebuffer_create(struct drm_device *dev,
>
>  static const struct drm_mode_config_funcs intel_mode_funcs = {
>  	.fb_create = intel_user_framebuffer_create,
> +	.get_format_info = intel_get_format_info,
>  	.output_poll_changed = intel_fbdev_output_poll_changed,
>  	.atomic_check = intel_atomic_check,
>  	.atomic_commit = intel_atomic_commit,
> diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
> index a5890bf44c0a..2926d916f199 100644
> --- a/include/uapi/drm/drm_fourcc.h
> +++ b/include/uapi/drm/drm_fourcc.h
> @@ -218,6 +218,9 @@ extern "C" {
>   */
>  #define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3)
>
> +#define I915_FORMAT_MOD_Y_TILED_CCS	fourcc_mod_code(INTEL, 4)
> +#define I915_FORMAT_MOD_Yf_TILED_CCS	fourcc_mod_code(INTEL, 5)
> +

I think when fb modifiers were started the idea was that we would later 
partition our vendor bit space for different classes of things and have 
helper functions to extract the tiling, etc, from them.

For example have first 3-4 bits represent the tiling, then in this case 
one bit for CCS, etc.

Have you considered that when adding these ones, and concluded this 
different scheme is better for some reason?

Regards,

Tvrtko
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH v2 00/37] drm: Deduplicate fb format information (v2)
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (36 preceding siblings ...)
  2016-11-18 19:53 ` [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS ville.syrjala
@ 2016-11-21 11:18 ` Christian König
  2016-12-14 21:37 ` Ville Syrjälä
  38 siblings, 0 replies; 99+ messages in thread
From: Christian König @ 2016-11-21 11:18 UTC (permalink / raw)
  To: ville.syrjala, dri-devel
  Cc: Ben Widawsky, Gerd Hoffmann, Paulo Zanoni, Sinclair Yeh,
	Liviu Dudau, intel-gfx, Alexey Brodkin, Thomas Hellstrom,
	linux-graphics-maintainer, Laurent Pinchart, Mali DP Maintainers,
	Alex Deucher, Dave Airlie, Ben Skeggs

Patches #2 and #3 are Reviewed-by: Christian König 
<christian.koenig@amd.com>.

The rest is Acked-by: Christian König <christian.koenig@amd.com>.

Regards,
Christian.

Am 18.11.2016 um 20:52 schrieb ville.syrjala@linux.intel.com:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Second installment of my effort to remove the duplicated
> depth/bpp/pixel_format from drm_framebuffer and just use
> struct drm_format_info instead.
>
> I tried to address all of the review feedback, and collect
> up all the r-bs I already got. Thanks for the review, guys.
>
> Changes since the last version are roughly:
> * drm_framebuffer_init() now fails if the fb isn't properly prepared
> * Applied mode cocciry all over to use fb->format more extensively
> * Dropped a few i915 specific patches that were taken care of the
>    previous item
> * Took up Laurent's idea that we can just compare the fb->format
>    pointers instead of comparing the fb->format->format values
> * Added a new .get_format_info() hooks for drivers to provide custom
>    format information + an quick example patch how we'd hook it up
>    for i915 render compression support
>
> Link to the previous version:
> https://lists.freedesktop.org/archives/dri-devel/2016-November/124135.html
>
> Entire series is available here:
> git://github.com/vsyrjala/linux.git fb_format_dedup_2
>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Cc: Ben Widawsky <ben@bwidawsk.net>
> Cc: Brian Starkey <brian.starkey@arm.com>
> Cc: "Christian König" <christian.koenig@amd.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: intel-gfx@lists.freedesktop.org
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: linux-graphics-maintainer@vmware.com
> Cc: Liviu Dudau <liviu.dudau@arm.com>
> Cc: Mali DP Maintainers <malidp@foss.arm.com>
> Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
> Cc: Sinclair Yeh <syeh@vmware.com>
> Cc: Thomas Hellstrom <thellstrom@vmware.com>
>
> Ville Syrjälä (37):
>    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: Reject fbs w/o format info in drm_framebuffer_init()
>    drm: Replace drm_format_num_planes() with fb->format->num_planes
>    drm/i915: Eliminate the ugly 'fb?:' constructs from the ilk/skl wm
>      code
>    drm: Replace drm_format_plane_cpp() with fb->format->cpp[]
>    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: 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
>    drm: Replace 'format->format' comparisons to just 'format' comparisons
>    drm: Eliminate the useless "non-RGB fb" debug message
>    drm: Add mode_config .get_format_info() hook
>    drm/i915: Implement .get_format_info() hook for CCS
>
>   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         |   6 +-
>   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               |   3 +-
>   drivers/gpu/drm/drm_fb_cma_helper.c             |  13 ++-
>   drivers/gpu/drm/drm_fb_helper.c                 |  10 +--
>   drivers/gpu/drm/drm_fourcc.c                    |  25 ++++++
>   drivers/gpu/drm/drm_framebuffer.c               |  62 +++++++++++--
>   drivers/gpu/drm/drm_modeset_helper.c            |  22 +----
>   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            | 115 ++++++++++++++++--------
>   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                 |  67 +++++++-------
>   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        |   4 +-
>   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                 |   8 +-
>   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                  |   4 +-
>   include/drm/drm_fourcc.h                        |   6 ++
>   include/drm/drm_framebuffer.h                   |  27 +++---
>   include/drm/drm_mode_config.h                   |  15 ++++
>   include/drm/drm_modeset_helper.h                |   3 +-
>   include/uapi/drm/drm_fourcc.h                   |   3 +
>   110 files changed, 641 insertions(+), 470 deletions(-)
>

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 09/37] drm/arm: Add local 'fb' variables
  2016-11-18 19:52 ` [PATCH 09/37] drm/arm: " ville.syrjala
  2016-11-18 20:30   ` Brian Starkey
@ 2016-11-21 11:51   ` Liviu Dudau
  2016-11-22 13:48     ` Ville Syrjälä
  1 sibling, 1 reply; 99+ messages in thread
From: Liviu Dudau @ 2016-11-21 11:51 UTC (permalink / raw)
  To: ville.syrjala; +Cc: Mali DP Maintainers, Laurent Pinchart, dri-devel

On Fri, Nov 18, 2016 at 09:52:45PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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 <liviu.dudau@arm.com>

Acked-by: Liviu Dudau <liviu.dudau@arm.com>

Are you going to take the series through drm-misc or you want each sub-maintainer
to cherry pick the patches?

Best regards,
Liviu

> Cc: Brian Starkey <brian.starkey@arm.com>
> Cc: Mali DP Maintainers <malidp@foss.arm.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/arm/hdlcd_crtc.c    | 18 ++++++++++--------
>  drivers/gpu/drm/arm/malidp_planes.c |  6 +++---
>  2 files changed, 13 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
> index bbaa55add2d2..8a0fee03aa39 100644
> --- a/drivers/gpu/drm/arm/hdlcd_crtc.c
> +++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
> @@ -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);
>  }
> diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
> index 63eec8f37cfc..ee7f7663a307 100644
> --- a/drivers/gpu/drm/arm/malidp_planes.c
> +++ b/drivers/gpu/drm/arm/malidp_planes.c
> @@ -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;
>  
> -- 
> 2.7.4
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 36/37] drm: Add mode_config .get_format_info() hook
  2016-11-20  8:13   ` Laurent Pinchart
@ 2016-11-21 13:18     ` Ville Syrjälä
  2016-11-21 13:23       ` Laurent Pinchart
  0 siblings, 1 reply; 99+ messages in thread
From: Ville Syrjälä @ 2016-11-21 13:18 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Ben Widawsky, intel-gfx, dri-devel

On Sun, Nov 20, 2016 at 10:13:10AM +0200, Laurent Pinchart wrote:
> Hi Ville,
> 
> Thank you for the patch.
> 
> On Friday 18 Nov 2016 21:53:12 ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Allow drivers to return a custom drm_format_info structure for special
> > fb layouts. We'll use this for the compression control surface in i915.
> > 
> > Cc: Ben Widawsky <ben@bwidawsk.net>
> > Cc: intel-gfx@lists.freedesktop.org
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_fb_cma_helper.c  |  2 +-
> >  drivers/gpu/drm/drm_fourcc.c         | 25 +++++++++++++++++++++++++
> >  drivers/gpu/drm/drm_framebuffer.c    |  9 +++++++--
> >  drivers/gpu/drm/drm_modeset_helper.c |  2 +-
> >  include/drm/drm_fourcc.h             |  6 ++++++
> >  include/drm/drm_mode_config.h        | 15 +++++++++++++++
> >  6 files changed, 55 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c
> > b/drivers/gpu/drm/drm_fb_cma_helper.c index aab4465307ed..d7f8876cf5e9
> > 100644
> > --- a/drivers/gpu/drm/drm_fb_cma_helper.c
> > +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
> > @@ -186,7 +186,7 @@ struct drm_framebuffer
> > *drm_fb_cma_create_with_funcs(struct drm_device *dev, int ret;
> >  	int i;
> > 
> > -	info = drm_format_info(mode_cmd->pixel_format);
> > +	info = drm_get_format_info(dev, mode_cmd);
> >  	if (!info)
> >  		return ERR_PTR(-EINVAL);
> > 
> > diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> > index 90d2cc8da8eb..7cfaee689f0c 100644
> > --- a/drivers/gpu/drm/drm_fourcc.c
> > +++ b/drivers/gpu/drm/drm_fourcc.c
> > @@ -199,6 +199,31 @@ const struct drm_format_info *drm_format_info(u32
> > format) EXPORT_SYMBOL(drm_format_info);
> > 
> >  /**
> > + * drm_format_info - query information for a given framebuffer
> > configuration
> 
> I assume you meant drm_get_format_info()

Yes.

> 
> > + * @dev: DRM device
> 
> Do we need the dev pointer ?

Not at the moment. I was thinking we might allow drivers to return a
different set of formats based on the device type, but I'm not sure
that's all that useful since drivers will have to check for unsupported
formats anyway in .fb_create(). The only use case might be if you need
to select between two different format info structs based on the device
type, because you simply can't tell the formats apart based on the
mode_cmd. But that sort of thing feels like a bad idea to me, and might
as well just require that you must be able to tell formats that require
different format intos apart based on the mode_cmd (eg. by having
different modifiers on them).

So I guess we could just drop the 'dev' argument to make it harder for
people to make that sort of mistake.

> 
> > + * @mode_cmd: metadata from the userspace fb creation request
> > + *
> > + * Returns:
> > + * The instance of struct drm_format_info that describes the pixel format,
> > or
> > + * NULL if the format is unsupported.
> 
> It would be useful to document how this function differs from 
> drm_format_info(). I also wonder whether it would make sense to completely 
> replace drm_format_info() to avoid keeping two separate but very similar 
> functions.

Yeah, that is basically what I was thinking. But I didn't feel like
doing that myself as it looked like that might involve actual work
in some of the drivers. I figured I'd leave it up to whoever cares
about said drivers.

> 
> > + */
> > +const struct drm_format_info *
> > +drm_get_format_info(struct drm_device *dev,
> > +		    const struct drm_mode_fb_cmd2 *mode_cmd)
> > +{
> > +	const struct drm_format_info *info = NULL;
> > +
> > +	if (dev->mode_config.funcs->get_format_info)
> > +		info = dev->mode_config.funcs->get_format_info(dev, mode_cmd);
> > +
> > +	if (!info)
> > +		info = drm_format_info(mode_cmd->pixel_format);
> > +
> > +	return info;
> > +}
> > +EXPORT_SYMBOL(drm_get_format_info);
> > +
> > +/**
> >   * drm_format_num_planes - get the number of planes for format
> >   * @format: pixel format (DRM_FORMAT_*)
> >   *
> > diff --git a/drivers/gpu/drm/drm_framebuffer.c
> > b/drivers/gpu/drm/drm_framebuffer.c index 94ddab41f24f..292930a5dcc2 100644
> > --- a/drivers/gpu/drm/drm_framebuffer.c
> > +++ b/drivers/gpu/drm/drm_framebuffer.c
> > @@ -126,11 +126,13 @@ int drm_mode_addfb(struct drm_device *dev,
> >  	return 0;
> >  }
> > 
> > -static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
> > +static int framebuffer_check(struct drm_device *dev,
> > +			     const struct drm_mode_fb_cmd2 *r)
> >  {
> >  	const struct drm_format_info *info;
> >  	int i;
> > 
> > +	/* check if the format is supported at all */
> >  	info = __drm_format_info(r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN);
> >  	if (!info) {
> >  		struct drm_format_name_buf format_name;
> > @@ -140,6 +142,9 @@ static int framebuffer_check(const struct
> > drm_mode_fb_cmd2 *r) return -EINVAL;
> >  	}
> > 
> > +	/* now let the driver pick its own format info */
> > +	info = drm_get_format_info(dev, r);
> > +
> >  	if (r->width == 0 || r->width % info->hsub) {
> >  		DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width);
> >  		return -EINVAL;
> > @@ -263,7 +268,7 @@ drm_internal_framebuffer_create(struct drm_device *dev,
> >  		return ERR_PTR(-EINVAL);
> >  	}
> > 
> > -	ret = framebuffer_check(r);
> > +	ret = framebuffer_check(dev, r);
> >  	if (ret)
> >  		return ERR_PTR(ret);
> > 
> > diff --git a/drivers/gpu/drm/drm_modeset_helper.c
> > b/drivers/gpu/drm/drm_modeset_helper.c index 5b051859b8d3..f78df06a940d
> > 100644
> > --- a/drivers/gpu/drm/drm_modeset_helper.c
> > +++ b/drivers/gpu/drm/drm_modeset_helper.c
> > @@ -75,7 +75,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device
> > *dev, int i;
> > 
> >  	fb->dev = dev;
> > -	fb->format = drm_format_info(mode_cmd->pixel_format);
> > +	fb->format = drm_get_format_info(dev, mode_cmd);
> >  	fb->width = mode_cmd->width;
> >  	fb->height = mode_cmd->height;
> >  	for (i = 0; i < 4; i++) {
> > diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
> > index fcc08da850c8..6942e84b6edd 100644
> > --- a/include/drm/drm_fourcc.h
> > +++ b/include/drm/drm_fourcc.h
> > @@ -25,6 +25,9 @@
> >  #include <linux/types.h>
> >  #include <uapi/drm/drm_fourcc.h>
> > 
> > +struct drm_device;
> > +struct drm_mode_fb_cmd2;
> > +
> >  /**
> >   * struct drm_format_info - information about a DRM format
> >   * @format: 4CC format identifier (DRM_FORMAT_*)
> > @@ -55,6 +58,9 @@ struct drm_format_name_buf {
> > 
> >  const struct drm_format_info *__drm_format_info(u32 format);
> >  const struct drm_format_info *drm_format_info(u32 format);
> > +const struct drm_format_info *
> > +drm_get_format_info(struct drm_device *dev,
> > +		    const struct drm_mode_fb_cmd2 *mode_cmd);
> >  uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
> >  int drm_format_num_planes(uint32_t format);
> >  int drm_format_plane_cpp(uint32_t format, int plane);
> > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > index bf9991b20611..80bb7e49bf8e 100644
> > --- a/include/drm/drm_mode_config.h
> > +++ b/include/drm/drm_mode_config.h
> > @@ -34,6 +34,7 @@ struct drm_file;
> >  struct drm_device;
> >  struct drm_atomic_state;
> >  struct drm_mode_fb_cmd2;
> > +struct drm_format_info;
> > 
> >  /**
> >   * struct drm_mode_config_funcs - basic driver provided mode setting
> > functions @@ -70,6 +71,20 @@ struct drm_mode_config_funcs {
> >  					     const struct drm_mode_fb_cmd2 
> *mode_cmd);
> > 
> >  	/**
> > +	 * @get_format_info:
> > +	 *
> > +	 * Allows a driver to return custom format information for special
> > +	 * fb layouts (eg. ones with auxiliary compresssion control planes).
> > +	 *
> > +	 * RETURNS:
> > +	 *
> > +	 * The format information specific to the given fb metadata, or
> > +	 * NULL if none is found.
> > +	 */
> > +	const struct drm_format_info *(*get_format_info)(struct drm_device 
> *dev,
> > +							 const struct 
> drm_mode_fb_cmd2 *mode_cmd);
> > +
> > +	/**
> >  	 * @output_poll_changed:
> >  	 *
> >  	 * Callback used by helpers to inform the driver of output 
> configuration
> 
> -- 
> Regards,
> 
> Laurent Pinchart

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 36/37] drm: Add mode_config .get_format_info() hook
  2016-11-21 13:18     ` Ville Syrjälä
@ 2016-11-21 13:23       ` Laurent Pinchart
  2016-11-21 13:31         ` Ville Syrjälä
  0 siblings, 1 reply; 99+ messages in thread
From: Laurent Pinchart @ 2016-11-21 13:23 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: Ben Widawsky, intel-gfx, dri-devel

Hi Ville,

On Monday 21 Nov 2016 15:18:23 Ville Syrjälä wrote:
> On Sun, Nov 20, 2016 at 10:13:10AM +0200, Laurent Pinchart wrote:
> > On Friday 18 Nov 2016 21:53:12 ville.syrjala@linux.intel.com wrote:
> >> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >> 
> >> Allow drivers to return a custom drm_format_info structure for special
> >> fb layouts. We'll use this for the compression control surface in i915.
> >> 
> >> Cc: Ben Widawsky <ben@bwidawsk.net>
> >> Cc: intel-gfx@lists.freedesktop.org
> >> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >> ---
> >> 
> >>  drivers/gpu/drm/drm_fb_cma_helper.c  |  2 +-
> >>  drivers/gpu/drm/drm_fourcc.c         | 25 +++++++++++++++++++++++++
> >>  drivers/gpu/drm/drm_framebuffer.c    |  9 +++++++--
> >>  drivers/gpu/drm/drm_modeset_helper.c |  2 +-
> >>  include/drm/drm_fourcc.h             |  6 ++++++
> >>  include/drm/drm_mode_config.h        | 15 +++++++++++++++
> >>  6 files changed, 55 insertions(+), 4 deletions(-)
> >> 
> >> diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c
> >> b/drivers/gpu/drm/drm_fb_cma_helper.c index aab4465307ed..d7f8876cf5e9
> >> 100644
> >> --- a/drivers/gpu/drm/drm_fb_cma_helper.c
> >> +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
> >> @@ -186,7 +186,7 @@ struct drm_framebuffer
> >> *drm_fb_cma_create_with_funcs(struct drm_device *dev, int ret;
> >> 
> >>  	int i;
> >> 
> >> -	info = drm_format_info(mode_cmd->pixel_format);
> >> +	info = drm_get_format_info(dev, mode_cmd);
> >>  	if (!info)
> >>  		return ERR_PTR(-EINVAL);
> >> 
> >> diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> >> index 90d2cc8da8eb..7cfaee689f0c 100644
> >> --- a/drivers/gpu/drm/drm_fourcc.c
> >> +++ b/drivers/gpu/drm/drm_fourcc.c
> >> @@ -199,6 +199,31 @@ const struct drm_format_info *drm_format_info(u32
> >> format)
> >>  EXPORT_SYMBOL(drm_format_info);
> >> 
> >>  /**
> >> + * drm_format_info - query information for a given framebuffer
> >> configuration
> > 
> > I assume you meant drm_get_format_info()
> 
> Yes.
> 
> >> + * @dev: DRM device
> > 
> > Do we need the dev pointer ?
> 
> Not at the moment. I was thinking we might allow drivers to return a
> different set of formats based on the device type, but I'm not sure
> that's all that useful since drivers will have to check for unsupported
> formats anyway in .fb_create(). The only use case might be if you need
> to select between two different format info structs based on the device
> type, because you simply can't tell the formats apart based on the
> mode_cmd. But that sort of thing feels like a bad idea to me, and might
> as well just require that you must be able to tell formats that require
> different format intos apart based on the mode_cmd (eg. by having
> different modifiers on them).
> 
> So I guess we could just drop the 'dev' argument to make it harder for
> people to make that sort of mistake.

I think that's a good idea, yes.

> >> + * @mode_cmd: metadata from the userspace fb creation request
> >> + *
> >> + * Returns:
> >> + * The instance of struct drm_format_info that describes the pixel
> >> format, or
> >> + * NULL if the format is unsupported.
> > 
> > It would be useful to document how this function differs from
> > drm_format_info(). I also wonder whether it would make sense to completely
> > replace drm_format_info() to avoid keeping two separate but very similar
> > functions.
> 
> Yeah, that is basically what I was thinking. But I didn't feel like
> doing that myself as it looked like that might involve actual work
> in some of the drivers. I figured I'd leave it up to whoever cares
> about said drivers.

Which driver(s) are you thinking about ? If we want to make 
drm_get_format_info() the default we obviously need to pass modifiers 
directly, as in most cases we won't have a struct drm_mode_fb_cmd2 to pass to 
the function. If we remove the dev argument you could just pass NULL modifiers 
in most cases, I don't think that would involve much rework in drivers.

> >> + */
> >> +const struct drm_format_info *
> >> +drm_get_format_info(struct drm_device *dev,
> >> +		    const struct drm_mode_fb_cmd2 *mode_cmd)
> >> +{
> >> +	const struct drm_format_info *info = NULL;
> >> +
> >> +	if (dev->mode_config.funcs->get_format_info)
> >> +		info = dev->mode_config.funcs->get_format_info(dev, mode_cmd);
> >> +
> >> +	if (!info)
> >> +		info = drm_format_info(mode_cmd->pixel_format);
> >> +
> >> +	return info;
> >> +}
> >> +EXPORT_SYMBOL(drm_get_format_info);

-- 
Regards,

Laurent Pinchart

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS
  2016-11-21  8:42   ` [Intel-gfx] " Tvrtko Ursulin
@ 2016-11-21 13:27     ` Ville Syrjälä
  2016-11-21 14:04       ` Tvrtko Ursulin
  0 siblings, 1 reply; 99+ messages in thread
From: Ville Syrjälä @ 2016-11-21 13:27 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: Ben Widawsky, intel-gfx, dri-devel, Laurent Pinchart

On Mon, Nov 21, 2016 at 08:42:13AM +0000, Tvrtko Ursulin wrote:
> 
> Hi,
> 
> On 18/11/2016 19:53, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > By providing our own format information for the CCS formats, we should
> > be able to make framebuffer_check() do the right thing for the CCS
> > surface as well.
> >
> > Note that we'll return the same format info for both Y and Yf tiled
> > format as that's what happens with the non-CCS Y vs. Yf as well. If
> > desired, we could potentially return a unique pointer for each
> > pixel_format+tiling+ccs combination, in which case we immediately be
> > able to tell if any of that stuff changed by just comparing the
> > pointers. But that does sound a bit wasteful space wise.
> >
> > Cc: Ben Widawsky <ben@bwidawsk.net>
> > Cc: intel-gfx@lists.freedesktop.org
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/i915/intel_display.c | 37 ++++++++++++++++++++++++++++++++++++
> >  include/uapi/drm/drm_fourcc.h        |  3 +++
> >  2 files changed, 40 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> > index 7b7135be3b9e..de6909770c68 100644
> > --- a/drivers/gpu/drm/i915/intel_display.c
> > +++ b/drivers/gpu/drm/i915/intel_display.c
> > @@ -2488,6 +2488,42 @@ static unsigned int intel_fb_modifier_to_tiling(uint64_t fb_modifier)
> >  	}
> >  }
> >
> > +static const struct drm_format_info ccs_formats[] = {
> > +	{ .format = DRM_FORMAT_XRGB8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
> > +	{ .format = DRM_FORMAT_XBGR8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
> > +	{ .format = DRM_FORMAT_ARGB8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
> > +	{ .format = DRM_FORMAT_ABGR8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
> > +};
> > +
> > +static const struct drm_format_info *
> > +lookup_format_info(const struct drm_format_info formats[],
> > +		   int num_formats, u32 format)
> > +{
> > +	int i;
> > +
> > +	for (i = 0; i < num_formats; i++) {
> > +		if (formats[i].format == format)
> > +			return &formats[i];
> > +	}
> > +
> > +	return NULL;
> > +}
> > +
> > +static const struct drm_format_info *
> > +intel_get_format_info(struct drm_device *dev,
> > +		      const struct drm_mode_fb_cmd2 *cmd)
> > +{
> > +	switch (cmd->modifier[0]) {
> > +	case I915_FORMAT_MOD_Y_TILED_CCS:
> > +	case I915_FORMAT_MOD_Yf_TILED_CCS:
> > +		return lookup_format_info(ccs_formats,
> > +					  ARRAY_SIZE(ccs_formats),
> > +					  cmd->pixel_format);
> > +	default:
> > +		return NULL;
> > +	}
> > +}
> > +
> >  static int
> >  intel_fill_fb_info(struct drm_i915_private *dev_priv,
> >  		   struct drm_framebuffer *fb)
> > @@ -15922,6 +15958,7 @@ intel_user_framebuffer_create(struct drm_device *dev,
> >
> >  static const struct drm_mode_config_funcs intel_mode_funcs = {
> >  	.fb_create = intel_user_framebuffer_create,
> > +	.get_format_info = intel_get_format_info,
> >  	.output_poll_changed = intel_fbdev_output_poll_changed,
> >  	.atomic_check = intel_atomic_check,
> >  	.atomic_commit = intel_atomic_commit,
> > diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
> > index a5890bf44c0a..2926d916f199 100644
> > --- a/include/uapi/drm/drm_fourcc.h
> > +++ b/include/uapi/drm/drm_fourcc.h
> > @@ -218,6 +218,9 @@ extern "C" {
> >   */
> >  #define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3)
> >
> > +#define I915_FORMAT_MOD_Y_TILED_CCS	fourcc_mod_code(INTEL, 4)
> > +#define I915_FORMAT_MOD_Yf_TILED_CCS	fourcc_mod_code(INTEL, 5)
> > +
> 
> I think when fb modifiers were started the idea was that we would later 
> partition our vendor bit space for different classes of things and have 
> helper functions to extract the tiling, etc, from them.
> 
> For example have first 3-4 bits represent the tiling, then in this case 
> one bit for CCS, etc.
> 
> Have you considered that when adding these ones, and concluded this 
> different scheme is better for some reason?

I haven't considered anything. And obviously this patch isn't meant
for inclusion as is. I just needed sometime to make it compile.

Generally I don't think adding magic meaning for individual bits for
things like this is a particularly good idea. Every time I've seen a
scheme like that it has eventually turned ugly on account of running
out of bits in one place or another.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 36/37] drm: Add mode_config .get_format_info() hook
  2016-11-21 13:23       ` Laurent Pinchart
@ 2016-11-21 13:31         ` Ville Syrjälä
  2016-11-21 13:42           ` Laurent Pinchart
  0 siblings, 1 reply; 99+ messages in thread
From: Ville Syrjälä @ 2016-11-21 13:31 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Ben Widawsky, intel-gfx, dri-devel

On Mon, Nov 21, 2016 at 03:23:19PM +0200, Laurent Pinchart wrote:
> Hi Ville,
> 
> On Monday 21 Nov 2016 15:18:23 Ville Syrjälä wrote:
> > On Sun, Nov 20, 2016 at 10:13:10AM +0200, Laurent Pinchart wrote:
> > > On Friday 18 Nov 2016 21:53:12 ville.syrjala@linux.intel.com wrote:
> > >> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >> 
> > >> Allow drivers to return a custom drm_format_info structure for special
> > >> fb layouts. We'll use this for the compression control surface in i915.
> > >> 
> > >> Cc: Ben Widawsky <ben@bwidawsk.net>
> > >> Cc: intel-gfx@lists.freedesktop.org
> > >> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >> ---
> > >> 
> > >>  drivers/gpu/drm/drm_fb_cma_helper.c  |  2 +-
> > >>  drivers/gpu/drm/drm_fourcc.c         | 25 +++++++++++++++++++++++++
> > >>  drivers/gpu/drm/drm_framebuffer.c    |  9 +++++++--
> > >>  drivers/gpu/drm/drm_modeset_helper.c |  2 +-
> > >>  include/drm/drm_fourcc.h             |  6 ++++++
> > >>  include/drm/drm_mode_config.h        | 15 +++++++++++++++
> > >>  6 files changed, 55 insertions(+), 4 deletions(-)
> > >> 
> > >> diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c
> > >> b/drivers/gpu/drm/drm_fb_cma_helper.c index aab4465307ed..d7f8876cf5e9
> > >> 100644
> > >> --- a/drivers/gpu/drm/drm_fb_cma_helper.c
> > >> +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
> > >> @@ -186,7 +186,7 @@ struct drm_framebuffer
> > >> *drm_fb_cma_create_with_funcs(struct drm_device *dev, int ret;
> > >> 
> > >>  	int i;
> > >> 
> > >> -	info = drm_format_info(mode_cmd->pixel_format);
> > >> +	info = drm_get_format_info(dev, mode_cmd);
> > >>  	if (!info)
> > >>  		return ERR_PTR(-EINVAL);
> > >> 
> > >> diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> > >> index 90d2cc8da8eb..7cfaee689f0c 100644
> > >> --- a/drivers/gpu/drm/drm_fourcc.c
> > >> +++ b/drivers/gpu/drm/drm_fourcc.c
> > >> @@ -199,6 +199,31 @@ const struct drm_format_info *drm_format_info(u32
> > >> format)
> > >>  EXPORT_SYMBOL(drm_format_info);
> > >> 
> > >>  /**
> > >> + * drm_format_info - query information for a given framebuffer
> > >> configuration
> > > 
> > > I assume you meant drm_get_format_info()
> > 
> > Yes.
> > 
> > >> + * @dev: DRM device
> > > 
> > > Do we need the dev pointer ?
> > 
> > Not at the moment. I was thinking we might allow drivers to return a
> > different set of formats based on the device type, but I'm not sure
> > that's all that useful since drivers will have to check for unsupported
> > formats anyway in .fb_create(). The only use case might be if you need
> > to select between two different format info structs based on the device
> > type, because you simply can't tell the formats apart based on the
> > mode_cmd. But that sort of thing feels like a bad idea to me, and might
> > as well just require that you must be able to tell formats that require
> > different format intos apart based on the mode_cmd (eg. by having
> > different modifiers on them).
> > 
> > So I guess we could just drop the 'dev' argument to make it harder for
> > people to make that sort of mistake.
> 
> I think that's a good idea, yes.
> 
> > >> + * @mode_cmd: metadata from the userspace fb creation request
> > >> + *
> > >> + * Returns:
> > >> + * The instance of struct drm_format_info that describes the pixel
> > >> format, or
> > >> + * NULL if the format is unsupported.
> > > 
> > > It would be useful to document how this function differs from
> > > drm_format_info(). I also wonder whether it would make sense to completely
> > > replace drm_format_info() to avoid keeping two separate but very similar
> > > functions.
> > 
> > Yeah, that is basically what I was thinking. But I didn't feel like
> > doing that myself as it looked like that might involve actual work
> > in some of the drivers. I figured I'd leave it up to whoever cares
> > about said drivers.
> 
> Which driver(s) are you thinking about ?

The ones that my cocci stuff couldn't convert over to fb->format.

> If we want to make 
> drm_get_format_info() the default we obviously need to pass modifiers 
> directly, as in most cases we won't have a struct drm_mode_fb_cmd2 to pass to 
> the function. If we remove the dev argument you could just pass NULL modifiers 
> in most cases, I don't think that would involve much rework in drivers.

fb->format is probably the right choice in most cases. But some drivers
seemed to have some kind of internal format info struct instead which
was in the way of doing a trivial conversion. I didn't want to start
doing non-trivial conversions since the series was already way too big
as is.

> 
> > >> + */
> > >> +const struct drm_format_info *
> > >> +drm_get_format_info(struct drm_device *dev,
> > >> +		    const struct drm_mode_fb_cmd2 *mode_cmd)
> > >> +{
> > >> +	const struct drm_format_info *info = NULL;
> > >> +
> > >> +	if (dev->mode_config.funcs->get_format_info)
> > >> +		info = dev->mode_config.funcs->get_format_info(dev, mode_cmd);
> > >> +
> > >> +	if (!info)
> > >> +		info = drm_format_info(mode_cmd->pixel_format);
> > >> +
> > >> +	return info;
> > >> +}
> > >> +EXPORT_SYMBOL(drm_get_format_info);
> 
> -- 
> Regards,
> 
> Laurent Pinchart

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 36/37] drm: Add mode_config .get_format_info() hook
  2016-11-21 13:31         ` Ville Syrjälä
@ 2016-11-21 13:42           ` Laurent Pinchart
  2016-11-21 14:25             ` Ville Syrjälä
  0 siblings, 1 reply; 99+ messages in thread
From: Laurent Pinchart @ 2016-11-21 13:42 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: Ben Widawsky, intel-gfx, dri-devel

Hi Ville,

On Monday 21 Nov 2016 15:31:57 Ville Syrjälä wrote:
> On Mon, Nov 21, 2016 at 03:23:19PM +0200, Laurent Pinchart wrote:
> > On Monday 21 Nov 2016 15:18:23 Ville Syrjälä wrote:
> >> On Sun, Nov 20, 2016 at 10:13:10AM +0200, Laurent Pinchart wrote:
> >>> On Friday 18 Nov 2016 21:53:12 ville.syrjala@linux.intel.com wrote:
> >>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>>> 
> >>>> Allow drivers to return a custom drm_format_info structure for
> >>>> special fb layouts. We'll use this for the compression control surface
> >>>> in i915.
> >>>> 
> >>>> Cc: Ben Widawsky <ben@bwidawsk.net>
> >>>> Cc: intel-gfx@lists.freedesktop.org
> >>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>>> ---
> >>>> 
> >>>>  drivers/gpu/drm/drm_fb_cma_helper.c  |  2 +-
> >>>>  drivers/gpu/drm/drm_fourcc.c         | 25 +++++++++++++++++++++++++
> >>>>  drivers/gpu/drm/drm_framebuffer.c    |  9 +++++++--
> >>>>  drivers/gpu/drm/drm_modeset_helper.c |  2 +-
> >>>>  include/drm/drm_fourcc.h             |  6 ++++++
> >>>>  include/drm/drm_mode_config.h        | 15 +++++++++++++++
> >>>>  6 files changed, 55 insertions(+), 4 deletions(-)

[snip]

> >>>> diff --git a/drivers/gpu/drm/drm_fourcc.c
> >>>> b/drivers/gpu/drm/drm_fourcc.c
> >>>> index 90d2cc8da8eb..7cfaee689f0c 100644
> >>>> --- a/drivers/gpu/drm/drm_fourcc.c
> >>>> +++ b/drivers/gpu/drm/drm_fourcc.c
> >>>> @@ -199,6 +199,31 @@ const struct drm_format_info
> >>>> *drm_format_info(u32 format)
> >>>>  EXPORT_SYMBOL(drm_format_info);
> >>>>  
> >>>>  /**
> >>>> + * drm_format_info - query information for a given framebuffer
> >>>> configuration
> >>> 
> >>> I assume you meant drm_get_format_info()
> >> 
> >> Yes.
> >> 
> >>>> + * @dev: DRM device
> >>> 
> >>> Do we need the dev pointer ?
> >> 
> >> Not at the moment. I was thinking we might allow drivers to return a
> >> different set of formats based on the device type, but I'm not sure
> >> that's all that useful since drivers will have to check for unsupported
> >> formats anyway in .fb_create(). The only use case might be if you need
> >> to select between two different format info structs based on the device
> >> type, because you simply can't tell the formats apart based on the
> >> mode_cmd. But that sort of thing feels like a bad idea to me, and might
> >> as well just require that you must be able to tell formats that require
> >> different format intos apart based on the mode_cmd (eg. by having
> >> different modifiers on them).
> >> 
> >> So I guess we could just drop the 'dev' argument to make it harder for
> >> people to make that sort of mistake.
> > 
> > I think that's a good idea, yes.
> > 
> >>>> + * @mode_cmd: metadata from the userspace fb creation request
> >>>> + *
> >>>> + * Returns:
> >>>> + * The instance of struct drm_format_info that describes the pixel
> >>>> format, or
> >>>> + * NULL if the format is unsupported.
> >>> 
> >>> It would be useful to document how this function differs from
> >>> drm_format_info(). I also wonder whether it would make sense to
> >>> completely replace drm_format_info() to avoid keeping two separate but
> >>> very similar functions.
> >> 
> >> Yeah, that is basically what I was thinking. But I didn't feel like
> >> doing that myself as it looked like that might involve actual work
> >> in some of the drivers. I figured I'd leave it up to whoever cares
> >> about said drivers.
> > 
> > Which driver(s) are you thinking about ?
> 
> The ones that my cocci stuff couldn't convert over to fb->format.

How about at least making drm_get_format_info() the default but converting 
what can be converted with coccinelle, and marking drm_format_info() as 
deprecated ?

> > If we want to make drm_get_format_info() the default we obviously need to
> > pass modifiers directly, as in most cases we won't have a struct
> > drm_mode_fb_cmd2 to pass to the function. If we remove the dev argument
> > you could just pass NULL modifiers in most cases, I don't think that would
> > involve much rework in drivers.
>
> fb->format is probably the right choice in most cases. But some drivers
> seemed to have some kind of internal format info struct instead which
> was in the way of doing a trivial conversion. I didn't want to start
> doing non-trivial conversions since the series was already way too big
> as is.

That's an interesting point I wanted to also mention. We have drivers that 
include formats information tables duplicating the one in the DRM core, with 
additional driver-specific information (see rcar_du_format_info() in 
drivers/gpu/drm/rcar-du/rcar_du_kms.c for instance). I wonder whether it would 
be possible to come up with a simple API that would allow providing those 
driver-specific data to the core, and get them back from the 
drm_get_format_info() function.

-- 
Regards,

Laurent Pinchart

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS
  2016-11-21 13:27     ` Ville Syrjälä
@ 2016-11-21 14:04       ` Tvrtko Ursulin
  0 siblings, 0 replies; 99+ messages in thread
From: Tvrtko Ursulin @ 2016-11-21 14:04 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Ben Widawsky, intel-gfx, dri-devel, Laurent Pinchart


On 21/11/2016 13:27, Ville Syrjälä wrote:
> On Mon, Nov 21, 2016 at 08:42:13AM +0000, Tvrtko Ursulin wrote:
>>
>> Hi,
>>
>> On 18/11/2016 19:53, ville.syrjala@linux.intel.com wrote:
>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>
>>> By providing our own format information for the CCS formats, we should
>>> be able to make framebuffer_check() do the right thing for the CCS
>>> surface as well.
>>>
>>> Note that we'll return the same format info for both Y and Yf tiled
>>> format as that's what happens with the non-CCS Y vs. Yf as well. If
>>> desired, we could potentially return a unique pointer for each
>>> pixel_format+tiling+ccs combination, in which case we immediately be
>>> able to tell if any of that stuff changed by just comparing the
>>> pointers. But that does sound a bit wasteful space wise.
>>>
>>> Cc: Ben Widawsky <ben@bwidawsk.net>
>>> Cc: intel-gfx@lists.freedesktop.org
>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>> ---
>>>  drivers/gpu/drm/i915/intel_display.c | 37 ++++++++++++++++++++++++++++++++++++
>>>  include/uapi/drm/drm_fourcc.h        |  3 +++
>>>  2 files changed, 40 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
>>> index 7b7135be3b9e..de6909770c68 100644
>>> --- a/drivers/gpu/drm/i915/intel_display.c
>>> +++ b/drivers/gpu/drm/i915/intel_display.c
>>> @@ -2488,6 +2488,42 @@ static unsigned int intel_fb_modifier_to_tiling(uint64_t fb_modifier)
>>>  	}
>>>  }
>>>
>>> +static const struct drm_format_info ccs_formats[] = {
>>> +	{ .format = DRM_FORMAT_XRGB8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
>>> +	{ .format = DRM_FORMAT_XBGR8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
>>> +	{ .format = DRM_FORMAT_ARGB8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
>>> +	{ .format = DRM_FORMAT_ABGR8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
>>> +};
>>> +
>>> +static const struct drm_format_info *
>>> +lookup_format_info(const struct drm_format_info formats[],
>>> +		   int num_formats, u32 format)
>>> +{
>>> +	int i;
>>> +
>>> +	for (i = 0; i < num_formats; i++) {
>>> +		if (formats[i].format == format)
>>> +			return &formats[i];
>>> +	}
>>> +
>>> +	return NULL;
>>> +}
>>> +
>>> +static const struct drm_format_info *
>>> +intel_get_format_info(struct drm_device *dev,
>>> +		      const struct drm_mode_fb_cmd2 *cmd)
>>> +{
>>> +	switch (cmd->modifier[0]) {
>>> +	case I915_FORMAT_MOD_Y_TILED_CCS:
>>> +	case I915_FORMAT_MOD_Yf_TILED_CCS:
>>> +		return lookup_format_info(ccs_formats,
>>> +					  ARRAY_SIZE(ccs_formats),
>>> +					  cmd->pixel_format);
>>> +	default:
>>> +		return NULL;
>>> +	}
>>> +}
>>> +
>>>  static int
>>>  intel_fill_fb_info(struct drm_i915_private *dev_priv,
>>>  		   struct drm_framebuffer *fb)
>>> @@ -15922,6 +15958,7 @@ intel_user_framebuffer_create(struct drm_device *dev,
>>>
>>>  static const struct drm_mode_config_funcs intel_mode_funcs = {
>>>  	.fb_create = intel_user_framebuffer_create,
>>> +	.get_format_info = intel_get_format_info,
>>>  	.output_poll_changed = intel_fbdev_output_poll_changed,
>>>  	.atomic_check = intel_atomic_check,
>>>  	.atomic_commit = intel_atomic_commit,
>>> diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
>>> index a5890bf44c0a..2926d916f199 100644
>>> --- a/include/uapi/drm/drm_fourcc.h
>>> +++ b/include/uapi/drm/drm_fourcc.h
>>> @@ -218,6 +218,9 @@ extern "C" {
>>>   */
>>>  #define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3)
>>>
>>> +#define I915_FORMAT_MOD_Y_TILED_CCS	fourcc_mod_code(INTEL, 4)
>>> +#define I915_FORMAT_MOD_Yf_TILED_CCS	fourcc_mod_code(INTEL, 5)
>>> +
>>
>> I think when fb modifiers were started the idea was that we would later
>> partition our vendor bit space for different classes of things and have
>> helper functions to extract the tiling, etc, from them.
>>
>> For example have first 3-4 bits represent the tiling, then in this case
>> one bit for CCS, etc.
>>
>> Have you considered that when adding these ones, and concluded this
>> different scheme is better for some reason?
>
> I haven't considered anything. And obviously this patch isn't meant
> for inclusion as is. I just needed sometime to make it compile.

No idea on the status of this series. Just noticed new modifiers by 
accident and remembered the early discussions.

> Generally I don't think adding magic meaning for individual bits for
> things like this is a particularly good idea. Every time I've seen a
> scheme like that it has eventually turned ugly on account of running
> out of bits in one place or another.

I think in this case it might be much better. You just need one more 
feature which intersects with tiling and ccs to make the list not very 
manageable.

Regards,

Tvrtko



_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 36/37] drm: Add mode_config .get_format_info() hook
  2016-11-21 13:42           ` Laurent Pinchart
@ 2016-11-21 14:25             ` Ville Syrjälä
  0 siblings, 0 replies; 99+ messages in thread
From: Ville Syrjälä @ 2016-11-21 14:25 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Ben Widawsky, intel-gfx, dri-devel

On Mon, Nov 21, 2016 at 03:42:34PM +0200, Laurent Pinchart wrote:
> Hi Ville,
> 
> On Monday 21 Nov 2016 15:31:57 Ville Syrjälä wrote:
> > On Mon, Nov 21, 2016 at 03:23:19PM +0200, Laurent Pinchart wrote:
> > > On Monday 21 Nov 2016 15:18:23 Ville Syrjälä wrote:
> > >> On Sun, Nov 20, 2016 at 10:13:10AM +0200, Laurent Pinchart wrote:
> > >>> On Friday 18 Nov 2016 21:53:12 ville.syrjala@linux.intel.com wrote:
> > >>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >>>> 
> > >>>> Allow drivers to return a custom drm_format_info structure for
> > >>>> special fb layouts. We'll use this for the compression control surface
> > >>>> in i915.
> > >>>> 
> > >>>> Cc: Ben Widawsky <ben@bwidawsk.net>
> > >>>> Cc: intel-gfx@lists.freedesktop.org
> > >>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >>>> ---
> > >>>> 
> > >>>>  drivers/gpu/drm/drm_fb_cma_helper.c  |  2 +-
> > >>>>  drivers/gpu/drm/drm_fourcc.c         | 25 +++++++++++++++++++++++++
> > >>>>  drivers/gpu/drm/drm_framebuffer.c    |  9 +++++++--
> > >>>>  drivers/gpu/drm/drm_modeset_helper.c |  2 +-
> > >>>>  include/drm/drm_fourcc.h             |  6 ++++++
> > >>>>  include/drm/drm_mode_config.h        | 15 +++++++++++++++
> > >>>>  6 files changed, 55 insertions(+), 4 deletions(-)
> 
> [snip]
> 
> > >>>> diff --git a/drivers/gpu/drm/drm_fourcc.c
> > >>>> b/drivers/gpu/drm/drm_fourcc.c
> > >>>> index 90d2cc8da8eb..7cfaee689f0c 100644
> > >>>> --- a/drivers/gpu/drm/drm_fourcc.c
> > >>>> +++ b/drivers/gpu/drm/drm_fourcc.c
> > >>>> @@ -199,6 +199,31 @@ const struct drm_format_info
> > >>>> *drm_format_info(u32 format)
> > >>>>  EXPORT_SYMBOL(drm_format_info);
> > >>>>  
> > >>>>  /**
> > >>>> + * drm_format_info - query information for a given framebuffer
> > >>>> configuration
> > >>> 
> > >>> I assume you meant drm_get_format_info()
> > >> 
> > >> Yes.
> > >> 
> > >>>> + * @dev: DRM device
> > >>> 
> > >>> Do we need the dev pointer ?
> > >> 
> > >> Not at the moment. I was thinking we might allow drivers to return a
> > >> different set of formats based on the device type, but I'm not sure
> > >> that's all that useful since drivers will have to check for unsupported
> > >> formats anyway in .fb_create(). The only use case might be if you need
> > >> to select between two different format info structs based on the device
> > >> type, because you simply can't tell the formats apart based on the
> > >> mode_cmd. But that sort of thing feels like a bad idea to me, and might
> > >> as well just require that you must be able to tell formats that require
> > >> different format intos apart based on the mode_cmd (eg. by having
> > >> different modifiers on them).
> > >> 
> > >> So I guess we could just drop the 'dev' argument to make it harder for
> > >> people to make that sort of mistake.
> > > 
> > > I think that's a good idea, yes.
> > > 
> > >>>> + * @mode_cmd: metadata from the userspace fb creation request
> > >>>> + *
> > >>>> + * Returns:
> > >>>> + * The instance of struct drm_format_info that describes the pixel
> > >>>> format, or
> > >>>> + * NULL if the format is unsupported.
> > >>> 
> > >>> It would be useful to document how this function differs from
> > >>> drm_format_info(). I also wonder whether it would make sense to
> > >>> completely replace drm_format_info() to avoid keeping two separate but
> > >>> very similar functions.
> > >> 
> > >> Yeah, that is basically what I was thinking. But I didn't feel like
> > >> doing that myself as it looked like that might involve actual work
> > >> in some of the drivers. I figured I'd leave it up to whoever cares
> > >> about said drivers.
> > > 
> > > Which driver(s) are you thinking about ?
> > 
> > The ones that my cocci stuff couldn't convert over to fb->format.
> 
> How about at least making drm_get_format_info() the default but converting 
> what can be converted with coccinelle, and marking drm_format_info() as 
> deprecated ?

I think I already did everything except the "mark as deprecated" part.
And adding that last bit into the patch would be trivial.

> 
> > > If we want to make drm_get_format_info() the default we obviously need to
> > > pass modifiers directly, as in most cases we won't have a struct
> > > drm_mode_fb_cmd2 to pass to the function. If we remove the dev argument
> > > you could just pass NULL modifiers in most cases, I don't think that would
> > > involve much rework in drivers.
> >
> > fb->format is probably the right choice in most cases. But some drivers
> > seemed to have some kind of internal format info struct instead which
> > was in the way of doing a trivial conversion. I didn't want to start
> > doing non-trivial conversions since the series was already way too big
> > as is.
> 
> That's an interesting point I wanted to also mention. We have drivers that 
> include formats information tables duplicating the one in the DRM core, with 
> additional driver-specific information (see rcar_du_format_info() in 
> drivers/gpu/drm/rcar-du/rcar_du_kms.c for instance). I wonder whether it would 
> be possible to come up with a simple API that would allow providing those 
> driver-specific data to the core, and get them back from the 
> drm_get_format_info() function.

I suppose drivers could just embed the drm_format_info into some bigger
structure which has additional information. One thing that makes that a
little harder is the fact that the regular format info structures aren't
exported to drivers in a way that they could just:

static const struct my_format_info format_info_foo {
	.base = drm_format_info_foo,
	...
};

So they'd have to duplicate the information which is maybe a little
error prone. OTOH that problem already exists to some degree with my
.get_format_info() hook (which somewhat makes me think we should just
put all of that stuff into drm_fourcc.c).

But I suppose exporting the drm_format_info structs could be done as
well, and then drivers could do whatever they want.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS
  2016-11-18 23:31   ` Ben Widawsky
@ 2016-11-21 14:37     ` Ville Syrjälä
  0 siblings, 0 replies; 99+ messages in thread
From: Ville Syrjälä @ 2016-11-21 14:37 UTC (permalink / raw)
  To: Ben Widawsky; +Cc: intel-gfx, Laurent Pinchart, dri-devel

On Fri, Nov 18, 2016 at 03:31:48PM -0800, Ben Widawsky wrote:
> On 16-11-18 21:53:13, Ville Syrjälä wrote:
> >From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> >By providing our own format information for the CCS formats, we should
> >be able to make framebuffer_check() do the right thing for the CCS
> >surface as well.
> >
> 
> I was hoping to see that patch as well :-). If you're adding the new fb
> modifiers, I think it'd make sense to make it part of this series.
> Alternatively, I can take 36, and 37 and make it part of my series, then
> integrate that last bit. It's up to you.
> 
> >Note that we'll return the same format info for both Y and Yf tiled
> >format as that's what happens with the non-CCS Y vs. Yf as well. If
> >desired, we could potentially return a unique pointer for each
> >pixel_format+tiling+ccs combination, in which case we immediately be
> >able to tell if any of that stuff changed by just comparing the
> >pointers. But that does sound a bit wasteful space wise.
> >
> >Cc: Ben Widawsky <ben@bwidawsk.net>
> >Cc: intel-gfx@lists.freedesktop.org
> >Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> I have a comment below however, you can consider it:
> Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
> 
> >---
> > drivers/gpu/drm/i915/intel_display.c | 37 ++++++++++++++++++++++++++++++++++++
> > include/uapi/drm/drm_fourcc.h        |  3 +++
> > 2 files changed, 40 insertions(+)
> >
> >diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> >index 7b7135be3b9e..de6909770c68 100644
> >--- a/drivers/gpu/drm/i915/intel_display.c
> >+++ b/drivers/gpu/drm/i915/intel_display.c
> >@@ -2488,6 +2488,42 @@ static unsigned int intel_fb_modifier_to_tiling(uint64_t fb_modifier)
> > 	}
> > }
> >
> >+static const struct drm_format_info ccs_formats[] = {
> >+	{ .format = DRM_FORMAT_XRGB8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
> >+	{ .format = DRM_FORMAT_XBGR8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
> >+	{ .format = DRM_FORMAT_ARGB8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
> >+	{ .format = DRM_FORMAT_ABGR8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },
> >+};
> >+
> >+static const struct drm_format_info *
> >+lookup_format_info(const struct drm_format_info formats[],
> >+		   int num_formats, u32 format)
> >+{
> >+	int i;
> >+
> >+	for (i = 0; i < num_formats; i++) {
> >+		if (formats[i].format == format)
> >+			return &formats[i];
> >+	}
> >+
> >+	return NULL;
> >+}
> >+
> >+static const struct drm_format_info *
> >+intel_get_format_info(struct drm_device *dev,
> >+		      const struct drm_mode_fb_cmd2 *cmd)
> >+{
> >+	switch (cmd->modifier[0]) {
> >+	case I915_FORMAT_MOD_Y_TILED_CCS:
> >+	case I915_FORMAT_MOD_Yf_TILED_CCS:
> >+		return lookup_format_info(ccs_formats,
> >+					  ARRAY_SIZE(ccs_formats),
> >+					  cmd->pixel_format);
> >+	default:
> >+		return NULL;
> >+	}
> >+}
> >+
> 
> It sort of seems like somewhat of a waste to provide this if implementations are
> allowed to return NULL. It's like saying, "DRM core will check stuff for you if
> you provide the info, but you don't have to do it if you don't want to."

The core will check the stuff anyway. The NULL just means "I don't have
any special requirements, so the core format info will be sufficient".

> If
> that's the case you may as well provide a driver hook to just do the check, ie.
> s/mod_funcs->get_format_info/mode_functs->check_format/

Drivers already have to do a bunch of checks in .fb_create(). In
addition the core does some basic sanity checks before the driver
even sees the mode_cmd (except for the new .get_format_info() hook
that is). I don't want every driver to have to duplicate all of these
basic sanity checks.

One alternative to this scheme would be have a helper function that
every driver would call in .fb_create() that would do these basic sanity
checks. That way we wouldn't need the extra hook, with a slight risk
that driver would forget to call the helper.

> 
> > static int
> > intel_fill_fb_info(struct drm_i915_private *dev_priv,
> > 		   struct drm_framebuffer *fb)
> >@@ -15922,6 +15958,7 @@ intel_user_framebuffer_create(struct drm_device *dev,
> >
> > static const struct drm_mode_config_funcs intel_mode_funcs = {
> > 	.fb_create = intel_user_framebuffer_create,
> >+	.get_format_info = intel_get_format_info,
> > 	.output_poll_changed = intel_fbdev_output_poll_changed,
> > 	.atomic_check = intel_atomic_check,
> > 	.atomic_commit = intel_atomic_commit,
> >diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
> >index a5890bf44c0a..2926d916f199 100644
> >--- a/include/uapi/drm/drm_fourcc.h
> >+++ b/include/uapi/drm/drm_fourcc.h
> >@@ -218,6 +218,9 @@ extern "C" {
> >  */
> > #define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3)
> >
> >+#define I915_FORMAT_MOD_Y_TILED_CCS	fourcc_mod_code(INTEL, 4)
> >+#define I915_FORMAT_MOD_Yf_TILED_CCS	fourcc_mod_code(INTEL, 5)
> >+
> > /*
> >  * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks
> >  *
> 
> -- 
> Ben Widawsky, Intel Open Source Technology Center

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 08/37] drm/arcpgu: Add local 'fb' variables
  2016-11-18 19:52 ` [PATCH 08/37] drm/arcpgu: Add " ville.syrjala
@ 2016-11-21 15:30   ` Alexey Brodkin
  2016-11-23 16:00   ` Alexey Brodkin
  1 sibling, 0 replies; 99+ messages in thread
From: Alexey Brodkin @ 2016-11-21 15:30 UTC (permalink / raw)
  To: ville.syrjala; +Cc: laurent.pinchart, dri-devel

Hi Ville,

On Fri, 2016-11-18 at 21:52 +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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.
> 
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/arc/arcpgu_crtc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> index 7130b044b004..5c26c5f126a3 100644
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> @@ -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;

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 14/37] drm/vmwgfx: Populate fb->pixel_format
  2016-11-18 19:52 ` [PATCH 14/37] drm/vmwgfx: Populate fb->pixel_format ville.syrjala
@ 2016-11-21 17:10   ` Sinclair Yeh
  0 siblings, 0 replies; 99+ messages in thread
From: Sinclair Yeh @ 2016-11-21 17:10 UTC (permalink / raw)
  To: ville.syrjala
  Cc: Thomas Hellstrom, linux-graphics-maintainer, Laurent Pinchart, dri-devel

Reviewed-by: Sinclair Yeh <syeh@vmware.com>

On Fri, Nov 18, 2016 at 09:52:50PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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.
> 
> Cc: linux-graphics-maintainer@vmware.com
> Cc: Sinclair Yeh <syeh@vmware.com>
> Cc: Thomas Hellstrom <thellstrom@vmware.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index 7d92ab56961b..5788913ca8f9 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -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;
> -- 
> 2.7.4
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 12/37] drm/vmwgfx: Populate fb->dev before drm_framebuffer_init()
  2016-11-18 19:52 ` [PATCH 12/37] drm/vmwgfx: Populate fb->dev before drm_framebuffer_init() ville.syrjala
@ 2016-11-21 17:10   ` Sinclair Yeh
  2016-11-22 13:53   ` [PATCH v2 " ville.syrjala
  1 sibling, 0 replies; 99+ messages in thread
From: Sinclair Yeh @ 2016-11-21 17:10 UTC (permalink / raw)
  To: ville.syrjala
  Cc: Thomas Hellstrom, linux-graphics-maintainer, Laurent Pinchart, dri-devel

Minor typo below.

Reviewed-by: Sinclair Yeh <syeh@vmware.com>

On Fri, Nov 18, 2016 at 09:52:48PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> drm_framebuffer_init() will start to check that fb->dev is already
> populated, so let's to that manually since vmwgfx isn't using
                      ^
do

> drm_helper_mode_fill_fb_struct().
> 
> Cc: linux-graphics-maintainer@vmware.com
> Cc: Sinclair Yeh <syeh@vmware.com>
> Cc: Thomas Hellstrom <thellstrom@vmware.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index e3f68cc9bb4b..7d92ab56961b 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -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;
> -- 
> 2.7.4
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* [PATCH v2 36/37] drm: Add mode_config .get_format_info() hook
  2016-11-18 19:53 ` [PATCH 36/37] drm: Add mode_config .get_format_info() hook ville.syrjala
  2016-11-20  8:13   ` Laurent Pinchart
@ 2016-11-22 13:41   ` ville.syrjala
  1 sibling, 0 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-22 13:41 UTC (permalink / raw)
  To: dri-devel; +Cc: Ben Widawsky, intel-gfx, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Allow drivers to return a custom drm_format_info structure for special
fb layouts. We'll use this for the compression control surface in i915.

v2: Fix drm_get_format_info() kernel doc (Laurent)
    Don't pass 'dev' to the new hook (Laurent)

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Ben Widawsky <ben@bwidawsk.net>
Cc: intel-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_fb_cma_helper.c  |  2 +-
 drivers/gpu/drm/drm_fourcc.c         | 25 +++++++++++++++++++++++++
 drivers/gpu/drm/drm_framebuffer.c    |  9 +++++++--
 drivers/gpu/drm/drm_modeset_helper.c |  2 +-
 include/drm/drm_fourcc.h             |  6 ++++++
 include/drm/drm_mode_config.h        | 14 ++++++++++++++
 6 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
index aab4465307ed..d7f8876cf5e9 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -186,7 +186,7 @@ struct drm_framebuffer *drm_fb_cma_create_with_funcs(struct drm_device *dev,
 	int ret;
 	int i;
 
-	info = drm_format_info(mode_cmd->pixel_format);
+	info = drm_get_format_info(dev, mode_cmd);
 	if (!info)
 		return ERR_PTR(-EINVAL);
 
diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index 90d2cc8da8eb..f9b6445e846a 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -199,6 +199,31 @@ const struct drm_format_info *drm_format_info(u32 format)
 EXPORT_SYMBOL(drm_format_info);
 
 /**
+ * drm_get_format_info - query information for a given framebuffer configuration
+ * @dev: DRM device
+ * @mode_cmd: metadata from the userspace fb creation request
+ *
+ * Returns:
+ * The instance of struct drm_format_info that describes the pixel format, or
+ * NULL if the format is unsupported.
+ */
+const struct drm_format_info *
+drm_get_format_info(struct drm_device *dev,
+		    const struct drm_mode_fb_cmd2 *mode_cmd)
+{
+	const struct drm_format_info *info = NULL;
+
+	if (dev->mode_config.funcs->get_format_info)
+		info = dev->mode_config.funcs->get_format_info(mode_cmd);
+
+	if (!info)
+		info = drm_format_info(mode_cmd->pixel_format);
+
+	return info;
+}
+EXPORT_SYMBOL(drm_get_format_info);
+
+/**
  * drm_format_num_planes - get the number of planes for format
  * @format: pixel format (DRM_FORMAT_*)
  *
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 94ddab41f24f..292930a5dcc2 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -126,11 +126,13 @@ int drm_mode_addfb(struct drm_device *dev,
 	return 0;
 }
 
-static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
+static int framebuffer_check(struct drm_device *dev,
+			     const struct drm_mode_fb_cmd2 *r)
 {
 	const struct drm_format_info *info;
 	int i;
 
+	/* check if the format is supported at all */
 	info = __drm_format_info(r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN);
 	if (!info) {
 		struct drm_format_name_buf format_name;
@@ -140,6 +142,9 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
 		return -EINVAL;
 	}
 
+	/* now let the driver pick its own format info */
+	info = drm_get_format_info(dev, r);
+
 	if (r->width == 0 || r->width % info->hsub) {
 		DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width);
 		return -EINVAL;
@@ -263,7 +268,7 @@ drm_internal_framebuffer_create(struct drm_device *dev,
 		return ERR_PTR(-EINVAL);
 	}
 
-	ret = framebuffer_check(r);
+	ret = framebuffer_check(dev, r);
 	if (ret)
 		return ERR_PTR(ret);
 
diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index 5b051859b8d3..f78df06a940d 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -75,7 +75,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
 	int i;
 
 	fb->dev = dev;
-	fb->format = drm_format_info(mode_cmd->pixel_format);
+	fb->format = drm_get_format_info(dev, mode_cmd);
 	fb->width = mode_cmd->width;
 	fb->height = mode_cmd->height;
 	for (i = 0; i < 4; i++) {
diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
index fcc08da850c8..6942e84b6edd 100644
--- a/include/drm/drm_fourcc.h
+++ b/include/drm/drm_fourcc.h
@@ -25,6 +25,9 @@
 #include <linux/types.h>
 #include <uapi/drm/drm_fourcc.h>
 
+struct drm_device;
+struct drm_mode_fb_cmd2;
+
 /**
  * struct drm_format_info - information about a DRM format
  * @format: 4CC format identifier (DRM_FORMAT_*)
@@ -55,6 +58,9 @@ struct drm_format_name_buf {
 
 const struct drm_format_info *__drm_format_info(u32 format);
 const struct drm_format_info *drm_format_info(u32 format);
+const struct drm_format_info *
+drm_get_format_info(struct drm_device *dev,
+		    const struct drm_mode_fb_cmd2 *mode_cmd);
 uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
 int drm_format_num_planes(uint32_t format);
 int drm_format_plane_cpp(uint32_t format, int plane);
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index bf9991b20611..3af17a3a69fb 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -34,6 +34,7 @@ struct drm_file;
 struct drm_device;
 struct drm_atomic_state;
 struct drm_mode_fb_cmd2;
+struct drm_format_info;
 
 /**
  * struct drm_mode_config_funcs - basic driver provided mode setting functions
@@ -70,6 +71,19 @@ struct drm_mode_config_funcs {
 					     const struct drm_mode_fb_cmd2 *mode_cmd);
 
 	/**
+	 * @get_format_info:
+	 *
+	 * Allows a driver to return custom format information for special
+	 * fb layouts (eg. ones with auxiliary compresssion control planes).
+	 *
+	 * RETURNS:
+	 *
+	 * The format information specific to the given fb metadata, or
+	 * NULL if none is found.
+	 */
+	const struct drm_format_info *(*get_format_info)(const struct drm_mode_fb_cmd2 *mode_cmd);
+
+	/**
 	 * @output_poll_changed:
 	 *
 	 * Callback used by helpers to inform the driver of output configuration
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* Re: [PATCH 09/37] drm/arm: Add local 'fb' variables
  2016-11-21 11:51   ` Liviu Dudau
@ 2016-11-22 13:48     ` Ville Syrjälä
  2016-11-22 13:57       ` Daniel Vetter
  0 siblings, 1 reply; 99+ messages in thread
From: Ville Syrjälä @ 2016-11-22 13:48 UTC (permalink / raw)
  To: Liviu Dudau; +Cc: dri-devel, Laurent Pinchart, Mali DP Maintainers

On Mon, Nov 21, 2016 at 11:51:21AM +0000, Liviu Dudau wrote:
> On Fri, Nov 18, 2016 at 09:52:45PM +0200, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > 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 <liviu.dudau@arm.com>
> 
> Acked-by: Liviu Dudau <liviu.dudau@arm.com>
> 
> Are you going to take the series through drm-misc or you want each sub-maintainer
> to cherry pick the patches?

Probably easier to suck it all in one go. Unless drm-misc maintainers
disagree?

> 
> Best regards,
> Liviu
> 
> > Cc: Brian Starkey <brian.starkey@arm.com>
> > Cc: Mali DP Maintainers <malidp@foss.arm.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/arm/hdlcd_crtc.c    | 18 ++++++++++--------
> >  drivers/gpu/drm/arm/malidp_planes.c |  6 +++---
> >  2 files changed, 13 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
> > index bbaa55add2d2..8a0fee03aa39 100644
> > --- a/drivers/gpu/drm/arm/hdlcd_crtc.c
> > +++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
> > @@ -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);
> >  }
> > diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
> > index 63eec8f37cfc..ee7f7663a307 100644
> > --- a/drivers/gpu/drm/arm/malidp_planes.c
> > +++ b/drivers/gpu/drm/arm/malidp_planes.c
> > @@ -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;
> >  
> > -- 
> > 2.7.4
> > 
> 
> -- 
> ====================
> | I would like to |
> | fix the world,  |
> | but they're not |
> | giving me the   |
>  \ source code!  /
>   ---------------
>     ¯\_(ツ)_/¯

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* [PATCH v2 12/37] drm/vmwgfx: Populate fb->dev before drm_framebuffer_init()
  2016-11-18 19:52 ` [PATCH 12/37] drm/vmwgfx: Populate fb->dev before drm_framebuffer_init() ville.syrjala
  2016-11-21 17:10   ` Sinclair Yeh
@ 2016-11-22 13:53   ` ville.syrjala
  1 sibling, 0 replies; 99+ messages in thread
From: ville.syrjala @ 2016-11-22 13:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Thomas Hellstrom, linux-graphics-maintainer, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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

v2: s/to/do/ (Sinclair)

Cc: linux-graphics-maintainer@vmware.com
Cc: Sinclair Yeh <syeh@vmware.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index e3f68cc9bb4b..7d92ab56961b 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -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;
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* Re: [PATCH 09/37] drm/arm: Add local 'fb' variables
  2016-11-22 13:48     ` Ville Syrjälä
@ 2016-11-22 13:57       ` Daniel Vetter
  0 siblings, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-22 13:57 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Liviu Dudau, dri-devel, Mali DP Maintainers, Laurent Pinchart

On Tue, Nov 22, 2016 at 03:48:50PM +0200, Ville Syrjälä wrote:
> On Mon, Nov 21, 2016 at 11:51:21AM +0000, Liviu Dudau wrote:
> > On Fri, Nov 18, 2016 at 09:52:45PM +0200, ville.syrjala@linux.intel.com wrote:
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > 
> > > 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 <liviu.dudau@arm.com>
> > 
> > Acked-by: Liviu Dudau <liviu.dudau@arm.com>
> > 
> > Are you going to take the series through drm-misc or you want each sub-maintainer
> > to cherry pick the patches?
> 
> Probably easier to suck it all in one go. Unless drm-misc maintainers
> disagree?

Seems like exactly the thing drm-misc is for.
-Daniel

> 
> > 
> > Best regards,
> > Liviu
> > 
> > > Cc: Brian Starkey <brian.starkey@arm.com>
> > > Cc: Mali DP Maintainers <malidp@foss.arm.com>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/arm/hdlcd_crtc.c    | 18 ++++++++++--------
> > >  drivers/gpu/drm/arm/malidp_planes.c |  6 +++---
> > >  2 files changed, 13 insertions(+), 11 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
> > > index bbaa55add2d2..8a0fee03aa39 100644
> > > --- a/drivers/gpu/drm/arm/hdlcd_crtc.c
> > > +++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
> > > @@ -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);
> > >  }
> > > diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
> > > index 63eec8f37cfc..ee7f7663a307 100644
> > > --- a/drivers/gpu/drm/arm/malidp_planes.c
> > > +++ b/drivers/gpu/drm/arm/malidp_planes.c
> > > @@ -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;
> > >  
> > > -- 
> > > 2.7.4
> > > 
> > 
> > -- 
> > ====================
> > | I would like to |
> > | fix the world,  |
> > | but they're not |
> > | giving me the   |
> >  \ source code!  /
> >   ---------------
> >     ¯\_(ツ)_/¯
> 
> -- 
> Ville Syrjälä
> Intel OTC

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 08/37] drm/arcpgu: Add local 'fb' variables
  2016-11-18 19:52 ` [PATCH 08/37] drm/arcpgu: Add " ville.syrjala
  2016-11-21 15:30   ` Alexey Brodkin
@ 2016-11-23 16:00   ` Alexey Brodkin
  1 sibling, 0 replies; 99+ messages in thread
From: Alexey Brodkin @ 2016-11-23 16:00 UTC (permalink / raw)
  To: ville.syrjala; +Cc: laurent.pinchart, dri-devel

Hi Ville,

On Fri, 2016-11-18 at 21:52 +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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.
> 
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/arc/arcpgu_crtc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> index 7130b044b004..5c26c5f126a3 100644
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> @@ -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;

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 01/37] drm/i915: Add local 'fb' variables
  2016-11-18 19:52 ` [PATCH 01/37] drm/i915: Add local 'fb' variables ville.syrjala
@ 2016-11-30 14:44   ` Daniel Vetter
  0 siblings, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 14:44 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, Laurent Pinchart, dri-devel

On Fri, Nov 18, 2016 at 09:52:37PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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.
> 
> Cc: intel-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/i915/intel_overlay.c | 26 ++++++++++++--------------
>  1 file changed, 12 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_overlay.c b/drivers/gpu/drm/i915/intel_overlay.c
> index fd0e4dac7cc1..ce3667c18e18 100644
> --- a/drivers/gpu/drm/i915/intel_overlay.c
> +++ b/drivers/gpu/drm/i915/intel_overlay.c
> @@ -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;
>  	}
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 04/37] drm/mgag200: Add local 'fb' variable
  2016-11-18 19:52 ` [PATCH 04/37] drm/mgag200: Add local 'fb' variable ville.syrjala
@ 2016-11-30 14:45   ` Daniel Vetter
  0 siblings, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 14:45 UTC (permalink / raw)
  To: ville.syrjala; +Cc: Dave Airlie, Laurent Pinchart, dri-devel

On Fri, Nov 18, 2016 at 09:52:40PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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: Dave Airlie <airlied@redhat.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/mgag200/mgag200_mode.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
> index 6b21cb27e1cc..bdac288ab16d 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_mode.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
> @@ -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;
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 05/37] drm/ast: Add local 'fb' variables
  2016-11-18 19:52 ` [PATCH 05/37] drm/ast: Add local 'fb' variables ville.syrjala
@ 2016-11-30 14:47   ` Daniel Vetter
  0 siblings, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 14:47 UTC (permalink / raw)
  To: ville.syrjala; +Cc: Dave Airlie, Laurent Pinchart, dri-devel

On Fri, Nov 18, 2016 at 09:52:41PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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: Dave Airlie <airlied@redhat.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/ast/ast_mode.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index 5957c3e659fe..deb3684ccaf8 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -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:
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 06/37] drm/gma500: Add some local 'fb' variables
  2016-11-18 19:52 ` [PATCH 06/37] drm/gma500: Add some " ville.syrjala
@ 2016-11-30 14:49   ` Daniel Vetter
  0 siblings, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 14:49 UTC (permalink / raw)
  To: ville.syrjala; +Cc: Laurent Pinchart, dri-devel

On Fri, Nov 18, 2016 at 09:52:42PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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 <patrik.r.jakobsson@gmail.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  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(-)
> 
> diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
> index 1a1cf7a3b5ef..05b9a4ceb58d 100644
> --- a/drivers/gpu/drm/gma500/gma_display.c
> +++ b/drivers/gpu/drm/gma500/gma_display.c
> @@ -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;
> diff --git a/drivers/gpu/drm/gma500/mdfld_intel_display.c b/drivers/gpu/drm/gma500/mdfld_intel_display.c
> index 92e3f93ee682..e80895285e94 100644
> --- a/drivers/gpu/drm/gma500/mdfld_intel_display.c
> +++ b/drivers/gpu/drm/gma500/mdfld_intel_display.c
> @@ -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;
> diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
> index da9fd34b9550..a51896544d91 100644
> --- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
> +++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
> @@ -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;
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 07/37] drm/cirrus: Add some local 'fb' variables
  2016-11-18 19:52 ` [PATCH 07/37] drm/cirrus: " ville.syrjala
@ 2016-11-30 14:50   ` Daniel Vetter
  0 siblings, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 14:50 UTC (permalink / raw)
  To: ville.syrjala; +Cc: Dave Airlie, Laurent Pinchart, dri-devel

On Fri, Nov 18, 2016 at 09:52:43PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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: Dave Airlie <airlied@redhat.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/cirrus/cirrus_mode.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c b/drivers/gpu/drm/cirrus/cirrus_mode.c
> index 17c915d9a03e..f2297acae235 100644
> --- a/drivers/gpu/drm/cirrus/cirrus_mode.c
> +++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
> @@ -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 */
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 10/37] drm/nouveau: Fix crtc->primary->fb vs. drm_fb fail
  2016-11-18 19:52 ` [PATCH 10/37] drm/nouveau: Fix crtc->primary->fb vs. drm_fb fail ville.syrjala
@ 2016-11-30 14:56   ` Daniel Vetter
  0 siblings, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 14:56 UTC (permalink / raw)
  To: ville.syrjala; +Cc: Laurent Pinchart, dri-devel, Ben Skeggs

On Fri, Nov 18, 2016 at 09:52:46PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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.
> 
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Oh dear, set_base_atomic indeed expects that the passed-in fb is used, and
that drivers do _not_ update crtc->primary->fb. And drm core expects them
to do that, kinda, or at least allows it. I guess time to nuke all that
kgdb stuff as dead code and unused since obviously all broken.

But that's another story, this here seems to make some sense.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/nouveau/dispnv04/crtc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
> index 59d1d1c5de5f..7c6c66f177df 100644
> --- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
> +++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
> @@ -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,
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 11/37] drm/nouveau: Add local 'fb' variables
  2016-11-18 19:52 ` [PATCH 11/37] drm/nouveau: Add local 'fb' variables ville.syrjala
@ 2016-11-30 14:57   ` Daniel Vetter
  0 siblings, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 14:57 UTC (permalink / raw)
  To: ville.syrjala; +Cc: Laurent Pinchart, dri-devel, Ben Skeggs

On Fri, Nov 18, 2016 at 09:52:47PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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: Ben Skeggs <bskeggs@redhat.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/nouveau/dispnv04/crtc.c | 5 +++--
>  drivers/gpu/drm/nouveau/dispnv04/dfp.c  | 3 ++-
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
> index 7c6c66f177df..8286b8ffe109 100644
> --- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
> +++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
> @@ -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;
> diff --git a/drivers/gpu/drm/nouveau/dispnv04/dfp.c b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
> index c2947ef7d4fc..945607b3cd41 100644
> --- a/drivers/gpu/drm/nouveau/dispnv04/dfp.c
> +++ b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
> @@ -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 {
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 16/37] drm/virtio: Call drm_helper_mode_fill_fb_struct() before drm_framebuffer_init()
  2016-11-18 19:52 ` [PATCH 16/37] drm/virtio: " ville.syrjala
@ 2016-11-30 15:32   ` Daniel Vetter
  0 siblings, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 15:32 UTC (permalink / raw)
  To: ville.syrjala; +Cc: Dave Airlie, Laurent Pinchart, dri-devel, Gerd Hoffmann

On Fri, Nov 18, 2016 at 09:52:52PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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 <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Yup, kernel-doc even says that drm_framebuffer_init() must be the very
last thing or races. I've done a full audit, and qxl&virtio are the only
two offenders. On both patches:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/virtio/virtgpu_display.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
> index 8b80fdd0e0a8..fad5a1cc5903 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_display.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_display.c
> @@ -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;
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 17/37] drm/i915: Set fb->dev early on for inherited fbs
  2016-11-18 19:52 ` [PATCH 17/37] drm/i915: Set fb->dev early on for inherited fbs ville.syrjala
@ 2016-11-30 15:36   ` Daniel Vetter
  0 siblings, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 15:36 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, Laurent Pinchart, dri-devel

On Fri, Nov 18, 2016 at 09:52:53PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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.
> 
> Cc: intel-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

I guess eventually we'll grow a WARN_ON(!fb->dev) in
drm_framebuffer_init() to make sure these don't escape? Anyway:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 12af936a402d..74a638c8de61 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -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;
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 20/37] drm/vmwgfx: Populate fb->format correctly
  2016-11-18 19:52 ` [PATCH 20/37] drm/vmwgfx: Populate fb->format correctly ville.syrjala
@ 2016-11-30 15:40   ` Daniel Vetter
  2016-11-30 16:03     ` Ville Syrjälä
  2016-11-30 15:52   ` Daniel Vetter
  1 sibling, 1 reply; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 15:40 UTC (permalink / raw)
  To: ville.syrjala
  Cc: Thomas Hellstrom, linux-graphics-maintainer, Laurent Pinchart, dri-devel

On Fri, Nov 18, 2016 at 09:52:56PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Populate the fb->format to point at the correct format information
> structure.
> 
> Cc: linux-graphics-maintainer@vmware.com
> Cc: Sinclair Yeh <syeh@vmware.com>
> Cc: Thomas Hellstrom <thellstrom@vmware.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index 5788913ca8f9..77f936e3056e 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -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);

Why not use drm_mode_fill_fb_struct here? This just seems to be bad
copypasta in both cases ...
-Daniel

>  	vfbd->base.base.pixel_format = pixel_format;
>  	vfbd->base.base.bits_per_pixel = mode_cmd->bpp;
>  	vfbd->base.base.pitches[0] = mode_cmd->pitch;
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 21/37] drm/i915: Populate fb->format early for inherited fbs
  2016-11-18 19:52 ` [PATCH 21/37] drm/i915: Populate fb->format early for inherited fbs ville.syrjala
@ 2016-11-30 15:42   ` Daniel Vetter
  2016-11-30 15:57     ` Ville Syrjälä
  2016-11-30 16:09     ` Daniel Vetter
  0 siblings, 2 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 15:42 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, Laurent Pinchart, dri-devel

On Fri, Nov 18, 2016 at 09:52:57PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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.
> 
> Cc: intel-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 74a638c8de61..c45da6766fff 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -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);

Do we really want to hand-roll this all, or could we somehow reuse
fill_fb_struct? Or will this all go away again?

I'll reserve judgement until the end, but this here looks correct ;-)

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

>  
>  	base = I915_READ(DSPSURF(pipe)) & 0xfffff000;
>  	if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Intel-gfx] [PATCH 24/37] drm/i915: Eliminate the ugly 'fb?:' constructs from the ilk/skl wm code
  2016-11-18 19:53 ` [PATCH 24/37] drm/i915: Eliminate the ugly 'fb?:' constructs from the ilk/skl wm code ville.syrjala
@ 2016-11-30 15:51   ` Daniel Vetter
  2016-11-30 15:59     ` Ville Syrjälä
  0 siblings, 1 reply; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 15:51 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, Laurent Pinchart, dri-devel

On Fri, Nov 18, 2016 at 09:53:00PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Don't access plane_state->fb until we know the plane to be visible.
> It it's visible, it will have an fb, and thus we don't have to
> consider the NULL fb case. Makes the code look nicer.
> 
> Cc: intel-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_pm.c | 23 +++++++++++++++--------
>  1 file changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index bbb1eaf1e6db..8ba7413872dd 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -1781,13 +1781,14 @@ static uint32_t ilk_compute_pri_wm(const struct intel_crtc_state *cstate,
>  				   uint32_t mem_value,
>  				   bool is_lp)
>  {
> -	int cpp = pstate->base.fb ?
> -		drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0;
>  	uint32_t method1, method2;
> +	int cpp;
>  
>  	if (!cstate->base.active || !pstate->base.visible)
>  		return 0;

Why do we still look for crtc_state->active here? Sounds like a bug in
proper validating our wm needs. Anway, change itself looks good.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

>  
> +	cpp = drm_format_plane_cpp(pstate->base.fb->pixel_format, 0);
> +
>  	method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value);
>  
>  	if (!is_lp)
> @@ -1809,13 +1810,14 @@ static uint32_t ilk_compute_spr_wm(const struct intel_crtc_state *cstate,
>  				   const struct intel_plane_state *pstate,
>  				   uint32_t mem_value)
>  {
> -	int cpp = pstate->base.fb ?
> -		drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0;
>  	uint32_t method1, method2;
> +	int cpp;
>  
>  	if (!cstate->base.active || !pstate->base.visible)
>  		return 0;
>  
> +	cpp = drm_format_plane_cpp(pstate->base.fb->pixel_format, 0);
> +
>  	method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value);
>  	method2 = ilk_wm_method2(ilk_pipe_pixel_rate(cstate),
>  				 cstate->base.adjusted_mode.crtc_htotal,
> @@ -1853,12 +1855,13 @@ static uint32_t ilk_compute_fbc_wm(const struct intel_crtc_state *cstate,
>  				   const struct intel_plane_state *pstate,
>  				   uint32_t pri_val)
>  {
> -	int cpp = pstate->base.fb ?
> -		drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0;
> +	int cpp;
>  
>  	if (!cstate->base.active || !pstate->base.visible)
>  		return 0;
>  
> +	cpp = drm_format_plane_cpp(pstate->base.fb->pixel_format, 0);
> +
>  	return ilk_wm_fbc(pri_val, drm_rect_width(&pstate->base.dst), cpp);
>  }
>  
> @@ -3229,13 +3232,17 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
>  			     int y)
>  {
>  	struct intel_plane_state *intel_pstate = to_intel_plane_state(pstate);
> -	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;
> +	struct drm_framebuffer *fb;
> +	u32 format;
>  
>  	if (!intel_pstate->base.visible)
>  		return 0;
> +
> +	fb = pstate->fb;
> +	format = fb->pixel_format;
> +
>  	if (pstate->plane->type == DRM_PLANE_TYPE_CURSOR)
>  		return 0;
>  	if (y && format != DRM_FORMAT_NV12)
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 20/37] drm/vmwgfx: Populate fb->format correctly
  2016-11-18 19:52 ` [PATCH 20/37] drm/vmwgfx: Populate fb->format correctly ville.syrjala
  2016-11-30 15:40   ` Daniel Vetter
@ 2016-11-30 15:52   ` Daniel Vetter
  1 sibling, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 15:52 UTC (permalink / raw)
  To: ville.syrjala
  Cc: Thomas Hellstrom, linux-graphics-maintainer, Laurent Pinchart, dri-devel

On Fri, Nov 18, 2016 at 09:52:56PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Populate the fb->format to point at the correct format information
> structure.
> 
> Cc: linux-graphics-maintainer@vmware.com
> Cc: Sinclair Yeh <syeh@vmware.com>
> Cc: Thomas Hellstrom <thellstrom@vmware.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index 5788913ca8f9..77f936e3056e 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -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;

If you change the earlier patch to just use fill_fb_struct this one here
isn't needed.
-Daniel

> @@ -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;
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 21/37] drm/i915: Populate fb->format early for inherited fbs
  2016-11-30 15:42   ` Daniel Vetter
@ 2016-11-30 15:57     ` Ville Syrjälä
  2016-11-30 16:09     ` Daniel Vetter
  1 sibling, 0 replies; 99+ messages in thread
From: Ville Syrjälä @ 2016-11-30 15:57 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: intel-gfx, Laurent Pinchart, dri-devel

On Wed, Nov 30, 2016 at 04:42:23PM +0100, Daniel Vetter wrote:
> On Fri, Nov 18, 2016 at 09:52:57PM +0200, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > 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.
> > 
> > Cc: intel-gfx@lists.freedesktop.org
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/i915/intel_display.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> > index 74a638c8de61..c45da6766fff 100644
> > --- a/drivers/gpu/drm/i915/intel_display.c
> > +++ b/drivers/gpu/drm/i915/intel_display.c
> > @@ -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);
> 
> Do we really want to hand-roll this all, or could we somehow reuse
> fill_fb_struct? Or will this all go away again?

Yeah, I think we'll want to flip all of this over to using
fill_fb_struct(). Just didn't have the energy to look into that yet,
and the series was already getting too long anyway. So figured I'd save
that for the next round.

> 
> I'll reserve judgement until the end, but this here looks correct ;-)
> 
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> >  
> >  	base = I915_READ(DSPSURF(pipe)) & 0xfffff000;
> >  	if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
> > -- 
> > 2.7.4
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Intel-gfx] [PATCH 24/37] drm/i915: Eliminate the ugly 'fb?:' constructs from the ilk/skl wm code
  2016-11-30 15:51   ` [Intel-gfx] " Daniel Vetter
@ 2016-11-30 15:59     ` Ville Syrjälä
  0 siblings, 0 replies; 99+ messages in thread
From: Ville Syrjälä @ 2016-11-30 15:59 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: intel-gfx, Laurent Pinchart, dri-devel

On Wed, Nov 30, 2016 at 04:51:33PM +0100, Daniel Vetter wrote:
> On Fri, Nov 18, 2016 at 09:53:00PM +0200, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Don't access plane_state->fb until we know the plane to be visible.
> > It it's visible, it will have an fb, and thus we don't have to
> > consider the NULL fb case. Makes the code look nicer.
> > 
> > Cc: intel-gfx@lists.freedesktop.org
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/i915/intel_pm.c | 23 +++++++++++++++--------
> >  1 file changed, 15 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> > index bbb1eaf1e6db..8ba7413872dd 100644
> > --- a/drivers/gpu/drm/i915/intel_pm.c
> > +++ b/drivers/gpu/drm/i915/intel_pm.c
> > @@ -1781,13 +1781,14 @@ static uint32_t ilk_compute_pri_wm(const struct intel_crtc_state *cstate,
> >  				   uint32_t mem_value,
> >  				   bool is_lp)
> >  {
> > -	int cpp = pstate->base.fb ?
> > -		drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0;
> >  	uint32_t method1, method2;
> > +	int cpp;
> >  
> >  	if (!cstate->base.active || !pstate->base.visible)
> >  		return 0;
> 
> Why do we still look for crtc_state->active here? Sounds like a bug in
> proper validating our wm needs.

Yeah, unfortunately that thing is still broken all over :( There are
broken assumptions about this higher up as well, so fixing this will
involve actual work I fear.

> Anway, change itself looks good.
> 
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> >  
> > +	cpp = drm_format_plane_cpp(pstate->base.fb->pixel_format, 0);
> > +
> >  	method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value);
> >  
> >  	if (!is_lp)
> > @@ -1809,13 +1810,14 @@ static uint32_t ilk_compute_spr_wm(const struct intel_crtc_state *cstate,
> >  				   const struct intel_plane_state *pstate,
> >  				   uint32_t mem_value)
> >  {
> > -	int cpp = pstate->base.fb ?
> > -		drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0;
> >  	uint32_t method1, method2;
> > +	int cpp;
> >  
> >  	if (!cstate->base.active || !pstate->base.visible)
> >  		return 0;
> >  
> > +	cpp = drm_format_plane_cpp(pstate->base.fb->pixel_format, 0);
> > +
> >  	method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value);
> >  	method2 = ilk_wm_method2(ilk_pipe_pixel_rate(cstate),
> >  				 cstate->base.adjusted_mode.crtc_htotal,
> > @@ -1853,12 +1855,13 @@ static uint32_t ilk_compute_fbc_wm(const struct intel_crtc_state *cstate,
> >  				   const struct intel_plane_state *pstate,
> >  				   uint32_t pri_val)
> >  {
> > -	int cpp = pstate->base.fb ?
> > -		drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0;
> > +	int cpp;
> >  
> >  	if (!cstate->base.active || !pstate->base.visible)
> >  		return 0;
> >  
> > +	cpp = drm_format_plane_cpp(pstate->base.fb->pixel_format, 0);
> > +
> >  	return ilk_wm_fbc(pri_val, drm_rect_width(&pstate->base.dst), cpp);
> >  }
> >  
> > @@ -3229,13 +3232,17 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
> >  			     int y)
> >  {
> >  	struct intel_plane_state *intel_pstate = to_intel_plane_state(pstate);
> > -	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;
> > +	struct drm_framebuffer *fb;
> > +	u32 format;
> >  
> >  	if (!intel_pstate->base.visible)
> >  		return 0;
> > +
> > +	fb = pstate->fb;
> > +	format = fb->pixel_format;
> > +
> >  	if (pstate->plane->type == DRM_PLANE_TYPE_CURSOR)
> >  		return 0;
> >  	if (y && format != DRM_FORMAT_NV12)
> > -- 
> > 2.7.4
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 27/37] drm/nouveau: Use fb->format rather than drm_format_info()
  2016-11-18 19:53 ` [PATCH 27/37] drm/nouveau: Use fb->format rather than drm_format_info() ville.syrjala
@ 2016-11-30 15:59   ` Daniel Vetter
  0 siblings, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 15:59 UTC (permalink / raw)
  To: ville.syrjala; +Cc: Laurent Pinchart, dri-devel, Ben Skeggs

On Fri, Nov 18, 2016 at 09:53:03PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Let's use the pointer to the format information cached under
> drm_framebuffer rather than look it up manually.
> 
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/nouveau/nv50_display.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
> index a9855a4ec532..d3bd428023ea 100644
> --- a/drivers/gpu/drm/nouveau/nv50_display.c
> +++ b/drivers/gpu/drm/nouveau/nv50_display.c
> @@ -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);

Could have done a smaller conversion with info = fb->format. Meh.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> -	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   :
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 31/37] drm: Nuke fb->depth
  2016-11-18 19:53 ` [PATCH 31/37] drm: Nuke fb->depth ville.syrjala
@ 2016-11-30 16:01   ` Daniel Vetter
  2016-12-14 21:31   ` [PATCH v2 " ville.syrjala
  1 sibling, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 16:01 UTC (permalink / raw)
  To: ville.syrjala; +Cc: Laurent Pinchart, dri-devel

On Fri, Nov 18, 2016 at 09:53:07PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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;

If you follow my suggestion for vmwgfx, then the above two spatch hunks
won't be needed. With that:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> 
> @@
> struct nouveau_framebuffer *fb;
> @@
> - fb->base.depth
> + fb->base.format->depth
> 
> @@
> struct drm_framebuffer fb;
> @@
> - fb.depth
> + fb.format->depth
> 
> @@
> struct drm_framebuffer *fb;
> @@
> - 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;
> 	 ...
>  };
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  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(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
> index f1c9e59a7c87..f24c91b699a9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
> @@ -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);
> diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c
> index c5dc06a55883..3a58fb600b05 100644
> --- a/drivers/gpu/drm/armada/armada_fbdev.c
> +++ b/drivers/gpu/drm/armada/armada_fbdev.c
> @@ -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",
> diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
> index d6f5ec64c667..f751792a3c7c 100644
> --- a/drivers/gpu/drm/ast/ast_fb.c
> +++ b/drivers/gpu/drm/ast/ast_fb.c
> @@ -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;
> diff --git a/drivers/gpu/drm/bochs/bochs_fbdev.c b/drivers/gpu/drm/bochs/bochs_fbdev.c
> index da790a1c302a..0317c3df6a22 100644
> --- a/drivers/gpu/drm/bochs/bochs_fbdev.c
> +++ b/drivers/gpu/drm/bochs/bochs_fbdev.c
> @@ -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);
>  
> diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
> index 3a6309d7d8e4..3cac8a03cf4f 100644
> --- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
> +++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
> @@ -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;
> diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
> index 0dc3f5bcbf48..181a9eafe34a 100644
> --- a/drivers/gpu/drm/drm_fb_cma_helper.c
> +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
> @@ -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;
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 14547817566d..755e3b6e9710 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -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;
> diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> index 22071d7e3420..556a92359c96 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -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) {
> diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
> index 1aa5e3bcc8a1..e5d19e5fc341 100644
> --- a/drivers/gpu/drm/drm_modeset_helper.c
> +++ b/drivers/gpu/drm/drm_modeset_helper.c
> @@ -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;
>  	}
>  
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> index 9f35deb56170..e68a46f112f6 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> @@ -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;
> diff --git a/drivers/gpu/drm/gma500/accel_2d.c b/drivers/gpu/drm/gma500/accel_2d.c
> index 0d2bb1682508..c51d9259c7a7 100644
> --- a/drivers/gpu/drm/gma500/accel_2d.c
> +++ b/drivers/gpu/drm/gma500/accel_2d.c
> @@ -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;
> diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
> index 6d89ed760941..a93b59ce6b41 100644
> --- a/drivers/gpu/drm/gma500/framebuffer.c
> +++ b/drivers/gpu/drm/gma500/framebuffer.c
> @@ -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;
> diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
> index 05b9a4ceb58d..5b852ad152ae 100644
> --- a/drivers/gpu/drm/gma500/gma_display.c
> +++ b/drivers/gpu/drm/gma500/gma_display.c
> @@ -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;
> diff --git a/drivers/gpu/drm/gma500/mdfld_intel_display.c b/drivers/gpu/drm/gma500/mdfld_intel_display.c
> index e80895285e94..3be3111825cd 100644
> --- a/drivers/gpu/drm/gma500/mdfld_intel_display.c
> +++ b/drivers/gpu/drm/gma500/mdfld_intel_display.c
> @@ -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;
> diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
> index a51896544d91..569810d47786 100644
> --- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
> +++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
> @@ -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;
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index b7f42c448a44..ebcba97616ab 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -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));
> diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
> index beb08982dc0b..b726483a460d 100644
> --- a/drivers/gpu/drm/i915/intel_fbdev.c
> +++ b/drivers/gpu/drm/i915/intel_fbdev.c
> @@ -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.
> diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c
> index 88dd2214114d..19a78b6b5a1a 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_fb.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
> @@ -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);
>  
> diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
> index bdac288ab16d..3180db5e81cb 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_mode.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
> @@ -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;
> diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
> index d29f5e82a410..3af969d8e8db 100644
> --- a/drivers/gpu/drm/msm/msm_fbdev.c
> +++ b/drivers/gpu/drm/msm/msm_fbdev.c
> @@ -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;
> diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
> index 8286b8ffe109..480e3ab477fd 100644
> --- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
> +++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
> @@ -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,
> diff --git a/drivers/gpu/drm/nouveau/dispnv04/dfp.c b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
> index 945607b3cd41..2e5bb2afda7c 100644
> --- a/drivers/gpu/drm/nouveau/dispnv04/dfp.c
> +++ b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
> @@ -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 {
> diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
> index 2f2a3dcd4ad7..5600f6c64497 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
> @@ -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) */
> diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c
> index 8d8ac173f55d..aed99a0fc44b 100644
> --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
> +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
> @@ -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;
> diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
> index 7e305d8a4146..e41b3322f433 100644
> --- a/drivers/gpu/drm/qxl/qxl_fb.c
> +++ b/drivers/gpu/drm/qxl/qxl_fb.c
> @@ -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:
> diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c
> index 899b6a1644bd..6c10a83f3362 100644
> --- a/drivers/gpu/drm/radeon/radeon_fb.c
> +++ b/drivers/gpu/drm/radeon/radeon_fb.c
> @@ -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);
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
> index 8f639c8597a5..52d1fdf9f9da 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
> @@ -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;
> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> index b8be3ee4d3b8..d2893f65341a 100644
> --- a/drivers/gpu/drm/tegra/drm.c
> +++ b/drivers/gpu/drm/tegra/drm.c
> @@ -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));
>  	}
> diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
> index 8a4aea211e94..8df7783cecc2 100644
> --- a/drivers/gpu/drm/tegra/fb.c
> +++ b/drivers/gpu/drm/tegra/fb.c
> @@ -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 +
> diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
> index fefd87f422ec..e21a3ed3ab2b 100644
> --- a/drivers/gpu/drm/udl/udl_fb.c
> +++ b/drivers/gpu/drm/udl/udl_fb.c
> @@ -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",
> diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c b/drivers/gpu/drm/virtio/virtgpu_fb.c
> index dd21f950e129..9d0da42cc420 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_fb.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_fb.c
> @@ -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);
>  
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
> index d2d93959b119..b6e4add09f44 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
> @@ -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;
>  
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index 77f936e3056e..2ce4743701f1 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -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;
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
> index 23ec673d5e16..a3a839a3d441 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
> @@ -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. */
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
> index f42359084adc..38d7b8a2b78e 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
> @@ -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;
> diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
> index cdcfb86b3f74..9b9772998db6 100644
> --- a/include/drm/drm_framebuffer.h
> +++ b/include/drm/drm_framebuffer.h
> @@ -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
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 20/37] drm/vmwgfx: Populate fb->format correctly
  2016-11-30 15:40   ` Daniel Vetter
@ 2016-11-30 16:03     ` Ville Syrjälä
  2016-11-30 16:09       ` Laurent Pinchart
  0 siblings, 1 reply; 99+ messages in thread
From: Ville Syrjälä @ 2016-11-30 16:03 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Thomas Hellstrom, linux-graphics-maintainer, Laurent Pinchart, dri-devel

On Wed, Nov 30, 2016 at 04:40:27PM +0100, Daniel Vetter wrote:
> On Fri, Nov 18, 2016 at 09:52:56PM +0200, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Populate the fb->format to point at the correct format information
> > structure.
> > 
> > Cc: linux-graphics-maintainer@vmware.com
> > Cc: Sinclair Yeh <syeh@vmware.com>
> > Cc: Thomas Hellstrom <thellstrom@vmware.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > index 5788913ca8f9..77f936e3056e 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > @@ -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);
> 
> Why not use drm_mode_fill_fb_struct here? This just seems to be bad
> copypasta in both cases ...

That it is. I was hoping I'd trick the vmware folks into fixing it by
posting this series. One issue is that this code still used the old
mode_cmd struct rather than the new mode_cmd2 struct. So the fix may
not be entirely trivial, and hence I was hoping people who care
about the driver would do it.

> -Daniel
> 
> >  	vfbd->base.base.pixel_format = pixel_format;
> >  	vfbd->base.base.bits_per_pixel = mode_cmd->bpp;
> >  	vfbd->base.base.pitches[0] = mode_cmd->pitch;
> > -- 
> > 2.7.4
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 30/37] drm/i915: Use drm_framebuffer_plane_{width, height}() where possible
  2016-11-18 19:53 ` [PATCH 30/37] drm/i915: Use drm_framebuffer_plane_{width, height}() where possible ville.syrjala
@ 2016-11-30 16:04   ` Daniel Vetter
  2016-11-30 16:06   ` [Intel-gfx] " Daniel Vetter
  1 sibling, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 16:04 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, Laurent Pinchart, dri-devel

On Fri, Nov 18, 2016 at 09:53:06PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Replace drm_format_plane_{width,height}() usage with
> drm_framebuffer_plane_{width,height}() to avoid the lookup of the format
> info.
> 
> Cc: intel-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/i915/intel_display.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 8f63fd38deee..5d8db436c557 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -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);
>  
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Intel-gfx] [PATCH 30/37] drm/i915: Use drm_framebuffer_plane_{width, height}() where possible
  2016-11-18 19:53 ` [PATCH 30/37] drm/i915: Use drm_framebuffer_plane_{width, height}() where possible ville.syrjala
  2016-11-30 16:04   ` Daniel Vetter
@ 2016-11-30 16:06   ` Daniel Vetter
  1 sibling, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 16:06 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, Laurent Pinchart, dri-devel

On Fri, Nov 18, 2016 at 09:53:06PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Replace drm_format_plane_{width,height}() usage with
> drm_framebuffer_plane_{width,height}() to avoid the lookup of the format
> info.
> 
> Cc: intel-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 8f63fd38deee..5d8db436c557 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -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);

Grep seems to say that we can nuke these two after this patch? I didn't
find that patch in your series ...
-Daniel

> +		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);
>  
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Intel-gfx] [PATCH 28/37] drm/i915: Store a pointer to the pixel format info for fbc
  2016-11-18 19:53 ` [PATCH 28/37] drm/i915: Store a pointer to the pixel format info for fbc ville.syrjala
@ 2016-11-30 16:07   ` Daniel Vetter
  0 siblings, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 16:07 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, Laurent Pinchart, dri-devel, Paulo Zanoni

On Fri, Nov 18, 2016 at 09:53:04PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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.
> 
> Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
> Cc: intel-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Assuming it all compiles still:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/i915/i915_drv.h  |  4 ++--
>  drivers/gpu/drm/i915/intel_fbc.c | 14 +++++++-------
>  2 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index be67aeece749..692b79e056be 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -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;
> diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
> index 62f215b12eb5..659cebc3bfd2 100644
> --- a/drivers/gpu/drm/i915/intel_fbc.c
> +++ b/drivers/gpu/drm/i915/intel_fbc.c
> @@ -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;
>  
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 20/37] drm/vmwgfx: Populate fb->format correctly
  2016-11-30 16:03     ` Ville Syrjälä
@ 2016-11-30 16:09       ` Laurent Pinchart
  2016-11-30 17:22         ` Daniel Vetter
  0 siblings, 1 reply; 99+ messages in thread
From: Laurent Pinchart @ 2016-11-30 16:09 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Thomas Hellstrom, linux-graphics-maintainer, dri-devel

Hello,

(Thomas, there's a question for you below)

On Wednesday 30 Nov 2016 18:03:30 Ville Syrjälä wrote:
> On Wed, Nov 30, 2016 at 04:40:27PM +0100, Daniel Vetter wrote:
> > On Fri, Nov 18, 2016 at 09:52:56PM +0200, ville.syrjala@linux.intel.com 
wrote:
> >> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >> 
> >> Populate the fb->format to point at the correct format information
> >> structure.
> >> 
> >> Cc: linux-graphics-maintainer@vmware.com
> >> Cc: Sinclair Yeh <syeh@vmware.com>
> >> Cc: Thomas Hellstrom <thellstrom@vmware.com>
> >> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >> ---
> >> 
> >>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 ++
> >>  1 file changed, 2 insertions(+)
> >> 
> >> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> >> b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 5788913ca8f9..77f936e3056e
> >> 100644
> >> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> >> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> >> @@ -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);
> > 
> > Why not use drm_mode_fill_fb_struct here? This just seems to be bad
> > copypasta in both cases ...
> 
> That it is. I was hoping I'd trick the vmware folks into fixing it by
> posting this series. One issue is that this code still used the old
> mode_cmd struct rather than the new mode_cmd2 struct. So the fix may
> not be entirely trivial, and hence I was hoping people who care
> about the driver would do it.

I gave it a try and it required touching too much code for my limited (or 
rather non-existing) knowledge of the driver. Pretty please to the vmwgfx 
maintainers, could you fix this ? vmwgfx is the last driver still relying on 
the old mode_cmd structure.

> >>  	vfbd->base.base.pixel_format = pixel_format;
> >>  	vfbd->base.base.bits_per_pixel = mode_cmd->bpp;
> >>  	vfbd->base.base.pitches[0] = mode_cmd->pitch;

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 21/37] drm/i915: Populate fb->format early for inherited fbs
  2016-11-30 15:42   ` Daniel Vetter
  2016-11-30 15:57     ` Ville Syrjälä
@ 2016-11-30 16:09     ` Daniel Vetter
  1 sibling, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 16:09 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, Laurent Pinchart, dri-devel

On Wed, Nov 30, 2016 at 04:42:23PM +0100, Daniel Vetter wrote:
> On Fri, Nov 18, 2016 at 09:52:57PM +0200, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > 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.
> > 
> > Cc: intel-gfx@lists.freedesktop.org
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/i915/intel_display.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> > index 74a638c8de61..c45da6766fff 100644
> > --- a/drivers/gpu/drm/i915/intel_display.c
> > +++ b/drivers/gpu/drm/i915/intel_display.c
> > @@ -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);
> 
> Do we really want to hand-roll this all, or could we somehow reuse
> fill_fb_struct? Or will this all go away again?

Looking at the end result I think doing the fill_fb_struct a pile earlier
would be nice. Or at least extract an set_fb_format helper or whatever to
set ->format and ->dev.

Needs a better name than set_fb_format though ;-)

Anyway, follow-up work.
-Daniel

> 
> I'll reserve judgement until the end, but this here looks correct ;-)
> 
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> >  
> >  	base = I915_READ(DSPSURF(pipe)) & 0xfffff000;
> >  	if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
> > -- 
> > 2.7.4
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH 20/37] drm/vmwgfx: Populate fb->format correctly
  2016-11-30 16:09       ` Laurent Pinchart
@ 2016-11-30 17:22         ` Daniel Vetter
  0 siblings, 0 replies; 99+ messages in thread
From: Daniel Vetter @ 2016-11-30 17:22 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: dri-devel, linux-graphics-maintainer, Thomas Hellstrom

On Wed, Nov 30, 2016 at 06:09:02PM +0200, Laurent Pinchart wrote:
> Hello,
> 
> (Thomas, there's a question for you below)
> 
> On Wednesday 30 Nov 2016 18:03:30 Ville Syrjälä wrote:
> > On Wed, Nov 30, 2016 at 04:40:27PM +0100, Daniel Vetter wrote:
> > > On Fri, Nov 18, 2016 at 09:52:56PM +0200, ville.syrjala@linux.intel.com 
> wrote:
> > >> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >> 
> > >> Populate the fb->format to point at the correct format information
> > >> structure.
> > >> 
> > >> Cc: linux-graphics-maintainer@vmware.com
> > >> Cc: Sinclair Yeh <syeh@vmware.com>
> > >> Cc: Thomas Hellstrom <thellstrom@vmware.com>
> > >> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >> ---
> > >> 
> > >>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 ++
> > >>  1 file changed, 2 insertions(+)
> > >> 
> > >> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > >> b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 5788913ca8f9..77f936e3056e
> > >> 100644
> > >> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > >> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > >> @@ -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);
> > > 
> > > Why not use drm_mode_fill_fb_struct here? This just seems to be bad
> > > copypasta in both cases ...
> > 
> > That it is. I was hoping I'd trick the vmware folks into fixing it by
> > posting this series. One issue is that this code still used the old
> > mode_cmd struct rather than the new mode_cmd2 struct. So the fix may
> > not be entirely trivial, and hence I was hoping people who care
> > about the driver would do it.
> 
> I gave it a try and it required touching too much code for my limited (or 
> rather non-existing) knowledge of the driver. Pretty please to the vmwgfx 
> maintainers, could you fix this ? vmwgfx is the last driver still relying on 
> the old mode_cmd structure.

Well you all managed to trick me into typing it, and it didn't seem too
bad. Pretty much just mechanically switching everything from mode_cmd to
mode_cmd2. Maybe I've touched too many drm drivers for big refactorings
and I have too low standards for what's involved ;-)

Patch submitted, review very much appreciated. And I'll try to ping
Sinclair on irc once he shows up for testing.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 99+ messages in thread

* [PATCH v2 13/37] drm: Pass 'dev' to drm_helper_mode_fill_fb_struct()
  2016-11-18 19:52 ` [PATCH 13/37] drm: Pass 'dev' to drm_helper_mode_fill_fb_struct() ville.syrjala
@ 2016-12-14 20:48   ` ville.syrjala
  0 siblings, 0 replies; 99+ messages in thread
From: ville.syrjala @ 2016-12-14 20:48 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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);

v2: Rerun spatch due to code changes

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 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/hisilicon/hibmc/hibmc_ttm.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 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c         | 4 ++--
 include/drm/drm_modeset_helper.h            | 3 ++-
 24 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 581601ca6b89..d2036df145b3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -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;
diff --git a/drivers/gpu/drm/armada/armada_fb.c b/drivers/gpu/drm/armada/armada_fb.c
index f03c212b754d..2a7eb6817c36 100644
--- a/drivers/gpu/drm/armada/armada_fb.c
+++ b/drivers/gpu/drm/armada/armada_fb.c
@@ -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) {
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index 904beaa932d0..d85af0ff2653 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -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) {
diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c
index 099a3c688c26..ceb1fecf02dd 100644
--- a/drivers/gpu/drm/bochs/bochs_mm.c
+++ b/drivers/gpu/drm/bochs/bochs_mm.c
@@ -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) {
diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c b/drivers/gpu/drm/cirrus/cirrus_main.c
index 2c3c0d4072ce..52d901fa8687 100644
--- a/drivers/gpu/drm/cirrus/cirrus_main.c
+++ b/drivers/gpu/drm/cirrus/cirrus_main.c
@@ -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) {
diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
index 81b3558302b5..570f5c6063f3 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -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];
diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index cc232ac6c950..285ffcba0fe8 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -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;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c
index 23cce0a3f5fc..68d414227533 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fb.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c
@@ -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) {
diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index 4071b2d1e8cf..6d89ed760941 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -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) {
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
index e76abf61edae..3c6f750389fb 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
@@ -512,7 +512,7 @@ hibmc_framebuffer_init(struct drm_device *dev,
 		return ERR_PTR(-ENOMEM);
 	}
 
-	drm_helper_mode_fill_fb_struct(&hibmc_fb->fb, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &hibmc_fb->fb, mode_cmd);
 	hibmc_fb->obj = obj;
 	ret = drm_framebuffer_init(dev, &hibmc_fb->fb, &hibmc_fb_funcs);
 	if (ret) {
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index bc1af87789bc..dd1e75b1d79c 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -15963,7 +15963,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);
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
index 147df85399ab..d4246c9dceae 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
@@ -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;
 
diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c
index e79cbc25ae3c..95d628b9457e 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -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) {
diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c
index 9acf544e7a8f..ccefd6a30f37 100644
--- a/drivers/gpu/drm/msm/msm_fb.c
+++ b/drivers/gpu/drm/msm/msm_fb.c
@@ -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) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index cef08da1da4e..e0db5d38fb18 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -259,7 +259,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);
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index 5f3337f1e9aa..9875c99be009 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -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) {
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 4b5eab8a47b3..6cabb47c75b1 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -629,7 +629,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;
 }
 
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index e7409e8a9f87..6285355eb5d5 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -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;
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
index 0f6eda023bd0..d5e1f8627d38 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
@@ -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];
diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index e4a5ab0a9677..a0096493f51c 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -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];
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index 167f42c67c7c..fefd87f422ec 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
index 58048709c34e..8b80fdd0e0a8 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -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;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index e7daf59bac80..cf22110e9eee 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -583,7 +583,7 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
 		goto out_err1;
 	}
 
-	drm_helper_mode_fill_fb_struct(&vfbs->base.base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &vfbs->base.base, mode_cmd);
 	vfbs->surface = vmw_surface_reference(surface);
 	vfbs->base.user_handle = mode_cmd->handles[0];
 	vfbs->is_dmabuf_proxy = is_dmabuf_proxy;
@@ -864,7 +864,7 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
 		goto out_err1;
 	}
 
-	drm_helper_mode_fill_fb_struct(&vfbd->base.base, mode_cmd);
+	drm_helper_mode_fill_fb_struct(dev, &vfbd->base.base, mode_cmd);
 	vfbd->base.dmabuf = true;
 	vfbd->buffer = vmw_dmabuf_reference(dmabuf);
 	vfbd->base.user_handle = mode_cmd->handles[0];
diff --git a/include/drm/drm_modeset_helper.h b/include/drm/drm_modeset_helper.h
index b8051d5abe10..cb0ec92e11e6 100644
--- a/include/drm/drm_modeset_helper.h
+++ b/include/drm/drm_modeset_helper.h
@@ -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,
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH v2 23/37] drm: Replace drm_format_num_planes() with fb->format->num_planes
  2016-11-18 19:52 ` [PATCH 23/37] drm: Replace drm_format_num_planes() with fb->format->num_planes ville.syrjala
  2016-11-19  2:41   ` Laurent Pinchart
@ 2016-12-14 21:30   ` ville.syrjala
  1 sibling, 0 replies; 99+ messages in thread
From: ville.syrjala @ 2016-12-14 21:30 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Replace drm_format_num_planes(fb->pixel_format) with just
fb->format->num_planes. Avoids the expensive format info lookup.

@@
struct drm_framebuffer *a;
struct drm_framebuffer b;
@@
(
- drm_format_num_planes(a->pixel_format)
+ a->format->num_planes
|
- drm_format_num_planes(b.pixel_format)
+ b.format->num_planes
)

@@
struct drm_plane_state *a;
struct drm_plane_state b;
@@
(
- drm_format_num_planes(a->fb->pixel_format)
+ a->fb->format->num_planes
|
- drm_format_num_planes(b.fb->pixel_format)
+ b.fb->format->num_planes
)

@@
struct drm_framebuffer *a;
identifier T;
@@
  T = a->pixel_format
<+...
- drm_format_num_planes(T)
+ a->format->num_planes
...+>

@@
struct drm_framebuffer b;
identifier T;
@@
  T = b.pixel_format
<+...
- drm_format_num_planes(T)
+ b.format->num_planes
...+>

v2: Rerun spatch due to code changes

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/arm/malidp_planes.c             | 2 +-
 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 | 2 +-
 drivers/gpu/drm/drm_atomic.c                    | 2 +-
 drivers/gpu/drm/i915/intel_display.c            | 2 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c       | 2 +-
 drivers/gpu/drm/msm/msm_fb.c                    | 8 ++++----
 drivers/gpu/drm/omapdrm/omap_fb.c               | 8 ++++----
 drivers/gpu/drm/tegra/dc.c                      | 4 ++--
 drivers/gpu/drm/tegra/fb.c                      | 2 +-
 drivers/gpu/drm/vc4/vc4_plane.c                 | 2 +-
 13 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
index ee7f7663a307..533ee2fa64be 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -116,7 +116,7 @@ static int malidp_de_plane_check(struct drm_plane *plane,
 	if (ms->format == MALIDP_INVALID_FORMAT_ID)
 		return -EINVAL;
 
-	ms->n_planes = drm_format_num_planes(fb->pixel_format);
+	ms->n_planes = fb->format->num_planes;
 	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",
diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index 95cb3966b2ca..2e1c63569c72 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -170,7 +170,7 @@ void armada_drm_plane_calc_addrs(u32 *addrs, struct drm_framebuffer *fb,
 {
 	u32 addr = drm_fb_obj(fb)->dev_addr;
 	u32 pixel_format = fb->pixel_format;
-	int num_planes = drm_format_num_planes(pixel_format);
+	int num_planes = fb->format->num_planes;
 	int i;
 
 	if (num_planes > 3)
diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
index 6743615232f5..a0883a1b3387 100644
--- a/drivers/gpu/drm/armada/armada_overlay.c
+++ b/drivers/gpu/drm/armada/armada_overlay.c
@@ -188,7 +188,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 
 		pixel_format = fb->pixel_format;
 		hsub = drm_format_horz_chroma_subsampling(pixel_format);
-		num_planes = drm_format_num_planes(pixel_format);
+		num_planes = fb->format->num_planes;
 
 		/*
 		 * Annoyingly, shifting a YUYV-format image by one pixel
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c
index 377e43cea9dd..63dfdbf34f80 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c
@@ -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 = fb->format->num_planes;
 
 	if (nplanes > layer->max_planes)
 		return;
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index 246ed1e33d8a..f97ae75f9e63 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -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 = fb->format->num_planes;
 	if (state->nplanes > ATMEL_HLCDC_MAX_PLANES)
 		return -EINVAL;
 
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 60697482b94c..62f0f57728e1 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -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",
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 822539bf9074..41f9b3d5ce85 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2498,7 +2498,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++) {
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index c099da7bc212..75247ea4335b 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -699,7 +699,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 = fb->format->num_planes;
 
 	/* bad formats should already be rejected: */
 	if (WARN_ON(nplanes > pipe2nclients(pipe)))
diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c
index ccefd6a30f37..0649863d7fd7 100644
--- a/drivers/gpu/drm/msm/msm_fb.c
+++ b/drivers/gpu/drm/msm/msm_fb.c
@@ -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 = fb->format->num_planes;
 
 	DBG("destroy: FB ID: %d (%p)", fb->base.id, fb);
 
@@ -65,7 +65,7 @@ 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 = fb->format->num_planes;
 
 	seq_printf(m, "fb: %dx%d@%4.4s (%2d, ID:%d)\n",
 			fb->width, fb->height, (char *)&fb->pixel_format,
@@ -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 = fb->format->num_planes;
 	uint64_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 = fb->format->num_planes;
 
 	for (i = 0; i < n; i++)
 		msm_gem_put_iova(msm_fb->planes[i], id);
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index 9875c99be009..c6ef457b9fca 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -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 = fb->format->num_planes;
 
 	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 = fb->format->num_planes;
 
 	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 = fb->format->num_planes;
 
 	mutex_lock(&omap_fb->lock);
 
@@ -343,7 +343,7 @@ 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 = fb->format->num_planes;
 
 	seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height,
 			(char *)&fb->pixel_format);
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 4010d69cbd08..b60c306190e9 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -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 (state->fb->format->num_planes > 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 < fb->format->num_planes; i++) {
 		struct tegra_bo *bo = tegra_fb_get_plane(fb, i);
 
 		window.base[i] = bo->paddr + fb->offsets[i];
diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index a0096493f51c..8a4aea211e94 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -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 >= framebuffer->format->num_planes)
 		return NULL;
 
 	return fb->planes[index];
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
index 881bf489478b..a7fb581c7c55 100644
--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -296,7 +296,7 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
 	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;
-	int num_planes = drm_format_num_planes(format);
+	int num_planes = fb->format->num_planes;
 	u32 h_subsample = 1;
 	u32 v_subsample = 1;
 	int i;
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH v2 25/37] drm: Replace drm_format_plane_cpp() with fb->format->cpp[]
  2016-11-18 19:53 ` [PATCH 25/37] drm: Replace drm_format_plane_cpp() with fb->format->cpp[] ville.syrjala
  2016-11-19  2:44   ` Laurent Pinchart
@ 2016-12-14 21:30   ` ville.syrjala
  1 sibling, 0 replies; 99+ messages in thread
From: ville.syrjala @ 2016-12-14 21:30 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Replace drm_format_plane_cpp(fb->pixel_format) with just
fb->format->cpp[]. Avoids the expensive format info lookup.

@@
struct drm_framebuffer *a;
struct drm_framebuffer b;
expression E;
@@
(
- drm_format_plane_cpp(a->pixel_format, E)
+ a->format->cpp[E]
|
- drm_format_plane_cpp(b.pixel_format, E)
+ b.format->cpp[E]
)

@@
struct drm_plane_state *a;
struct drm_plane_state b;
expression E;
@@
(
- drm_format_plane_cpp(a->fb->pixel_format, E)
+ a->fb->format->cpp[E]
|
- drm_format_plane_cpp(b.fb->pixel_format, E)
+ b.fb->format->cpp[E]
)

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

@@
struct drm_framebuffer b;
identifier T;
expression E;
@@
  T = b.pixel_format
<+...
- drm_format_plane_cpp(T, E)
+ b.format->cpp[E]
...+>

v2: Rerun spatch due to code changes

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/arm/hdlcd_crtc.c                |  2 +-
 drivers/gpu/drm/armada/armada_crtc.c            |  3 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c |  2 +-
 drivers/gpu/drm/i915/intel_display.c            | 16 +++++-----
 drivers/gpu/drm/i915/intel_pm.c                 | 42 ++++++++++++-------------
 drivers/gpu/drm/i915/intel_sprite.c             |  2 +-
 drivers/gpu/drm/imx/ipuv3-plane.c               |  6 ++--
 drivers/gpu/drm/mediatek/mtk_drm_plane.c        |  2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c     |  4 +--
 drivers/gpu/drm/sti/sti_gdp.c                   |  2 +-
 drivers/gpu/drm/sun4i/sun4i_backend.c           |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c            |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_plane.c           |  2 +-
 drivers/gpu/drm/vc4/vc4_plane.c                 |  2 +-
 drivers/gpu/drm/zte/zx_plane.c                  |  2 +-
 15 files changed, 45 insertions(+), 46 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
index 35705a4173f3..ecdcd99c92cc 100644
--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
@@ -238,7 +238,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);
+		fb->format->cpp[0];
 
 	hdlcd = plane->dev->dev_private;
 	hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_LENGTH, fb->pitches[0]);
diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index 2e1c63569c72..99283f30edc5 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -169,7 +169,6 @@ void armada_drm_plane_calc_addrs(u32 *addrs, struct drm_framebuffer *fb,
 	int x, int y)
 {
 	u32 addr = drm_fb_obj(fb)->dev_addr;
-	u32 pixel_format = fb->pixel_format;
 	int num_planes = fb->format->num_planes;
 	int i;
 
@@ -178,7 +177,7 @@ void armada_drm_plane_calc_addrs(u32 *addrs, struct drm_framebuffer *fb,
 
 	for (i = 0; i < num_planes; i++)
 		addrs[i] = addr + fb->offsets[i] + y * fb->pitches[i] +
-			     x * drm_format_plane_cpp(pixel_format, i);
+			     x * fb->format->cpp[i];
 	for (; i < 3; i++)
 		addrs[i] = 0;
 }
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index f97ae75f9e63..3e00512ef187 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -672,7 +672,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
 		int xdiv = i ? hsub : 1;
 		int ydiv = i ? vsub : 1;
 
-		state->bpp[i] = drm_format_plane_cpp(fb->pixel_format, i);
+		state->bpp[i] = fb->format->cpp[i];
 		if (!state->bpp[i])
 			return -EINVAL;
 
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 41f9b3d5ce85..1f9e5adc0d69 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2276,7 +2276,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;
@@ -2345,7 +2345,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);
 
@@ -2401,7 +2401,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)
@@ -2469,7 +2469,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];
 
@@ -2507,7 +2507,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);
 
@@ -2834,7 +2834,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:
@@ -2913,7 +2913,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) {
@@ -3279,7 +3279,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 {
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 6728fa51eafd..351476e85452 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -675,7 +675,7 @@ static void pineview_update_wm(struct intel_crtc *unused_crtc)
 			&crtc->config->base.adjusted_mode;
 		const struct drm_framebuffer *fb =
 			crtc->base.primary->state->fb;
-		int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+		int cpp = fb->format->cpp[0];
 		int clock = adjusted_mode->crtc_clock;
 
 		/* Display SR */
@@ -750,7 +750,7 @@ static bool g4x_compute_wm0(struct drm_i915_private *dev_priv,
 	clock = adjusted_mode->crtc_clock;
 	htotal = adjusted_mode->crtc_htotal;
 	hdisplay = crtc->config->pipe_src_w;
-	cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+	cpp = fb->format->cpp[0];
 
 	/* Use the small buffer method to calculate plane watermark */
 	entries = ((clock * cpp / 1000) * display_latency_ns) / 1000;
@@ -839,7 +839,7 @@ static bool g4x_compute_srwm(struct drm_i915_private *dev_priv,
 	clock = adjusted_mode->crtc_clock;
 	htotal = adjusted_mode->crtc_htotal;
 	hdisplay = crtc->config->pipe_src_w;
-	cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+	cpp = fb->format->cpp[0];
 
 	line_time_us = max(htotal * 1000 / clock, 1);
 	line_count = (latency_ns / line_time_us + 1000) / 1000;
@@ -994,7 +994,7 @@ static uint16_t vlv_compute_wm_level(const struct intel_crtc_state *crtc_state,
 	if (!plane_state->base.visible)
 		return 0;
 
-	cpp = drm_format_plane_cpp(plane_state->base.fb->pixel_format, 0);
+	cpp = plane_state->base.fb->format->cpp[0];
 	clock = adjusted_mode->crtc_clock;
 	htotal = adjusted_mode->crtc_htotal;
 	width = crtc_state->pipe_src_w;
@@ -1035,7 +1035,7 @@ static void vlv_compute_fifo(struct intel_crtc *crtc)
 
 		if (state->base.visible) {
 			wm_state->num_active_planes++;
-			total_rate += drm_format_plane_cpp(state->base.fb->pixel_format, 0);
+			total_rate += state->base.fb->format->cpp[0];
 		}
 	}
 
@@ -1054,7 +1054,7 @@ static void vlv_compute_fifo(struct intel_crtc *crtc)
 			continue;
 		}
 
-		rate = drm_format_plane_cpp(state->base.fb->pixel_format, 0);
+		rate = state->base.fb->format->cpp[0];
 		plane->wm.fifo_size = fifo_size * rate / total_rate;
 		fifo_left -= plane->wm.fifo_size;
 	}
@@ -1473,7 +1473,7 @@ static void i965_update_wm(struct intel_crtc *unused_crtc)
 		int clock = adjusted_mode->crtc_clock;
 		int htotal = adjusted_mode->crtc_htotal;
 		int hdisplay = crtc->config->pipe_src_w;
-		int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+		int cpp = fb->format->cpp[0];
 		unsigned long line_time_us;
 		int entries;
 
@@ -1559,7 +1559,7 @@ static void i9xx_update_wm(struct intel_crtc *unused_crtc)
 		if (IS_GEN2(dev_priv))
 			cpp = 4;
 		else
-			cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+			cpp = fb->format->cpp[0];
 
 		planea_wm = intel_calculate_wm(adjusted_mode->crtc_clock,
 					       wm_info, fifo_size, cpp,
@@ -1586,7 +1586,7 @@ static void i9xx_update_wm(struct intel_crtc *unused_crtc)
 		if (IS_GEN2(dev_priv))
 			cpp = 4;
 		else
-			cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+			cpp = fb->format->cpp[0];
 
 		planeb_wm = intel_calculate_wm(adjusted_mode->crtc_clock,
 					       wm_info, fifo_size, cpp,
@@ -1639,7 +1639,7 @@ static void i9xx_update_wm(struct intel_crtc *unused_crtc)
 		if (IS_I915GM(dev_priv) || IS_I945GM(dev_priv))
 			cpp = 4;
 		else
-			cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+			cpp = fb->format->cpp[0];
 
 		line_time_us = max(htotal * 1000 / clock, 1);
 
@@ -1805,7 +1805,7 @@ static uint32_t ilk_compute_pri_wm(const struct intel_crtc_state *cstate,
 	if (!cstate->base.active || !pstate->base.visible)
 		return 0;
 
-	cpp = drm_format_plane_cpp(pstate->base.fb->pixel_format, 0);
+	cpp = pstate->base.fb->format->cpp[0];
 
 	method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value);
 
@@ -1834,7 +1834,7 @@ static uint32_t ilk_compute_spr_wm(const struct intel_crtc_state *cstate,
 	if (!cstate->base.active || !pstate->base.visible)
 		return 0;
 
-	cpp = drm_format_plane_cpp(pstate->base.fb->pixel_format, 0);
+	cpp = pstate->base.fb->format->cpp[0];
 
 	method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value);
 	method2 = ilk_wm_method2(ilk_pipe_pixel_rate(cstate),
@@ -1878,7 +1878,7 @@ static uint32_t ilk_compute_fbc_wm(const struct intel_crtc_state *cstate,
 	if (!cstate->base.active || !pstate->base.visible)
 		return 0;
 
-	cpp = drm_format_plane_cpp(pstate->base.fb->pixel_format, 0);
+	cpp = pstate->base.fb->format->cpp[0];
 
 	return ilk_wm_fbc(pri_val, drm_rect_width(&pstate->base.dst), cpp);
 }
@@ -3239,13 +3239,13 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
 	if (format == DRM_FORMAT_NV12) {
 		if (y)  /* y-plane data rate */
 			data_rate = width * height *
-				drm_format_plane_cpp(format, 0);
+				fb->format->cpp[0];
 		else    /* uv-plane data rate */
 			data_rate = (width / 2) * (height / 2) *
-				drm_format_plane_cpp(format, 1);
+				fb->format->cpp[1];
 	} else {
 		/* for packed formats */
-		data_rate = width * height * drm_format_plane_cpp(format, 0);
+		data_rate = width * height * fb->format->cpp[0];
 	}
 
 	down_scale_amount = skl_plane_downscale_amount(intel_pstate);
@@ -3330,9 +3330,9 @@ skl_ddb_min_alloc(const struct drm_plane_state *pstate,
 	}
 
 	if (fb->pixel_format == DRM_FORMAT_NV12 && !y)
-		plane_bpp = drm_format_plane_cpp(fb->pixel_format, 1);
+		plane_bpp = fb->format->cpp[1];
 	else
-		plane_bpp = drm_format_plane_cpp(fb->pixel_format, 0);
+		plane_bpp = fb->format->cpp[0];
 
 	if (drm_rotation_90_or_270(pstate->rotation)) {
 		switch (plane_bpp) {
@@ -3606,13 +3606,13 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 	if (drm_rotation_90_or_270(pstate->rotation))
 		swap(width, height);
 
-	cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+	cpp = fb->format->cpp[0];
 	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) ?
-			drm_format_plane_cpp(fb->pixel_format, 1) :
-			drm_format_plane_cpp(fb->pixel_format, 0);
+			fb->format->cpp[1] :
+			fb->format->cpp[0];
 
 		switch (cpp) {
 		case 1:
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 63154a5a9305..c2448471fd93 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -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);
 
diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c
index e74a0ad52950..f44a83656310 100644
--- a/drivers/gpu/drm/imx/ipuv3-plane.c
+++ b/drivers/gpu/drm/imx/ipuv3-plane.c
@@ -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;
+	       fb->format->cpp[0] * x;
 }
 
 static inline unsigned long
@@ -96,7 +96,7 @@ drm_plane_state_to_ubo(struct drm_plane_state *state)
 	y /= drm_format_vert_chroma_subsampling(fb->pixel_format);
 
 	return cma_obj->paddr + fb->offsets[1] + fb->pitches[1] * y +
-	       drm_format_plane_cpp(fb->pixel_format, 1) * x - eba;
+	       fb->format->cpp[1] * x - eba;
 }
 
 static inline unsigned long
@@ -115,7 +115,7 @@ drm_plane_state_to_vbo(struct drm_plane_state *state)
 	y /= drm_format_vert_chroma_subsampling(fb->pixel_format);
 
 	return cma_obj->paddr + fb->offsets[2] + fb->pitches[2] * y +
-	       drm_format_plane_cpp(fb->pixel_format, 2) * x - eba;
+	       fb->format->cpp[2] * x - eba;
 }
 
 void ipu_plane_put_resources(struct ipu_plane *ipu_plane)
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index c461a232cbf5..71421923c592 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -135,7 +135,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
 	pitch = fb->pitches[0];
 	format = fb->pixel_format;
 
-	addr += (plane->state->src.x1 >> 16) * drm_format_plane_cpp(format, 0);
+	addr += (plane->state->src.x1 >> 16) * fb->format->cpp[0];
 	addr += (plane->state->src.y1 >> 16) * pitch;
 
 	state->pending.enable = true;
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index c7eba305c488..50e085e74214 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -749,7 +749,7 @@ 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) * fb->format->cpp[0];
 	offset += (src->y1 >> 16) * fb->pitches[0];
 	dma_addr = rk_obj->dma_addr + offset + fb->offsets[0];
 
@@ -763,7 +763,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 	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);
+		int bpp = fb->format->cpp[1];
 
 		uv_obj = rockchip_fb_get_gem_obj(fb, 1);
 		rk_uv_obj = to_rockchip_obj(uv_obj);
diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
index 81df3097b545..58316bd6d7d6 100644
--- a/drivers/gpu/drm/sti/sti_gdp.c
+++ b/drivers/gpu/drm/sti/sti_gdp.c
@@ -757,7 +757,7 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
 			 (unsigned long)cma_obj->paddr);
 
 	/* pixel memory location */
-	bpp = drm_format_plane_cpp(fb->pixel_format, 0);
+	bpp = fb->format->cpp[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];
diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 2e08f969bb64..a606207d4e25 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -218,7 +218,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 = fb->format->cpp[0];
 	paddr = gem->paddr + fb->offsets[0];
 	paddr += (state->src_x >> 16) * bpp;
 	paddr += (state->src_y >> 16) * fb->pitches[0];
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 9942b0577d6e..0dc96e12fd06 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -91,7 +91,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 * fb->format->cpp[0];
 
 	end = start + (crtc->mode.vdisplay * fb->pitches[0]);
 
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
index 8a6a50d74aff..c0fc874e91cf 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
@@ -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);
+		state->fb->format->cpp[0];
 	if (state->fb->pitches[0] != pitch) {
 		dev_err(plane->dev->dev,
 			"Invalid pitch: fb and crtc widths must be the same");
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
index a7fb581c7c55..f84f6bddd015 100644
--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -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 = fb->format->cpp[i];
 			u32 subs = ((i == 0) ? 1 : h_subsample);
 
 			vc4_state->offsets[i] += (cpp *
diff --git a/drivers/gpu/drm/zte/zx_plane.c b/drivers/gpu/drm/zte/zx_plane.c
index 546eb92a94e8..72d27b0a48b2 100644
--- a/drivers/gpu/drm/zte/zx_plane.c
+++ b/drivers/gpu/drm/zte/zx_plane.c
@@ -159,7 +159,7 @@ static void zx_gl_plane_atomic_update(struct drm_plane *plane,
 	dst_w = plane->state->crtc_w;
 	dst_h = plane->state->crtc_h;
 
-	bpp = drm_format_plane_cpp(format, 0);
+	bpp = fb->format->cpp[0];
 
 	cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
 	paddr = cma_obj->paddr + fb->offsets[0];
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH v2 31/37] drm: Nuke fb->depth
  2016-11-18 19:53 ` [PATCH 31/37] drm: Nuke fb->depth ville.syrjala
  2016-11-30 16:01   ` Daniel Vetter
@ 2016-12-14 21:31   ` ville.syrjala
  1 sibling, 0 replies; 99+ messages in thread
From: ville.syrjala @ 2016-12-14 21:31 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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

@@
struct drm_framebuffer *fb;
expression E;
@@
 drm_helper_mode_fill_fb_struct(...) {
	...
-	fb->depth = E;
	...
 }

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

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

@@
struct drm_framebuffer *fb;
@@
- 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;
	 ...
 };

v2: Drop the vmw stuff (Daniel)
    Rerun spatch due to code changes

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 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/hisilicon/hibmc/hibmc_drm_fbdev.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                |  5 +++--
 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(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index 24629bec181a..838943d0962e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -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);
diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c
index c5dc06a55883..3a58fb600b05 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -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",
diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
index d6f5ec64c667..f751792a3c7c 100644
--- a/drivers/gpu/drm/ast/ast_fb.c
+++ b/drivers/gpu/drm/ast/ast_fb.c
@@ -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;
diff --git a/drivers/gpu/drm/bochs/bochs_fbdev.c b/drivers/gpu/drm/bochs/bochs_fbdev.c
index da790a1c302a..0317c3df6a22 100644
--- a/drivers/gpu/drm/bochs/bochs_fbdev.c
+++ b/drivers/gpu/drm/bochs/bochs_fbdev.c
@@ -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);
 
diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 3a6309d7d8e4..3cac8a03cf4f 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
index 0dc3f5bcbf48..181a9eafe34a 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index e934b541feea..96c78b33a999 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1653,7 +1653,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;
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 22071d7e3420..556a92359c96 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -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) {
diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index 1aa5e3bcc8a1..e5d19e5fc341 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index 9f35deb56170..e68a46f112f6 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/accel_2d.c b/drivers/gpu/drm/gma500/accel_2d.c
index 0d2bb1682508..c51d9259c7a7 100644
--- a/drivers/gpu/drm/gma500/accel_2d.c
+++ b/drivers/gpu/drm/gma500/accel_2d.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index 6d89ed760941..a93b59ce6b41 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
index 05b9a4ceb58d..5b852ad152ae 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/mdfld_intel_display.c b/drivers/gpu/drm/gma500/mdfld_intel_display.c
index e80895285e94..3be3111825cd 100644
--- a/drivers/gpu/drm/gma500/mdfld_intel_display.c
+++ b/drivers/gpu/drm/gma500/mdfld_intel_display.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
index a51896544d91..569810d47786 100644
--- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
+++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
@@ -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;
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c
index 9b0696735ba1..7a6957ae4b44 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c
@@ -135,7 +135,7 @@ static int hibmc_drm_fb_create(struct drm_fb_helper *helper,
 	info->fbops = &hibmc_drm_fb_ops;
 
 	drm_fb_helper_fill_fix(info, hi_fbdev->fb->fb.pitches[0],
-			       hi_fbdev->fb->fb.depth);
+			       hi_fbdev->fb->fb.format->depth);
 	drm_fb_helper_fill_var(info, &priv->fbdev->helper, sizes->fb_width,
 			       sizes->fb_height);
 
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 7fca6b9fd10c..a3d9cb5ad184 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -1869,7 +1869,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));
@@ -1887,7 +1887,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));
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index 2163aaad6a36..9c5e9cfa4ed7 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -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.
diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c
index 88dd2214114d..19a78b6b5a1a 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -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);
 
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
index 34dd38e8a651..9399099d3e39 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -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;
diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index bffe93498512..5d68ab362d75 100644
--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 8286b8ffe109..480e3ab477fd 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -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,
diff --git a/drivers/gpu/drm/nouveau/dispnv04/dfp.c b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
index 945607b3cd41..2e5bb2afda7c 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dfp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
@@ -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 {
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 2f2a3dcd4ad7..5600f6c64497 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -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) */
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c
index 8d8ac173f55d..aed99a0fc44b 100644
--- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
index fd7e5e94be5b..e6ade6aab54c 100644
--- a/drivers/gpu/drm/qxl/qxl_fb.c
+++ b/drivers/gpu/drm/qxl/qxl_fb.c
@@ -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:
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c
index 899b6a1644bd..6c10a83f3362 100644
--- a/drivers/gpu/drm/radeon/radeon_fb.c
+++ b/drivers/gpu/drm/radeon/radeon_fb.c
@@ -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);
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
index 8f639c8597a5..52d1fdf9f9da 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index b8be3ee4d3b8..d2893f65341a 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -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));
 	}
diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index 8a4aea211e94..8df7783cecc2 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -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 +
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index fefd87f422ec..e21a3ed3ab2b 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -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",
diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c b/drivers/gpu/drm/virtio/virtgpu_fb.c
index dd21f950e129..9d0da42cc420 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fb.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fb.c
@@ -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);
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
index 723fd763da8e..4a7a7d2997dd 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
@@ -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;
 	}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
index 23ec673d5e16..a3a839a3d441 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
@@ -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. */
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
index f42359084adc..38d7b8a2b78e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
@@ -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;
diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
index 79640c3e7ec4..0c14f0adf161 100644
--- a/include/drm/drm_framebuffer.h
+++ b/include/drm/drm_framebuffer.h
@@ -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
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH v3 32/37] drm: Nuke fb->bits_per_pixel
  2016-11-18 19:53 ` [PATCH v2 32/37] drm: Nuke fb->bits_per_pixel ville.syrjala
@ 2016-12-14 21:32   ` ville.syrjala
  0 siblings, 0 replies; 99+ messages in thread
From: ville.syrjala @ 2016-12-14 21:32 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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 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_plane_state *state;
expression E;
@@
(
- E * state->fb->bits_per_pixel / 8
+ E * state->fb->format->cpp[0]
|
- state->fb->bits_per_pixel / 8
+ state->fb->format->cpp[0]
|
- E * state->fb->bits_per_pixel >> 3
+ E * state->fb->format->cpp[0]
|
- state->fb->bits_per_pixel >> 3
+ state->fb->format->cpp[0]
|
- (state->fb->bits_per_pixel + 7) / 8
+ state->fb->format->cpp[0]
|
- state->fb->bits_per_pixel
+ state->fb->format->cpp[0] * 8
|
- state->fb->format->cpp[0] * 8 != 8
+ state->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)
v3: Adjusted the semantic patch a bit and regenerated due to code
    changes

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)
---
 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           |  2 +-
 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/hisilicon/hibmc/hibmc_drm_de.c |  6 +++---
 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             |  4 ++--
 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, 90 insertions(+), 101 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index 9999dc71b998..8d0ff1c8db8e 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -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);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index b3d62b909f43..c25edecb46d4 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -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);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index e564442b6393..ffd20f90788c 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -1630,7 +1630,7 @@ static int dce_v6_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_v6_0_grph_enable(crtc, true);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index 6ce7fb42dbef..e6f446af3818 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -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);
diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index 99283f30edc5..426e86f4cf96 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -190,7 +190,7 @@ static unsigned armada_drm_crtc_calc_fb(struct drm_framebuffer *fb,
 	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);
 
 	armada_drm_plane_calc_addrs(addrs, fb, x, y);
 
diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c
index 3a58fb600b05..78335100cbc3 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
index f751792a3c7c..b085140fae95 100644
--- a/drivers/gpu/drm/ast/ast_fb.c
+++ b/drivers/gpu/drm/ast/ast_fb.c
@@ -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;
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index e70364a8544e..606cb40f6c7c 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -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:
diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 3cac8a03cf4f..79a5cd108245 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c b/drivers/gpu/drm/cirrus/cirrus_mode.c
index 06674a9b7665..ed43ab10ac99 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 96c78b33a999..bee5e4149a1c 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1169,7 +1169,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);
 
@@ -1252,14 +1252,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;
 	}
 
@@ -1645,7 +1645,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;
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 556a92359c96..94ddab41f24f 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -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) ||
diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index e5d19e5fc341..3c44409244dc 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -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;
diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index 6ca1f3117fe8..e8ce4a318586 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -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;
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index f4d5a2133777..58dc9a5196bc 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -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)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index e68a46f112f6..d8808158d418 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -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;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index e2e405170d35..0029065979b8 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -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)
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index edb20a34c66c..b313e61aab65 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -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 &&
diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index a93b59ce6b41..6bf33ba055b3 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
index 5b852ad152ae..d1c5642b1c1e 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/mdfld_intel_display.c b/drivers/gpu/drm/gma500/mdfld_intel_display.c
index 3be3111825cd..63c6e08600ae 100644
--- a/drivers/gpu/drm/gma500/mdfld_intel_display.c
+++ b/drivers/gpu/drm/gma500/mdfld_intel_display.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
index 569810d47786..0fff269d3fe6 100644
--- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
+++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
@@ -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;
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
index 2a1386e33126..c655883d3613 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
@@ -122,11 +122,11 @@ static void hibmc_plane_atomic_update(struct drm_plane *plane,
 
 	writel(gpu_addr, priv->mmio + HIBMC_CRT_FB_ADDRESS);
 
-	reg = state->fb->width * (state->fb->bits_per_pixel / 8);
+	reg = state->fb->width * (state->fb->format->cpp[0]);
 	/* now line_pad is 16 */
 	reg = PADDING(16, reg);
 
-	line_l = state->fb->width * state->fb->bits_per_pixel / 8;
+	line_l = state->fb->width * state->fb->format->cpp[0];
 	line_l = PADDING(16, line_l);
 	writel(HIBMC_FIELD(HIBMC_CRT_FB_WIDTH_WIDTH, reg) |
 	       HIBMC_FIELD(HIBMC_CRT_FB_WIDTH_OFFS, line_l),
@@ -136,7 +136,7 @@ static void hibmc_plane_atomic_update(struct drm_plane *plane,
 	reg = readl(priv->mmio + HIBMC_CRT_DISP_CTL);
 	reg &= ~HIBMC_CRT_DISP_CTL_FORMAT_MASK;
 	reg |= HIBMC_FIELD(HIBMC_CRT_DISP_CTL_FORMAT,
-			   state->fb->bits_per_pixel / 16);
+			   state->fb->format->cpp[0] * 8 / 16);
 	writel(reg, priv->mmio + HIBMC_CRT_DISP_CTL);
 }
 
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index a3d9cb5ad184..7eded0561f75 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -1870,7 +1870,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);
@@ -1888,7 +1888,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);
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 9ede5f7bd484..d425d7efb9f8 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -8755,7 +8755,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) {
@@ -8784,7 +8783,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;
@@ -9782,7 +9781,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;
@@ -9827,7 +9825,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;
@@ -9898,7 +9896,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;
@@ -9927,7 +9924,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;
@@ -11084,7 +11081,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])
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index 9c5e9cfa4ed7..06afce1eac49 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -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);
diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c
index 19a78b6b5a1a..1a665e1671b8 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -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;
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
index 9399099d3e39..067dfbc91b1c 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 480e3ab477fd..a72754d73c84 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -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;
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index e0db5d38fb18..c5cf88859b0b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -947,7 +947,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 */
diff --git a/drivers/gpu/drm/qxl/qxl_draw.c b/drivers/gpu/drm/qxl/qxl_draw.c
index 9b728edf1b49..4d8681e84e68 100644
--- a/drivers/gpu/drm/qxl/qxl_draw.c
+++ b/drivers/gpu/drm/qxl/qxl_draw.c
@@ -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;
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 05f4ebe31ce2..0d7f84f7d71d 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -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);
 
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 984b35f43554..e3399310d41d 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -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];
 		}
 	}
 
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 6285355eb5d5..aea8b62835a4 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -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;
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index 31c03e32a6b5..ce6cb6666212 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -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;
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index b60c306190e9..642dcff87e34 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -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 */
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index d2893f65341a..e289dbc6ad82 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -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));
 	}
 
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index e21a3ed3ab2b..b8dc06d68777 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -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;
diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c b/drivers/gpu/drm/virtio/virtgpu_fb.c
index 9d0da42cc420..61254b991265 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fb.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fb.c
@@ -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);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
index 4a7a7d2997dd..58643c5ca1d7 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
@@ -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;
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
index a3a839a3d441..3806148e1bdb 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
@@ -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. */
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
index 38d7b8a2b78e..d4268efc37d2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
@@ -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];
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
index 94ad8d2acf9a..b27cd18ee66a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
@@ -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;
diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
index 0c14f0adf161..72b9b4898915 100644
--- a/include/drm/drm_framebuffer.h
+++ b/include/drm/drm_framebuffer.h
@@ -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.
 	 */
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [PATCH v3 33/37] drm: Nuke fb->pixel_format
  2016-11-18 19:53 ` [PATCH v2 33/37] drm: Nuke fb->pixel_format ville.syrjala
  2016-11-19  2:55   ` Laurent Pinchart
@ 2016-12-14 21:32   ` ville.syrjala
  1 sibling, 0 replies; 99+ messages in thread
From: ville.syrjala @ 2016-12-14 21:32 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Replace uses of fb->pixel_format 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 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 *a;
struct drm_framebuffer b;
@@
(
- a->pixel_format
+ a->format->format
|
- b.pixel_format
+ b.format->format
)

@@
struct drm_plane_state *a;
struct drm_plane_state b;
@@
(
- a->fb->pixel_format
+ a->fb->format->format
|
- b.fb->pixel_format
+ b.fb->format->format
)

@@
struct drm_crtc *CRTC;
@@
(
- CRTC->primary->fb->pixel_format
+ CRTC->primary->fb->format->format
|
- CRTC->primary->state->fb->pixel_format
+ CRTC->primary->state->fb->format->format
)

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

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

v2: Fix commit message (Laurent)
    Rebase due to earlier removal of many fb->pixel_format uses,
    including the 'fb->format = drm_format_info(fb->format->format);'
    snafu
v3: Adjusted the semantic patch a bit and regenerated due to code
    changes

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 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                |  2 +-
 drivers/gpu/drm/arm/malidp_planes.c             |  8 +++---
 drivers/gpu/drm/armada/armada_crtc.c            |  2 +-
 drivers/gpu/drm/armada/armada_overlay.c         |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 18 ++++++-------
 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_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               | 34 ++++++++++++-------------
 drivers/gpu/drm/mediatek/mtk_drm_plane.c        |  2 +-
 drivers/gpu/drm/meson/meson_plane.c             |  2 +-
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c       |  2 +-
 drivers/gpu/drm/msm/msm_fb.c                    |  2 +-
 drivers/gpu/drm/mxsfb/mxsfb_crtc.c              |  2 +-
 drivers/gpu/drm/nouveau/dispnv04/overlay.c      |  8 +++---
 drivers/gpu/drm/nouveau/nv50_display.c          |  4 +--
 drivers/gpu/drm/omapdrm/omap_fb.c               |  2 +-
 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     | 18 ++++++-------
 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                   |  8 +++---
 drivers/gpu/drm/sti/sti_hqvdp.c                 |  2 +-
 drivers/gpu/drm/sun4i/sun4i_backend.c           |  3 ++-
 drivers/gpu/drm/tegra/dc.c                      |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c            |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_plane.c           |  2 +-
 drivers/gpu/drm/vc4/vc4_plane.c                 |  4 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c              |  2 +-
 drivers/gpu/drm/zte/zx_plane.c                  |  2 +-
 include/drm/drm_framebuffer.h                   |  4 ---
 54 files changed, 145 insertions(+), 151 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index 8d0ff1c8db8e..84afaae97e65 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index c25edecb46d4..7a7fa96d2e49 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index ffd20f90788c..59eff6e9a883 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -1501,7 +1501,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 = (GRPH_DEPTH(GRPH_DEPTH_8BPP) |
 			     GRPH_FORMAT(GRPH_FORMAT_INDEXED));
@@ -1567,7 +1567,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;
 	}
 
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index e6f446af3818..8de832dd981d 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index 5c26c5f126a3..ad9a95916f1f 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -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;
 
diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
index ecdcd99c92cc..20ebfb4fbdfa 100644
--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
@@ -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)
diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
index 533ee2fa64be..eff2fe47e26a 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -112,7 +112,7 @@ 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;
 
@@ -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;
 
diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index 426e86f4cf96..41fc6ee9da91 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -1035,7 +1035,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);
diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
index a0883a1b3387..34cb73d0db77 100644
--- a/drivers/gpu/drm/armada/armada_overlay.c
+++ b/drivers/gpu/drm/armada/armada_overlay.c
@@ -186,7 +186,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 
 		armada_drm_plane_calc_addrs(addrs, fb, src_x, src_y);
 
-		pixel_format = fb->pixel_format;
+		pixel_format = fb->format->format;
 		hsub = drm_format_horz_chroma_subsampling(pixel_format);
 		num_planes = fb->format->num_planes;
 
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index 3e00512ef187..bd2791c4b002 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -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;
 
@@ -664,8 +664,8 @@ 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;
@@ -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)
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 62f0f57728e1..b602faf28367 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -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");
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 14c58072651b..080c8d361f1f 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -575,11 +575,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;
 			}
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 5d2cb138eba6..94bce0b462aa 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
index 181a9eafe34a..aab4465307ed 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -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: ",
diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index 3c44409244dc..639e474e7d43 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -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);
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index c2dc8e6f80ff..f479cda5fc2d 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -482,11 +482,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;
 	}
@@ -858,7 +858,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;
diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index e8ce4a318586..c5c01628c715 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -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;
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index 58dc9a5196bc..f9ab19e205e2 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -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;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 0029065979b8..745cfbdf6b39 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -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)
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index b313e61aab65..a106046e0c93 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -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 ||
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
index a99f48847420..0a20723aa6e1 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
@@ -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;
diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
index 3ea70459b901..307d460ab684 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
@@ -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;
 
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 7eded0561f75..15deb2bc568b 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -3031,7 +3031,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");
 		}
diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
index dbe9fb41ae53..e049838159a1 100644
--- a/drivers/gpu/drm/i915/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
@@ -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;
 
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index d425d7efb9f8..463984a5a251 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2456,7 +2456,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);
@@ -2701,7 +2701,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];
@@ -2977,7 +2977,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;
@@ -3032,7 +3032,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;
@@ -3147,7 +3147,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;
@@ -3283,7 +3283,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;
@@ -3398,7 +3398,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);
@@ -4769,7 +4769,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:
@@ -4785,7 +4785,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;
 	}
 
@@ -8754,7 +8754,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) {
@@ -8776,7 +8775,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;
@@ -9780,7 +9779,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;
@@ -9814,11 +9812,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;
@@ -9895,7 +9893,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;
@@ -9917,7 +9914,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;
@@ -12183,7 +12180,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;
 
 	/*
@@ -12880,7 +12877,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,
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index 06afce1eac49..73d02d21c768 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -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",
diff --git a/drivers/gpu/drm/i915/intel_overlay.c b/drivers/gpu/drm/i915/intel_overlay.c
index 90bab516e891..489c14ff2cb9 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -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;
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 351476e85452..d0834b3d4fb6 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -3222,7 +3222,7 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
 		return 0;
 
 	fb = pstate->fb;
-	format = fb->pixel_format;
+	format = fb->format->format;
 
 	if (pstate->plane->type == DRM_PLANE_TYPE_CURSOR)
 		return 0;
@@ -3309,7 +3309,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 */
@@ -3324,12 +3324,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];
 
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index c2448471fd93..7031bc733d97 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -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_id), fb->pitches[0]);
 	I915_WRITE(SPPOS(pipe, plane_id), (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;
 
diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c
index f44a83656310..0b945f077344 100644
--- a/drivers/gpu/drm/imx/ipuv3-plane.c
+++ b/drivers/gpu/drm/imx/ipuv3-plane.c
@@ -92,8 +92,8 @@ 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 +
 	       fb->format->cpp[1] * x - eba;
@@ -111,8 +111,8 @@ 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 +
 	       fb->format->cpp[2] * x - eba;
@@ -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,
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index 71421923c592..e405e89ed5e5 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -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) * fb->format->cpp[0];
 	addr += (plane->state->src.y1 >> 16) * pitch;
diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c
index 4942ca090b46..642b2fab42ff 100644
--- a/drivers/gpu/drm/meson/meson_plane.c
+++ b/drivers/gpu/drm/meson/meson_plane.c
@@ -113,7 +113,7 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
 	if (meson_vpu_is_compatible(priv, "amlogic,meson-gxbb-vpu"))
 		priv->viu.osd1_blk0_cfg[0] |= OSD_OUTPUT_COLOR_RGB;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_XRGB8888:
 		/* For XRGB, replace the pixel's alpha by 0xFF */
 		writel_bits_relaxed(OSD_REPLACE_EN, OSD_REPLACE_EN,
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
index 911e4690d36a..53619d07677e 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
@@ -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;
diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c
index 0649863d7fd7..5cf165c9c3a9 100644
--- a/drivers/gpu/drm/msm/msm_fb.c
+++ b/drivers/gpu/drm/msm/msm_fb.c
@@ -68,7 +68,7 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 	int i, n = fb->format->num_planes;
 
 	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++) {
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
index 081890336ce7..e10a4eda4078 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
@@ -46,7 +46,7 @@ static int mxsfb_set_pixel_fmt(struct mxsfb_drm_private *mxsfb)
 {
 	struct drm_crtc *crtc = &mxsfb->pipe.crtc;
 	struct drm_device *drm = crtc->dev;
-	const u32 format = crtc->primary->state->fb->pixel_format;
+	const u32 format = crtc->primary->state->fb->format->format;
 	u32 ctrl, ctrl1;
 
 	ctrl = CTRL_BYPASS_COUNT | CTRL_MASTER;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/overlay.c b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
index a79514d440b3..6275c270df25 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/overlay.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
@@ -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);
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index b617e5d3277a..cb85cb72dc1c 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -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   :
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index c6ef457b9fca..bd6b94c38613 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -346,7 +346,7 @@ void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 	int i, n = fb->format->num_planes;
 
 	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];
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 0d7f84f7d71d..3c492a0aa6bd 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index a74f8ed8ca2e..dcde6288da6c 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index 83ebd162f3ef..b5bfbe50bd87 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 50e085e74214..fb5f001f51c3 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -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;
@@ -753,16 +753,16 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 	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);
+	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 = fb->format->cpp[1];
 
 		uv_obj = rockchip_fb_get_gem_obj(fb, 1);
@@ -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) |
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
index dddbdd62bed0..445476551695 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_plane.c b/drivers/gpu/drm/shmobile/shmob_drm_plane.c
index 1805bb23b113..2023a93cee2b 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_plane.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_plane.c
@@ -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;
 	}
 
diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
index 58316bd6d7d6..877d053d86f4 100644
--- a/drivers/gpu/drm/sti/sti_gdp.c
+++ b/drivers/gpu/drm/sti/sti_gdp.c
@@ -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,7 +753,7 @@ 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 */
diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c
index f88130f2eb48..becf10d255c4 100644
--- a/drivers/gpu/drm/sti/sti_hqvdp.c
+++ b/drivers/gpu/drm/sti/sti_hqvdp.c
@@ -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 */
diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
index a606207d4e25..a278e1f44661 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -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;
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 642dcff87e34..7561a95a54e3 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -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;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 0dc96e12fd06..47c2fe659fe3 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -399,7 +399,7 @@ static void tilcdc_crtc_set_mode(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;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
index c0fc874e91cf..4b7519dfd1b9 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
@@ -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__);
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
index f84f6bddd015..110d1518f5d5 100644
--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -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 = fb->format->num_planes;
 	u32 h_subsample = 1;
 	u32 v_subsample = 1;
@@ -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;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
index 58643c5ca1d7..867a8442220c 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
@@ -488,7 +488,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->pixel_format == mode_cmd.pixel_format &&
+	    cur_fb->format->format == mode_cmd.pixel_format &&
 	    cur_fb->pitches[0] == mode_cmd.pitches[0])
 		return 0;
 
diff --git a/drivers/gpu/drm/zte/zx_plane.c b/drivers/gpu/drm/zte/zx_plane.c
index 72d27b0a48b2..b634b090cdc1 100644
--- a/drivers/gpu/drm/zte/zx_plane.c
+++ b/drivers/gpu/drm/zte/zx_plane.c
@@ -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;
diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
index 72b9b4898915..f0dde1d02be4 100644
--- a/include/drm/drm_framebuffer.h
+++ b/include/drm/drm_framebuffer.h
@@ -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.
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* Re: [PATCH v2 00/37] drm: Deduplicate fb format information (v2)
  2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
                   ` (37 preceding siblings ...)
  2016-11-21 11:18 ` [PATCH v2 00/37] drm: Deduplicate fb format information (v2) Christian König
@ 2016-12-14 21:37 ` Ville Syrjälä
  2016-12-15 13:41   ` Ville Syrjälä
  38 siblings, 1 reply; 99+ messages in thread
From: Ville Syrjälä @ 2016-12-14 21:37 UTC (permalink / raw)
  To: dri-devel
  Cc: Ben Widawsky, Gerd Hoffmann, Paulo Zanoni, Sinclair Yeh,
	Liviu Dudau, intel-gfx, Alexey Brodkin, Thomas Hellstrom,
	Christian König, linux-graphics-maintainer,
	Laurent Pinchart, Mali DP Maintainers, Alex Deucher, Dave Airlie,
	Ben Skeggs

On Fri, Nov 18, 2016 at 09:52:36PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Second installment of my effort to remove the duplicated
> depth/bpp/pixel_format from drm_framebuffer and just use
> struct drm_format_info instead.
> 
> I tried to address all of the review feedback, and collect
> up all the r-bs I already got. Thanks for the review, guys.
> 
> Changes since the last version are roughly:
> * drm_framebuffer_init() now fails if the fb isn't properly prepared
> * Applied mode cocciry all over to use fb->format more extensively
> * Dropped a few i915 specific patches that were taken care of the
>   previous item
> * Took up Laurent's idea that we can just compare the fb->format
>   pointers instead of comparing the fb->format->format values
> * Added a new .get_format_info() hooks for drivers to provide custom
>   format information + an quick example patch how we'd hook it up
>   for i915 render compression support
> 
> Link to the previous version:
> https://lists.freedesktop.org/archives/dri-devel/2016-November/124135.html
> 
> Entire series is available here:
> git://github.com/vsyrjala/linux.git fb_format_dedup_2
> 
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Cc: Ben Widawsky <ben@bwidawsk.net>
> Cc: Brian Starkey <brian.starkey@arm.com>
> Cc: "Christian König" <christian.koenig@amd.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: intel-gfx@lists.freedesktop.org
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: linux-graphics-maintainer@vmware.com
> Cc: Liviu Dudau <liviu.dudau@arm.com>
> Cc: Mali DP Maintainers <malidp@foss.arm.com>
> Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
> Cc: Sinclair Yeh <syeh@vmware.com>
> Cc: Thomas Hellstrom <thellstrom@vmware.com>
> 
> Ville Syrjälä (37):
>   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

I've pushed up to here to drm-misc-next. Thanks for the reviews.

I re-ran spatch to regenerate some of the later patches as there had
been a bit of churn in the code. I've reposted the changed patches,
and if no one screams I'll be pushing the rest tomorrowish.

>   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: Reject fbs w/o format info in drm_framebuffer_init()
>   drm: Replace drm_format_num_planes() with fb->format->num_planes
>   drm/i915: Eliminate the ugly 'fb?:' constructs from the ilk/skl wm
>     code
>   drm: Replace drm_format_plane_cpp() with fb->format->cpp[]
>   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: 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
>   drm: Replace 'format->format' comparisons to just 'format' comparisons
>   drm: Eliminate the useless "non-RGB fb" debug message
>   drm: Add mode_config .get_format_info() hook
>   drm/i915: Implement .get_format_info() hook for CCS
> 
>  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         |   6 +-
>  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               |   3 +-
>  drivers/gpu/drm/drm_fb_cma_helper.c             |  13 ++-
>  drivers/gpu/drm/drm_fb_helper.c                 |  10 +--
>  drivers/gpu/drm/drm_fourcc.c                    |  25 ++++++
>  drivers/gpu/drm/drm_framebuffer.c               |  62 +++++++++++--
>  drivers/gpu/drm/drm_modeset_helper.c            |  22 +----
>  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            | 115 ++++++++++++++++--------
>  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                 |  67 +++++++-------
>  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        |   4 +-
>  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                 |   8 +-
>  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                  |   4 +-
>  include/drm/drm_fourcc.h                        |   6 ++
>  include/drm/drm_framebuffer.h                   |  27 +++---
>  include/drm/drm_mode_config.h                   |  15 ++++
>  include/drm/drm_modeset_helper.h                |   3 +-
>  include/uapi/drm/drm_fourcc.h                   |   3 +
>  110 files changed, 641 insertions(+), 470 deletions(-)
> 
> -- 
> 2.7.4

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PATCH v2 00/37] drm: Deduplicate fb format information (v2)
  2016-12-14 21:37 ` Ville Syrjälä
@ 2016-12-15 13:41   ` Ville Syrjälä
  0 siblings, 0 replies; 99+ messages in thread
From: Ville Syrjälä @ 2016-12-15 13:41 UTC (permalink / raw)
  To: dri-devel
  Cc: Ben Widawsky, Paulo Zanoni, Sinclair Yeh, Alexey Brodkin,
	intel-gfx, Liviu Dudau, Thomas Hellstrom, Ben Skeggs,
	linux-graphics-maintainer, Gerd Hoffmann, Dave Airlie,
	Alex Deucher, Mali DP Maintainers, Christian König,
	Laurent Pinchart

On Wed, Dec 14, 2016 at 11:37:46PM +0200, Ville Syrjälä wrote:
> On Fri, Nov 18, 2016 at 09:52:36PM +0200, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Second installment of my effort to remove the duplicated
> > depth/bpp/pixel_format from drm_framebuffer and just use
> > struct drm_format_info instead.
> > 
> > I tried to address all of the review feedback, and collect
> > up all the r-bs I already got. Thanks for the review, guys.
> > 
> > Changes since the last version are roughly:
> > * drm_framebuffer_init() now fails if the fb isn't properly prepared
> > * Applied mode cocciry all over to use fb->format more extensively
> > * Dropped a few i915 specific patches that were taken care of the
> >   previous item
> > * Took up Laurent's idea that we can just compare the fb->format
> >   pointers instead of comparing the fb->format->format values
> > * Added a new .get_format_info() hooks for drivers to provide custom
> >   format information + an quick example patch how we'd hook it up
> >   for i915 render compression support
> > 
> > Link to the previous version:
> > https://lists.freedesktop.org/archives/dri-devel/2016-November/124135.html
> > 
> > Entire series is available here:
> > git://github.com/vsyrjala/linux.git fb_format_dedup_2
> > 
> > Cc: Alex Deucher <alexander.deucher@amd.com>
> > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > Cc: Ben Skeggs <bskeggs@redhat.com>
> > Cc: Ben Widawsky <ben@bwidawsk.net>
> > Cc: Brian Starkey <brian.starkey@arm.com>
> > Cc: "Christian König" <christian.koenig@amd.com>
> > Cc: Dave Airlie <airlied@redhat.com>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: intel-gfx@lists.freedesktop.org
> > Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Cc: linux-graphics-maintainer@vmware.com
> > Cc: Liviu Dudau <liviu.dudau@arm.com>
> > Cc: Mali DP Maintainers <malidp@foss.arm.com>
> > Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> > Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
> > Cc: Sinclair Yeh <syeh@vmware.com>
> > Cc: Thomas Hellstrom <thellstrom@vmware.com>
> > 
> > Ville Syrjälä (37):
> >   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
> 
> I've pushed up to here to drm-misc-next. Thanks for the reviews.
> 
> I re-ran spatch to regenerate some of the later patches as there had
> been a bit of churn in the code. I've reposted the changed patches,
> and if no one screams I'll be pushing the rest tomorrowish.
> 
> >   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: Reject fbs w/o format info in drm_framebuffer_init()
> >   drm: Replace drm_format_num_planes() with fb->format->num_planes
> >   drm/i915: Eliminate the ugly 'fb?:' constructs from the ilk/skl wm
> >     code
> >   drm: Replace drm_format_plane_cpp() with fb->format->cpp[]
> >   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: 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
> >   drm: Replace 'format->format' comparisons to just 'format' comparisons
> >   drm: Eliminate the useless "non-RGB fb" debug message

And I've just pushed up to here (minus the vmvgfx patches which dropped
out due to Daniel's earlier refactorin).

> >   drm: Add mode_config .get_format_info() hook
> >   drm/i915: Implement .get_format_info() hook for CCS

I'll hang on to these until we get the i915 CCS thing into shape.

Thanks for the reviews everyone.

> > 
> >  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         |   6 +-
> >  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               |   3 +-
> >  drivers/gpu/drm/drm_fb_cma_helper.c             |  13 ++-
> >  drivers/gpu/drm/drm_fb_helper.c                 |  10 +--
> >  drivers/gpu/drm/drm_fourcc.c                    |  25 ++++++
> >  drivers/gpu/drm/drm_framebuffer.c               |  62 +++++++++++--
> >  drivers/gpu/drm/drm_modeset_helper.c            |  22 +----
> >  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            | 115 ++++++++++++++++--------
> >  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                 |  67 +++++++-------
> >  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        |   4 +-
> >  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                 |   8 +-
> >  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                  |   4 +-
> >  include/drm/drm_fourcc.h                        |   6 ++
> >  include/drm/drm_framebuffer.h                   |  27 +++---
> >  include/drm/drm_mode_config.h                   |  15 ++++
> >  include/drm/drm_modeset_helper.h                |   3 +-
> >  include/uapi/drm/drm_fourcc.h                   |   3 +
> >  110 files changed, 641 insertions(+), 470 deletions(-)
> > 
> > -- 
> > 2.7.4
> 
> -- 
> Ville Syrjälä
> Intel OTC
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 99+ messages in thread

end of thread, other threads:[~2016-12-15 13:41 UTC | newest]

Thread overview: 99+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-18 19:52 [PATCH v2 00/37] drm: Deduplicate fb format information (v2) ville.syrjala
2016-11-18 19:52 ` [PATCH 01/37] drm/i915: Add local 'fb' variables ville.syrjala
2016-11-30 14:44   ` Daniel Vetter
2016-11-18 19:52 ` [PATCH 02/37] drm/radeon: " ville.syrjala
2016-11-18 19:52 ` [PATCH 03/37] drm/radeon: Use DIV_ROUND_UP() ville.syrjala
2016-11-18 19:52 ` [PATCH 04/37] drm/mgag200: Add local 'fb' variable ville.syrjala
2016-11-30 14:45   ` Daniel Vetter
2016-11-18 19:52 ` [PATCH 05/37] drm/ast: Add local 'fb' variables ville.syrjala
2016-11-30 14:47   ` Daniel Vetter
2016-11-18 19:52 ` [PATCH 06/37] drm/gma500: Add some " ville.syrjala
2016-11-30 14:49   ` Daniel Vetter
2016-11-18 19:52 ` [PATCH 07/37] drm/cirrus: " ville.syrjala
2016-11-30 14:50   ` Daniel Vetter
2016-11-18 19:52 ` [PATCH 08/37] drm/arcpgu: Add " ville.syrjala
2016-11-21 15:30   ` Alexey Brodkin
2016-11-23 16:00   ` Alexey Brodkin
2016-11-18 19:52 ` [PATCH 09/37] drm/arm: " ville.syrjala
2016-11-18 20:30   ` Brian Starkey
2016-11-21 11:51   ` Liviu Dudau
2016-11-22 13:48     ` Ville Syrjälä
2016-11-22 13:57       ` Daniel Vetter
2016-11-18 19:52 ` [PATCH 10/37] drm/nouveau: Fix crtc->primary->fb vs. drm_fb fail ville.syrjala
2016-11-30 14:56   ` Daniel Vetter
2016-11-18 19:52 ` [PATCH 11/37] drm/nouveau: Add local 'fb' variables ville.syrjala
2016-11-30 14:57   ` Daniel Vetter
2016-11-18 19:52 ` [PATCH 12/37] drm/vmwgfx: Populate fb->dev before drm_framebuffer_init() ville.syrjala
2016-11-21 17:10   ` Sinclair Yeh
2016-11-22 13:53   ` [PATCH v2 " ville.syrjala
2016-11-18 19:52 ` [PATCH 13/37] drm: Pass 'dev' to drm_helper_mode_fill_fb_struct() ville.syrjala
2016-12-14 20:48   ` [PATCH v2 " ville.syrjala
2016-11-18 19:52 ` [PATCH 14/37] drm/vmwgfx: Populate fb->pixel_format ville.syrjala
2016-11-21 17:10   ` Sinclair Yeh
2016-11-18 19:52 ` [PATCH 15/37] drm/qxl: Call drm_helper_mode_fill_fb_struct() before drm_framebuffer_init() ville.syrjala
2016-11-18 19:52 ` [PATCH 16/37] drm/virtio: " ville.syrjala
2016-11-30 15:32   ` Daniel Vetter
2016-11-18 19:52 ` [PATCH 17/37] drm/i915: Set fb->dev early on for inherited fbs ville.syrjala
2016-11-30 15:36   ` Daniel Vetter
2016-11-18 19:52 ` [PATCH v2 18/37] drm: Populate fb->dev from drm_helper_mode_fill_fb_struct() ville.syrjala
2016-11-18 19:52 ` [PATCH v2 19/37] drm: Store a pointer to drm_format_info under drm_framebuffer ville.syrjala
2016-11-19  2:33   ` Laurent Pinchart
2016-11-18 19:52 ` [PATCH 20/37] drm/vmwgfx: Populate fb->format correctly ville.syrjala
2016-11-30 15:40   ` Daniel Vetter
2016-11-30 16:03     ` Ville Syrjälä
2016-11-30 16:09       ` Laurent Pinchart
2016-11-30 17:22         ` Daniel Vetter
2016-11-30 15:52   ` Daniel Vetter
2016-11-18 19:52 ` [PATCH 21/37] drm/i915: Populate fb->format early for inherited fbs ville.syrjala
2016-11-30 15:42   ` Daniel Vetter
2016-11-30 15:57     ` Ville Syrjälä
2016-11-30 16:09     ` Daniel Vetter
2016-11-18 19:52 ` [PATCH 22/37] drm: Reject fbs w/o format info in drm_framebuffer_init() ville.syrjala
2016-11-19  2:36   ` Laurent Pinchart
2016-11-18 19:52 ` [PATCH 23/37] drm: Replace drm_format_num_planes() with fb->format->num_planes ville.syrjala
2016-11-19  2:41   ` Laurent Pinchart
2016-12-14 21:30   ` [PATCH v2 " ville.syrjala
2016-11-18 19:53 ` [PATCH 24/37] drm/i915: Eliminate the ugly 'fb?:' constructs from the ilk/skl wm code ville.syrjala
2016-11-30 15:51   ` [Intel-gfx] " Daniel Vetter
2016-11-30 15:59     ` Ville Syrjälä
2016-11-18 19:53 ` [PATCH 25/37] drm: Replace drm_format_plane_cpp() with fb->format->cpp[] ville.syrjala
2016-11-19  2:44   ` Laurent Pinchart
2016-12-14 21:30   ` [PATCH v2 " ville.syrjala
2016-11-18 19:53 ` [PATCH 26/37] drm/fb_cma_helper: Replace drm_format_info() with fb->format ville.syrjala
2016-11-18 19:53 ` [PATCH 27/37] drm/nouveau: Use fb->format rather than drm_format_info() ville.syrjala
2016-11-30 15:59   ` Daniel Vetter
2016-11-18 19:53 ` [PATCH 28/37] drm/i915: Store a pointer to the pixel format info for fbc ville.syrjala
2016-11-30 16:07   ` [Intel-gfx] " Daniel Vetter
2016-11-18 19:53 ` [PATCH 29/37] drm: Add drm_framebuffer_plane_{width,height}() ville.syrjala
2016-11-18 19:53 ` [PATCH 30/37] drm/i915: Use drm_framebuffer_plane_{width, height}() where possible ville.syrjala
2016-11-30 16:04   ` Daniel Vetter
2016-11-30 16:06   ` [Intel-gfx] " Daniel Vetter
2016-11-18 19:53 ` [PATCH 31/37] drm: Nuke fb->depth ville.syrjala
2016-11-30 16:01   ` Daniel Vetter
2016-12-14 21:31   ` [PATCH v2 " ville.syrjala
2016-11-18 19:53 ` [PATCH v2 32/37] drm: Nuke fb->bits_per_pixel ville.syrjala
2016-12-14 21:32   ` [PATCH v3 " ville.syrjala
2016-11-18 19:53 ` [PATCH v2 33/37] drm: Nuke fb->pixel_format ville.syrjala
2016-11-19  2:55   ` Laurent Pinchart
2016-12-14 21:32   ` [PATCH v3 " ville.syrjala
2016-11-18 19:53 ` [PATCH 34/37] drm: Replace 'format->format' comparisons to just 'format' comparisons ville.syrjala
2016-11-19  2:56   ` Laurent Pinchart
2016-11-18 19:53 ` [PATCH 35/37] drm: Eliminate the useless "non-RGB fb" debug message ville.syrjala
2016-11-19  2:57   ` Laurent Pinchart
2016-11-18 19:53 ` [PATCH 36/37] drm: Add mode_config .get_format_info() hook ville.syrjala
2016-11-20  8:13   ` Laurent Pinchart
2016-11-21 13:18     ` Ville Syrjälä
2016-11-21 13:23       ` Laurent Pinchart
2016-11-21 13:31         ` Ville Syrjälä
2016-11-21 13:42           ` Laurent Pinchart
2016-11-21 14:25             ` Ville Syrjälä
2016-11-22 13:41   ` [PATCH v2 " ville.syrjala
2016-11-18 19:53 ` [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS ville.syrjala
2016-11-18 23:31   ` Ben Widawsky
2016-11-21 14:37     ` Ville Syrjälä
2016-11-21  8:42   ` [Intel-gfx] " Tvrtko Ursulin
2016-11-21 13:27     ` Ville Syrjälä
2016-11-21 14:04       ` Tvrtko Ursulin
2016-11-21 11:18 ` [PATCH v2 00/37] drm: Deduplicate fb format information (v2) Christian König
2016-12-14 21:37 ` Ville Syrjälä
2016-12-15 13:41   ` Ville Syrjälä

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.