Skip to contentSkip to conversation

drm: Deduplicate fb format information (v2)

PATCH In review [email protected] 10 participants 99 messages Nov 18, 2016 – Dec 15, 2016 Page 2 of 2

Subsystems (40)
lore
Share & tools
lore
#75 lore raw

PATCH v2 33/37 drm: Nuke fb->pixel_format

In reply to [email protected]

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

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
---
 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(-)
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +2 -2
index 9c8f33780257..575f010a3112 100644
@@ -2072,7 +2072,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,
 
 	pipe_config = AMDGPU_TILING_GET(tiling_flags, PIPE_CONFIG);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format = REG_SET_FIELD(0, GRPH_CONTROL, GRPH_DEPTH, 0);
 		fb_format = REG_SET_FIELD(fb_format, GRPH_CONTROL, GRPH_FORMAT, 0);
@@ -2145,7 +2145,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +2 -2
index 72ba3a50452b..9f325f4e018c 100644
@@ -2053,7 +2053,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,
 
 	pipe_config = AMDGPU_TILING_GET(tiling_flags, PIPE_CONFIG);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format = REG_SET_FIELD(0, GRPH_CONTROL, GRPH_DEPTH, 0);
 		fb_format = REG_SET_FIELD(fb_format, GRPH_CONTROL, GRPH_FORMAT, 0);
@@ -2126,7 +2126,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2 -2
index aa64d9c1a8c8..6975a78f733b 100644
@@ -1494,7 +1494,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,
 	amdgpu_bo_get_tiling_flags(abo, &tiling_flags);
 	amdgpu_bo_unreserve(abo);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_8BPP) |
 			     EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_INDEXED));
@@ -1560,7 +1560,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +2 -2
index ecf6c68b8f43..bfdfda50f0e7 100644
@@ -1950,7 +1950,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
 
 	pipe_config = AMDGPU_TILING_GET(tiling_flags, PIPE_CONFIG);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format = ((GRPH_DEPTH_8BPP << GRPH_CONTROL__GRPH_DEPTH__SHIFT) |
 			     (GRPH_FORMAT_INDEXED << GRPH_CONTROL__GRPH_FORMAT__SHIFT));
@@ -2016,7 +2016,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
drivers/gpu/drm/arc/arcpgu_crtc.c +1 -1
index 5c26c5f126a3..ad9a95916f1f 100644
@@ -36,7 +36,7 @@ static void arc_pgu_set_pxl_fmt(struct drm_crtc *crtc)
 {
 	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
 	const struct drm_framebuffer *fb = crtc->primary->state->fb;
-	uint32_t pixel_format = fb->pixel_format;
+	uint32_t pixel_format = fb->format->format;
 	struct simplefb_format *format = NULL;
 	int i;
 
drivers/gpu/drm/arm/hdlcd_crtc.c +1 -1
index 5c19c25729cb..5d8e29f6815d 100644
@@ -65,7 +65,7 @@ static int hdlcd_set_pxl_fmt(struct drm_crtc *crtc)
 	struct simplefb_format *format = NULL;
 	int i;
 
-	pixel_format = fb->pixel_format;
+	pixel_format = fb->format->format;
 
 	for (i = 0; i < ARRAY_SIZE(supported_formats); i++) {
 		if (supported_formats[i].fourcc == pixel_format)
drivers/gpu/drm/arm/malidp_planes.c +4 -4
index 533ee2fa64be..eff2fe47e26a 100644
@@ -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;
 
drivers/gpu/drm/armada/armada_crtc.c +1 -1
index c69a5ea54f23..52e139dc9e38 100644
@@ -996,7 +996,7 @@ static int armada_drm_crtc_page_flip(struct drm_crtc *crtc,
 	int ret;
 
 	/* We don't support changing the pixel format */
-	if (fb->pixel_format != crtc->primary->fb->pixel_format)
+	if (fb->format->format != crtc->primary->fb->format->format)
 		return -EINVAL;
 
 	work = kmalloc(sizeof(*work), GFP_KERNEL);
drivers/gpu/drm/armada/armada_overlay.c +1 -1
index e2ad408c2f24..fe12fe139eb4 100644
@@ -182,7 +182,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 		src_y = src.y1 >> 16;
 		src_x = src.x1 >> 16;
 
-		pixel_format = fb->pixel_format;
+		pixel_format = fb->format->format;
 		hsub = drm_format_horz_chroma_subsampling(pixel_format);
 		num_planes = fb->format->num_planes;
 
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +9 -9
index 3e00512ef187..bd2791c4b002 100644
@@ -356,7 +356,7 @@ atmel_hlcdc_plane_update_general_settings(struct atmel_hlcdc_plane *plane,
 		cfg |= ATMEL_HLCDC_LAYER_OVR | ATMEL_HLCDC_LAYER_ITER2BL |
 		       ATMEL_HLCDC_LAYER_ITER;
 
-		if (atmel_hlcdc_format_embeds_alpha(state->base.fb->pixel_format))
+		if (atmel_hlcdc_format_embeds_alpha(state->base.fb->format->format))
 			cfg |= ATMEL_HLCDC_LAYER_LAEN;
 		else
 			cfg |= ATMEL_HLCDC_LAYER_GAEN |
@@ -386,13 +386,13 @@ static void atmel_hlcdc_plane_update_format(struct atmel_hlcdc_plane *plane,
 	u32 cfg;
 	int ret;
 
-	ret = atmel_hlcdc_format_to_plane_mode(state->base.fb->pixel_format,
+	ret = atmel_hlcdc_format_to_plane_mode(state->base.fb->format->format,
 					       &cfg);
 	if (ret)
 		return;
 
-	if ((state->base.fb->pixel_format == DRM_FORMAT_YUV422 ||
-	     state->base.fb->pixel_format == DRM_FORMAT_NV61) &&
+	if ((state->base.fb->format->format == DRM_FORMAT_YUV422 ||
+	     state->base.fb->format->format == DRM_FORMAT_NV61) &&
 	    drm_rotation_90_or_270(state->base.rotation))
 		cfg |= ATMEL_HLCDC_YUV422ROT;
 
@@ -405,7 +405,7 @@ static void atmel_hlcdc_plane_update_format(struct atmel_hlcdc_plane *plane,
 	 * Rotation optimization is not working on RGB888 (rotation is still
 	 * working but without any optimization).
 	 */
-	if (state->base.fb->pixel_format == DRM_FORMAT_RGB888)
+	if (state->base.fb->format->format == DRM_FORMAT_RGB888)
 		cfg = ATMEL_HLCDC_LAYER_DMA_ROTDIS;
 	else
 		cfg = 0;
@@ -514,7 +514,7 @@ atmel_hlcdc_plane_prepare_disc_area(struct drm_crtc_state *c_state)
 		ovl_state = drm_plane_state_to_atmel_hlcdc_plane_state(ovl_s);
 
 		if (!ovl_s->fb ||
-		    atmel_hlcdc_format_embeds_alpha(ovl_s->fb->pixel_format) ||
+		    atmel_hlcdc_format_embeds_alpha(ovl_s->fb->format->format) ||
 		    ovl_state->alpha != 255)
 			continue;
 
@@ -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)
drivers/gpu/drm/drm_atomic.c +3 -3
index cb6ab0106b0b..a3e4a0dc8fb4 100644
@@ -902,11 +902,11 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
 	}
 
 	/* Check whether this plane supports the fb pixel format. */
-	ret = drm_plane_check_pixel_format(plane, state->fb->pixel_format);
+	ret = drm_plane_check_pixel_format(plane, state->fb->format->format);
 	if (ret) {
 		struct drm_format_name_buf format_name;
 		DRM_DEBUG_ATOMIC("Invalid pixel format %s\n",
-		                 drm_get_format_name(state->fb->pixel_format,
+		                 drm_get_format_name(state->fb->format->format,
 		                                     &format_name));
 		return ret;
 	}
@@ -964,7 +964,7 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,
 		struct drm_format_name_buf format_name;
 
 		drm_printf(p, "\t\tformat=%s\n",
-		              drm_get_format_name(fb->pixel_format, &format_name));
+		              drm_get_format_name(fb->format->format, &format_name));
 		drm_printf(p, "\t\t\tmodifier=0x%llx\n", fb->modifier);
 		drm_printf(p, "\t\tsize=%dx%d\n", fb->width, fb->height);
 		drm_printf(p, "\t\tlayers:\n");
drivers/gpu/drm/drm_crtc.c +2 -2
index 90931e039731..7e814741f7f3 100644
@@ -556,11 +556,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
 		 */
 		if (!crtc->primary->format_default) {
 			ret = drm_plane_check_pixel_format(crtc->primary,
-							   fb->pixel_format);
+							   fb->format->format);
 			if (ret) {
 				struct drm_format_name_buf format_name;
 				DRM_DEBUG_KMS("Invalid pixel format %s\n",
-				              drm_get_format_name(fb->pixel_format,
+				              drm_get_format_name(fb->format->format,
 				                                  &format_name));
 				goto out;
 			}
drivers/gpu/drm/drm_crtc_helper.c +2 -2
index 5d2cb138eba6..94bce0b462aa 100644
@@ -588,8 +588,8 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
 		if (set->crtc->primary->fb == NULL) {
 			DRM_DEBUG_KMS("crtc has no fb, full mode set\n");
 			mode_changed = true;
-		} else if (set->fb->pixel_format !=
-			   set->crtc->primary->fb->pixel_format) {
+		} else if (set->fb->format->format !=
+			   set->crtc->primary->fb->format->format) {
 			mode_changed = true;
 		} else
 			fb_changed = true;
drivers/gpu/drm/drm_fb_cma_helper.c +1 -1
index 181a9eafe34a..aab4465307ed 100644
@@ -307,7 +307,7 @@ static void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file *m)
 	int i;
 
 	seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height,
-			(char *)&fb->pixel_format);
+			(char *)&fb->format->format);
 
 	for (i = 0; i < fb->fomat->num_planes; i++) {
 		seq_printf(m, "   %d: offset=%d pitch=%d, obj: ",
drivers/gpu/drm/drm_modeset_helper.c +0 -1
index 3c44409244dc..639e474e7d43 100644
@@ -94,7 +94,6 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
 		fb->offsets[i] = mode_cmd->offsets[i];
 	}
 	fb->modifier = mode_cmd->modifier[0];
-	fb->pixel_format = mode_cmd->pixel_format;
 	fb->flags = mode_cmd->flags;
 }
 EXPORT_SYMBOL(drm_helper_mode_fill_fb_struct);
drivers/gpu/drm/drm_plane.c +3 -3
index 419ac313c36f..ac1e06df7280 100644
@@ -478,11 +478,11 @@ static int __setplane_internal(struct drm_plane *plane,
 	}
 
 	/* Check whether this plane supports the fb pixel format. */
-	ret = drm_plane_check_pixel_format(plane, fb->pixel_format);
+	ret = drm_plane_check_pixel_format(plane, fb->format->format);
 	if (ret) {
 		struct drm_format_name_buf format_name;
 		DRM_DEBUG_KMS("Invalid pixel format %s\n",
-		              drm_get_format_name(fb->pixel_format,
+		              drm_get_format_name(fb->format->format,
 		                                  &format_name));
 		goto out;
 	}
@@ -854,7 +854,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 	if (ret)
 		goto out;
 
-	if (crtc->primary->fb->pixel_format != fb->pixel_format) {
+	if (crtc->primary->fb->format->format != fb->format->format) {
 		DRM_DEBUG_KMS("Page flip is not allowed to change frame buffer format.\n");
 		ret = -EINVAL;
 		goto out;
drivers/gpu/drm/exynos/exynos5433_drm_decon.c +1 -1
index e8ce4a318586..c5c01628c715 100644
@@ -200,7 +200,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
 	val = readl(ctx->addr + DECON_WINCONx(win));
 	val &= ~WINCONx_BPPMODE_MASK;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_XRGB1555:
 		val |= WINCONx_BPPMODE_16BPP_I1555;
 		val |= WINCONx_HAWSWP_F;
drivers/gpu/drm/exynos/exynos7_drm_decon.c +1 -1
index 58dc9a5196bc..f9ab19e205e2 100644
@@ -281,7 +281,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
 	val = readl(ctx->regs + WINCON(win));
 	val &= ~WINCONx_BPPMODE_MASK;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_RGB565:
 		val |= WINCONx_BPPMODE_16BPP_565;
 		val |= WINCONx_BURSTLEN_16WORD;
drivers/gpu/drm/exynos/exynos_drm_fimd.c +1 -1
index 0029065979b8..745cfbdf6b39 100644
@@ -804,7 +804,7 @@ static void fimd_update_plane(struct exynos_drm_crtc *crtc,
 		DRM_DEBUG_KMS("osd size = 0x%x\n", (unsigned int)val);
 	}
 
-	fimd_win_set_pixfmt(ctx, win, fb->pixel_format, state->src.w);
+	fimd_win_set_pixfmt(ctx, win, fb->format->format, state->src.w);
 
 	/* hardware window 0 doesn't support color key. */
 	if (win != 0)
drivers/gpu/drm/exynos/exynos_mixer.c +4 -4
index b313e61aab65..a106046e0c93 100644
@@ -485,7 +485,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
 	bool crcb_mode = false;
 	u32 val;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_NV12:
 		crcb_mode = false;
 		break;
@@ -494,7 +494,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
 		break;
 	default:
 		DRM_ERROR("pixel format for vp is wrong [%d].\n",
-				fb->pixel_format);
+				fb->format->format);
 		return;
 	}
 
@@ -597,7 +597,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
 	unsigned int fmt;
 	u32 val;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_XRGB4444:
 	case DRM_FORMAT_ARGB4444:
 		fmt = MXR_FORMAT_ARGB4444;
@@ -681,7 +681,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
 	mixer_cfg_scan(ctx, mode->vdisplay);
 	mixer_cfg_rgb_fmt(ctx, mode->vdisplay);
 	mixer_cfg_layer(ctx, win, priority, true);
-	mixer_cfg_gfx_blend(ctx, win, is_alpha_format(fb->pixel_format));
+	mixer_cfg_gfx_blend(ctx, win, is_alpha_format(fb->format->format));
 
 	/* layer update mandatory for mixer 16.0.33.0 */
 	if (ctx->mxr_ver == MXR_VER_16_0_33_0 ||
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c +2 -2
index a99f48847420..0a20723aa6e1 100644
@@ -44,7 +44,7 @@ static int fsl_dcu_drm_plane_atomic_check(struct drm_plane *plane,
 	if (!state->fb || !state->crtc)
 		return 0;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_RGB565:
 	case DRM_FORMAT_RGB888:
 	case DRM_FORMAT_XRGB8888:
@@ -96,7 +96,7 @@ static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane,
 
 	gem = drm_fb_cma_get_gem_obj(fb, 0);
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_RGB565:
 		bpp = FSL_DCU_RGB565;
 		break;
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +3 -3
index afc2b5d2d5f0..2f0c2e1c6110 100644
@@ -617,7 +617,7 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb,
 			 ch + 1, y, in_h, stride, (u32)obj->paddr);
 	DRM_DEBUG_DRIVER("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n",
 			 addr, fb->width, fb->height, fmt,
-			 drm_get_format_name(fb->pixel_format, &format_name));
+			 drm_get_format_name(fb->format->format, &format_name));
 
 	/* get reg offset */
 	reg_ctrl = RD_CH_CTRL(ch);
@@ -773,7 +773,7 @@ static void ade_update_channel(struct ade_plane *aplane,
 {
 	struct ade_hw_ctx *ctx = aplane->ctx;
 	void __iomem *base = ctx->base;
-	u32 fmt = ade_get_format(fb->pixel_format);
+	u32 fmt = ade_get_format(fb->format->format);
 	u32 ch = aplane->ch;
 	u32 in_w;
 	u32 in_h;
@@ -835,7 +835,7 @@ static int ade_plane_atomic_check(struct drm_plane *plane,
 	if (!crtc || !fb)
 		return 0;
 
-	fmt = ade_get_format(fb->pixel_format);
+	fmt = ade_get_format(fb->format->format);
 	if (fmt == ADE_FORMAT_UNSUPPORT)
 		return -EINVAL;
 
drivers/gpu/drm/i915/i915_debugfs.c +2 -1
index ee272ec8732c..e571e9a37ac4 100644
@@ -3042,7 +3042,8 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)
 		state = plane->state;
 
 		if (state->fb) {
-			drm_get_format_name(state->fb->pixel_format, &format_name);
+			drm_get_format_name(state->fb->format->format,
+					    &format_name);
 		} else {
 			sprintf(format_name.str, "N/A");
 		}
drivers/gpu/drm/i915/intel_atomic_plane.c +2 -2
index dbe9fb41ae53..e049838159a1 100644
@@ -155,11 +155,11 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
 		 * RGB 16-bit 5:6:5, and Indexed 8-bit.
 		 * TBD: Add RGB64 case once its added in supported format list.
 		 */
-		switch (state->fb->pixel_format) {
+		switch (state->fb->format->format) {
 		case DRM_FORMAT_C8:
 		case DRM_FORMAT_RGB565:
 			DRM_DEBUG_KMS("Unsupported pixel format %s for 90/270!\n",
-			              drm_get_format_name(state->fb->pixel_format,
+			              drm_get_format_name(state->fb->format->format,
 			                                  &format_name));
 			return -EINVAL;
 
drivers/gpu/drm/i915/intel_display.c +15 -18
index 6c889f0e8e0f..f5f9f1422d69 100644
@@ -2455,7 +2455,7 @@ u32 intel_compute_tile_offset(int *x, int *y,
 	u32 alignment;
 
 	/* AUX_DIST needs only 4K alignment */
-	if (fb->pixel_format == DRM_FORMAT_NV12 && plane == 1)
+	if (fb->format->format == DRM_FORMAT_NV12 && plane == 1)
 		alignment = 4096;
 	else
 		alignment = intel_surf_alignment(dev_priv, fb->modifier);
@@ -2700,7 +2700,7 @@ intel_alloc_initial_plane_obj(struct intel_crtc *crtc,
 	if (plane_config->tiling == I915_TILING_X)
 		obj->tiling_and_stride = fb->pitches[0] | I915_TILING_X;
 
-	mode_cmd.pixel_format = fb->pixel_format;
+	mode_cmd.pixel_format = fb->format->format;
 	mode_cmd.width = fb->width;
 	mode_cmd.height = fb->height;
 	mode_cmd.pitches[0] = fb->pitches[0];
@@ -2976,7 +2976,7 @@ int skl_check_plane_surface(struct intel_plane_state *plane_state)
 	 * Handle the AUX surface first since
 	 * the main surface setup depends on it.
 	 */
-	if (fb->pixel_format == DRM_FORMAT_NV12) {
+	if (fb->format->format == DRM_FORMAT_NV12) {
 		ret = skl_check_nv12_aux_surface(plane_state);
 		if (ret)
 			return ret;
@@ -3031,7 +3031,7 @@ static void i9xx_update_primary_plane(struct drm_plane *primary,
 		I915_WRITE(PRIMCNSTALPHA(plane), 0);
 	}
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_C8:
 		dspcntr |= DISPPLANE_8BPP;
 		break;
@@ -3146,7 +3146,7 @@ static void ironlake_update_primary_plane(struct drm_plane *primary,
 	if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
 		dspcntr |= DISPPLANE_PIPE_CSC_ENABLE;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_C8:
 		dspcntr |= DISPPLANE_8BPP;
 		break;
@@ -3282,7 +3282,7 @@ u32 skl_plane_stride(const struct drm_framebuffer *fb, int plane,
 		stride /= intel_tile_height(dev_priv, fb->modifier, cpp);
 	} else {
 		stride /= intel_fb_stride_alignment(dev_priv, fb->modifier,
-						    fb->pixel_format);
+						    fb->format->format);
 	}
 
 	return stride;
@@ -3396,7 +3396,7 @@ static void skylake_update_primary_plane(struct drm_plane *plane,
 		    PLANE_CTL_PIPE_GAMMA_ENABLE |
 		    PLANE_CTL_PIPE_CSC_ENABLE;
 
-	plane_ctl |= skl_plane_ctl_format(fb->pixel_format);
+	plane_ctl |= skl_plane_ctl_format(fb->format->format);
 	plane_ctl |= skl_plane_ctl_tiling(fb->modifier);
 	plane_ctl |= PLANE_CTL_PLANE_GAMMA_DISABLE;
 	plane_ctl |= skl_plane_ctl_rotation(rotation);
@@ -4768,7 +4768,7 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
 	}
 
 	/* Check src format */
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_RGB565:
 	case DRM_FORMAT_XBGR8888:
 	case DRM_FORMAT_XRGB8888:
@@ -4784,7 +4784,7 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
 	default:
 		DRM_DEBUG_KMS("[PLANE:%d:%s] FB:%d unsupported scaling format 0x%x\n",
 			      intel_plane->base.base.id, intel_plane->base.name,
-			      fb->base.id, fb->pixel_format);
+			      fb->base.id, fb->format->format);
 		return -EINVAL;
 	}
 
@@ -8714,7 +8714,6 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
 
 	pixel_format = val & DISPPLANE_PIXFORMAT_MASK;
 	fourcc = i9xx_format_to_fourcc(pixel_format);
-	fb->pixel_format = fourcc;
 	fb->format = drm_format_info(fourcc);
 
 	if (INTEL_GEN(dev_priv) >= 4) {
@@ -8736,7 +8735,7 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
 	fb->pitches[0] = val & 0xffffffc0;
 
 	aligned_height = intel_fb_align_height(dev, fb->height,
-					       fb->pixel_format,
+					       fb->format->format,
 					       fb->modifier);
 
 	plane_config->size = fb->pitches[0] * aligned_height;
@@ -9745,7 +9744,6 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
 	fourcc = skl_format_to_fourcc(pixel_format,
 				      val & PLANE_CTL_ORDER_RGBX,
 				      val & PLANE_CTL_ALPHA_MASK);
-	fb->pixel_format = fourcc;
 	fb->format = drm_format_info(fourcc);
 
 	tiling = val & PLANE_CTL_TILED_MASK;
@@ -9779,11 +9777,11 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
 
 	val = I915_READ(PLANE_STRIDE(pipe, 0));
 	stride_mult = intel_fb_stride_alignment(dev_priv, fb->modifier,
-						fb->pixel_format);
+						fb->format->format);
 	fb->pitches[0] = (val & 0x3ff) * stride_mult;
 
 	aligned_height = intel_fb_align_height(dev, fb->height,
-					       fb->pixel_format,
+					       fb->format->format,
 					       fb->modifier);
 
 	plane_config->size = fb->pitches[0] * aligned_height;
@@ -9860,7 +9858,6 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
 
 	pixel_format = val & DISPPLANE_PIXFORMAT_MASK;
 	fourcc = i9xx_format_to_fourcc(pixel_format);
-	fb->pixel_format = fourcc;
 	fb->format = drm_format_info(fourcc);
 
 	base = I915_READ(DSPSURF(pipe)) & 0xfffff000;
@@ -9882,7 +9879,7 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
 	fb->pitches[0] = val & 0xffffffc0;
 
 	aligned_height = intel_fb_align_height(dev, fb->height,
-					       fb->pixel_format,
+					       fb->format->format,
 					       fb->modifier);
 
 	plane_config->size = fb->pitches[0] * aligned_height;
@@ -12151,7 +12148,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 		return -EBUSY;
 
 	/* Can't change pixel format via MI display flips. */
-	if (fb->pixel_format != crtc->primary->fb->pixel_format)
+	if (fb->format->format != crtc->primary->fb->format->format)
 		return -EINVAL;
 
 	/*
@@ -12845,7 +12842,7 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,
 		DRM_DEBUG_KMS("[PLANE:%d:%s] FB:%d, fb = %ux%u format = %s\n",
 			      plane->base.id, plane->name,
 			      fb->base.id, fb->width, fb->height,
-			      drm_get_format_name(fb->pixel_format, &format_name));
+			      drm_get_format_name(fb->format->format, &format_name));
 		if (INTEL_GEN(dev_priv) >= 9)
 			DRM_DEBUG_KMS("\tscaler:%d src %dx%d+%d+%d dst %dx%d+%d+%d\n",
 				      state->scaler_id,
drivers/gpu/drm/i915/intel_fbdev.c +1 -1
index 3f60a4f6f078..570c07d59d1a 100644
@@ -632,7 +632,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 
 		cur_size = intel_crtc->config->base.adjusted_mode.crtc_vdisplay;
 		cur_size = intel_fb_align_height(dev, cur_size,
-						 fb->base.pixel_format,
+						 fb->base.format->format,
 						 fb->base.modifier);
 		cur_size *= fb->base.pitches[0];
 		DRM_DEBUG_KMS("pipe %c area: %dx%d, bpp: %d, size: %d\n",
drivers/gpu/drm/i915/intel_overlay.c +1 -1
index ce3667c18e18..568d194435fd 100644
@@ -667,7 +667,7 @@ static void update_colorkey(struct intel_overlay *overlay,
 	if (overlay->color_key_enabled)
 		flags |= DST_KEY_ENABLE;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_C8:
 		key = 0;
 		flags |= CLK_RGB8I_MASK;
drivers/gpu/drm/i915/intel_pm.c +5 -5
index f94fe998b0ee..5f35bd7131e1 100644
@@ -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];
 
drivers/gpu/drm/i915/intel_sprite.c +6 -6
index b46c1794d3ac..ff766c0cb873 100644
@@ -223,7 +223,7 @@ skl_update_plane(struct drm_plane *drm_plane,
 		PLANE_CTL_PIPE_GAMMA_ENABLE |
 		PLANE_CTL_PIPE_CSC_ENABLE;
 
-	plane_ctl |= skl_plane_ctl_format(fb->pixel_format);
+	plane_ctl |= skl_plane_ctl_format(fb->format->format);
 	plane_ctl |= skl_plane_ctl_tiling(fb->modifier);
 
 	plane_ctl |= skl_plane_ctl_rotation(rotation);
@@ -357,7 +357,7 @@ vlv_update_plane(struct drm_plane *dplane,
 
 	sprctl = SP_ENABLE;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_YUYV:
 		sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_YUYV;
 		break;
@@ -443,7 +443,7 @@ vlv_update_plane(struct drm_plane *dplane,
 		sprctl |= SP_SOURCE_KEY;
 
 	if (IS_CHERRYVIEW(dev_priv) && pipe == PIPE_B)
-		chv_update_csc(intel_plane, fb->pixel_format);
+		chv_update_csc(intel_plane, fb->format->format);
 
 	I915_WRITE(SPSTRIDE(pipe, plane), fb->pitches[0]);
 	I915_WRITE(SPPOS(pipe, plane), (crtc_y << 16) | crtc_x);
@@ -502,7 +502,7 @@ ivb_update_plane(struct drm_plane *plane,
 
 	sprctl = SPRITE_ENABLE;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_XBGR8888:
 		sprctl |= SPRITE_FORMAT_RGBX888 | SPRITE_RGB_ORDER_RGBX;
 		break;
@@ -640,7 +640,7 @@ ilk_update_plane(struct drm_plane *plane,
 
 	dvscntr = DVS_ENABLE;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_XBGR8888:
 		dvscntr |= DVS_FORMAT_RGBX888 | DVS_RGB_ORDER_XBGR;
 		break;
@@ -866,7 +866,7 @@ intel_check_sprite_plane(struct drm_plane *plane,
 		src_y = src->y1 >> 16;
 		src_h = drm_rect_height(src) >> 16;
 
-		if (format_is_yuv(fb->pixel_format)) {
+		if (format_is_yuv(fb->format->format)) {
 			src_x &= ~1;
 			src_w &= ~1;
 
drivers/gpu/drm/imx/ipuv3-plane.c +17 -17
index f44a83656310..0b945f077344 100644
@@ -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,
drivers/gpu/drm/mediatek/mtk_drm_plane.c +1 -1
index 71421923c592..e405e89ed5e5 100644
@@ -133,7 +133,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
 	mtk_gem = to_mtk_gem_obj(gem);
 	addr = mtk_gem->dma_addr;
 	pitch = fb->pitches[0];
-	format = fb->pixel_format;
+	format = fb->format->format;
 
 	addr += (plane->state->src.x1 >> 16) * fb->format->cpp[0];
 	addr += (plane->state->src.y1 >> 16) * pitch;
drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c +1 -1
index 911e4690d36a..53619d07677e 100644
@@ -43,7 +43,7 @@ enum mdp4_frame_format mdp4_get_frame_format(struct drm_framebuffer *fb)
 	if (fb->modifier == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE)
 		is_tile = true;
 
-	if (fb->pixel_format == DRM_FORMAT_NV12 && is_tile)
+	if (fb->format->format == DRM_FORMAT_NV12 && is_tile)
 		return FRAME_TILE_YCBCR_420;
 
 	return FRAME_LINEAR;
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +1 -1
index 8c985c8e23f2..b90e9e497260 100644
@@ -340,7 +340,7 @@ static int mdp5_plane_atomic_check(struct drm_plane *plane,
 	if (plane_enabled(state) && plane_enabled(old_state)) {
 		/* we cannot change SMP block configuration during scanout: */
 		bool full_modeset = false;
-		if (state->fb->pixel_format != old_state->fb->pixel_format) {
+		if (state->fb->format->format != old_state->fb->format->format) {
 			DBG("%s: pixel_format change!", mdp5_plane->name);
 			full_modeset = true;
 		}
drivers/gpu/drm/msm/msm_fb.c +1 -1
index 5cad5e9a07c9..a39c91569d58 100644
@@ -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++) {
drivers/gpu/drm/nouveau/dispnv04/overlay.c +4 -4
index a79514d440b3..6275c270df25 100644
@@ -145,16 +145,16 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	nvif_wr32(dev, NV_PVIDEO_POINT_OUT(flip), crtc_y << 16 | crtc_x);
 	nvif_wr32(dev, NV_PVIDEO_SIZE_OUT(flip), crtc_h << 16 | crtc_w);
 
-	if (fb->pixel_format != DRM_FORMAT_UYVY)
+	if (fb->format->format != DRM_FORMAT_UYVY)
 		format |= NV_PVIDEO_FORMAT_COLOR_LE_CR8YB8CB8YA8;
-	if (fb->pixel_format == DRM_FORMAT_NV12)
+	if (fb->format->format == DRM_FORMAT_NV12)
 		format |= NV_PVIDEO_FORMAT_PLANAR;
 	if (nv_plane->iturbt_709)
 		format |= NV_PVIDEO_FORMAT_MATRIX_ITURBT709;
 	if (nv_plane->colorkey & (1 << 24))
 		format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY;
 
-	if (fb->pixel_format == DRM_FORMAT_NV12) {
+	if (fb->format->format == DRM_FORMAT_NV12) {
 		nvif_wr32(dev, NV_PVIDEO_UVPLANE_BASE(flip), 0);
 		nvif_wr32(dev, NV_PVIDEO_UVPLANE_OFFSET_BUFF(flip),
 			nv_fb->nvbo->bo.offset + fb->offsets[1]);
@@ -411,7 +411,7 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 
 	if (nv_plane->colorkey & (1 << 24))
 		overlay |= 0x10;
-	if (fb->pixel_format == DRM_FORMAT_YUYV)
+	if (fb->format->format == DRM_FORMAT_YUYV)
 		overlay |= 0x100;
 
 	nvif_wr32(dev, NV_PVIDEO_OVERLAY, overlay);
drivers/gpu/drm/nouveau/nv50_display.c +2 -2
index d3bd428023ea..4fd313ee46b3 100644
@@ -1153,7 +1153,7 @@ nv50_curs_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
 	if (asyw->state.fb->width != asyw->state.fb->height)
 		return -EINVAL;
 
-	switch (asyw->state.fb->pixel_format) {
+	switch (asyw->state.fb->format->format) {
 	case DRM_FORMAT_ARGB8888: asyh->curs.format = 1; break;
 	default:
 		WARN_ON(1);
@@ -1438,7 +1438,7 @@ nv50_base_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
 	asyh->base.w = asyw->state.fb->width;
 	asyh->base.h = asyw->state.fb->height;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_C8         : asyw->image.format = 0x1e; break;
 	case DRM_FORMAT_RGB565     : asyw->image.format = 0xe8; break;
 	case DRM_FORMAT_XRGB1555   :
drivers/gpu/drm/omapdrm/omap_fb.c +1 -1
index c6ef457b9fca..bd6b94c38613 100644
@@ -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];
drivers/gpu/drm/radeon/atombios_crtc.c +4 -4
index 0d7f84f7d71d..3c492a0aa6bd 100644
@@ -1195,7 +1195,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 	radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL);
 	radeon_bo_unreserve(rbo);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_8BPP) |
 			     EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_INDEXED));
@@ -1261,7 +1261,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
@@ -1511,7 +1511,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
 	radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL);
 	radeon_bo_unreserve(rbo);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format =
 		    AVIVO_D1GRPH_CONTROL_DEPTH_8BPP |
@@ -1564,7 +1564,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
drivers/gpu/drm/rcar-du/rcar_du_plane.c +2 -2
index a74f8ed8ca2e..dcde6288da6c 100644
@@ -567,10 +567,10 @@ static int rcar_du_plane_atomic_check(struct drm_plane *plane,
 		return -EINVAL;
 	}
 
-	rstate->format = rcar_du_format_info(state->fb->pixel_format);
+	rstate->format = rcar_du_format_info(state->fb->format->format);
 	if (rstate->format == NULL) {
 		dev_dbg(rcdu->dev, "%s: unsupported format %08x\n", __func__,
-			state->fb->pixel_format);
+			state->fb->format->format);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +2 -2
index 83ebd162f3ef..b5bfbe50bd87 100644
@@ -201,10 +201,10 @@ static int rcar_du_vsp_plane_atomic_check(struct drm_plane *plane,
 		return -EINVAL;
 	}
 
-	rstate->format = rcar_du_format_info(state->fb->pixel_format);
+	rstate->format = rcar_du_format_info(state->fb->format->format);
 	if (rstate->format == NULL) {
 		dev_dbg(rcdu->dev, "%s: unsupported format %08x\n", __func__,
-			state->fb->pixel_format);
+			state->fb->format->format);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9 -9
index 50e085e74214..fb5f001f51c3 100644
@@ -668,7 +668,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
 	if (!state->visible)
 		return 0;
 
-	ret = vop_convert_format(fb->pixel_format);
+	ret = vop_convert_format(fb->format->format);
 	if (ret < 0)
 		return ret;
 
@@ -676,7 +676,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
 	 * Src.x1 can be odd when do clip, but yuv plane start point
 	 * need align with 2 pixel.
 	 */
-	if (is_yuv_support(fb->pixel_format) && ((state->src.x1 >> 16) % 2))
+	if (is_yuv_support(fb->format->format) && ((state->src.x1 >> 16) % 2))
 		return -EINVAL;
 
 	return 0;
@@ -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) |
drivers/gpu/drm/shmobile/shmob_drm_crtc.c +3 -3
index 6547b1db460a..2494410435a1 100644
@@ -174,7 +174,7 @@ static void shmob_drm_crtc_start(struct shmob_drm_crtc *scrtc)
 	if (scrtc->started)
 		return;
 
-	format = shmob_drm_format_info(crtc->primary->fb->pixel_format);
+	format = shmob_drm_format_info(crtc->primary->fb->format->format);
 	if (WARN_ON(format == NULL))
 		return;
 
@@ -376,10 +376,10 @@ static int shmob_drm_crtc_mode_set(struct drm_crtc *crtc,
 	const struct shmob_drm_format_info *format;
 	void *cache;
 
-	format = shmob_drm_format_info(crtc->primary->fb->pixel_format);
+	format = shmob_drm_format_info(crtc->primary->fb->format->format);
 	if (format == NULL) {
 		dev_dbg(sdev->dev, "mode_set: unsupported format %08x\n",
-			crtc->primary->fb->pixel_format);
+			crtc->primary->fb->format->format);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/shmobile/shmob_drm_plane.c +2 -2
index 1805bb23b113..2023a93cee2b 100644
@@ -183,10 +183,10 @@ shmob_drm_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 	struct shmob_drm_device *sdev = plane->dev->dev_private;
 	const struct shmob_drm_format_info *format;
 
-	format = shmob_drm_format_info(fb->pixel_format);
+	format = shmob_drm_format_info(fb->format->format);
 	if (format == NULL) {
 		dev_dbg(sdev->dev, "update_plane: unsupported format %08x\n",
-			fb->pixel_format);
+			fb->format->format);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/sti/sti_gdp.c +4 -4
index 58316bd6d7d6..877d053d86f4 100644
@@ -636,10 +636,10 @@ static int sti_gdp_atomic_check(struct drm_plane *drm_plane,
 	src_w = clamp_val(state->src_w >> 16, 0, GAM_GDP_SIZE_MAX);
 	src_h = clamp_val(state->src_h >> 16, 0, GAM_GDP_SIZE_MAX);
 
-	format = sti_gdp_fourcc2format(fb->pixel_format);
+	format = sti_gdp_fourcc2format(fb->format->format);
 	if (format == -1) {
 		DRM_ERROR("Format not supported by GDP %.4s\n",
-			  (char *)&fb->pixel_format);
+			  (char *)&fb->format->format);
 		return -EINVAL;
 	}
 
@@ -745,7 +745,7 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
 	/* build the top field */
 	top_field->gam_gdp_agc = GAM_GDP_AGC_FULL_RANGE;
 	top_field->gam_gdp_ctl = WAIT_NEXT_VSYNC;
-	format = sti_gdp_fourcc2format(fb->pixel_format);
+	format = sti_gdp_fourcc2format(fb->format->format);
 	top_field->gam_gdp_ctl |= format;
 	top_field->gam_gdp_ctl |= sti_gdp_get_alpharange(format);
 	top_field->gam_gdp_ppt &= ~GAM_GDP_PPT_IGNORE;
@@ -753,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 */
drivers/gpu/drm/sti/sti_hqvdp.c +1 -1
index f88130f2eb48..becf10d255c4 100644
@@ -1147,7 +1147,7 @@ static void sti_hqvdp_atomic_update(struct drm_plane *drm_plane,
 	cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
 
 	DRM_DEBUG_DRIVER("drm FB:%d format:%.4s phys@:0x%lx\n", fb->base.id,
-			 (char *)&fb->pixel_format,
+			 (char *)&fb->format->format,
 			 (unsigned long)cma_obj->paddr);
 
 	/* Buffer planes address */
drivers/gpu/drm/sun4i/sun4i_backend.c +2 -1
index a606207d4e25..a278e1f44661 100644
@@ -189,7 +189,8 @@ int sun4i_backend_update_layer_formats(struct sun4i_backend *backend,
 	DRM_DEBUG_DRIVER("Switching display backend interlaced mode %s\n",
 			 interlaced ? "on" : "off");
 
-	ret = sun4i_backend_drm_format_to_layer(plane, fb->pixel_format, &val);
+	ret = sun4i_backend_drm_format_to_layer(plane, fb->format->format,
+						&val);
 	if (ret) {
 		DRM_DEBUG_DRIVER("Invalid format\n");
 		return val;
drivers/gpu/drm/tegra/dc.c +1 -1
index 642dcff87e34..7561a95a54e3 100644
@@ -511,7 +511,7 @@ static int tegra_plane_atomic_check(struct drm_plane *plane,
 	if (!state->crtc)
 		return 0;
 
-	err = tegra_dc_format(state->fb->pixel_format, &plane_state->format,
+	err = tegra_dc_format(state->fb->format->format, &plane_state->format,
 			      &plane_state->swap);
 	if (err < 0)
 		return err;
drivers/gpu/drm/tilcdc/tilcdc_crtc.c +1 -1
index 38972e3d652e..f10499ab4bec 100644
@@ -459,7 +459,7 @@ static void tilcdc_crtc_mode_set_nofb(struct drm_crtc *crtc)
 	if (info->tft_alt_mode)
 		reg |= LCDC_TFT_ALT_ENABLE;
 	if (priv->rev == 2) {
-		switch (fb->pixel_format) {
+		switch (fb->format->format) {
 		case DRM_FORMAT_BGR565:
 		case DRM_FORMAT_RGB565:
 			break;
drivers/gpu/drm/tilcdc/tilcdc_plane.c +1 -1
index c0fc874e91cf..4b7519dfd1b9 100644
@@ -77,7 +77,7 @@ static int tilcdc_plane_atomic_check(struct drm_plane *plane,
 	}
 
 	if (state->fb && old_state->fb &&
-	    state->fb->pixel_format != old_state->fb->pixel_format) {
+	    state->fb->format->format != old_state->fb->format->format) {
 		dev_dbg(plane->dev->dev,
 			"%s(): pixel format change requires mode_change\n",
 			__func__);
drivers/gpu/drm/vc4/vc4_plane.c +2 -2
index f84f6bddd015..110d1518f5d5 100644
@@ -295,7 +295,7 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
 	struct drm_framebuffer *fb = state->fb;
 	struct drm_gem_cma_object *bo = drm_fb_cma_get_gem_obj(fb, 0);
 	u32 subpixel_src_mask = (1 << 16) - 1;
-	u32 format = fb->pixel_format;
+	u32 format = fb->format->format;
 	int num_planes = 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;
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0 -2
index eb8e36462961..91e30c9abff0 100644
@@ -590,7 +590,6 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
 	vfbs->base.base.dev = dev;
 	/* XXX get the first 4 from the surface info */
 	vfbs->base.base.format = drm_format_info(pixel_format);
-	vfbs->base.base.pixel_format = pixel_format;
 	vfbs->base.base.pitches[0] = mode_cmd->pitch;
 	vfbs->base.base.width = mode_cmd->width;
 	vfbs->base.base.height = mode_cmd->height;
@@ -897,7 +896,6 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
 
 	vfbd->base.base.dev = dev;
 	vfbd->base.base.format = drm_format_info(pixel_format);
-	vfbd->base.base.pixel_format = pixel_format;
 	vfbd->base.base.pitches[0] = mode_cmd->pitch;
 	vfbd->base.base.width = mode_cmd->width;
 	vfbd->base.base.height = mode_cmd->height;
drivers/gpu/drm/zte/zx_plane.c +1 -1
index 72d27b0a48b2..b634b090cdc1 100644
@@ -146,7 +146,7 @@ static void zx_gl_plane_atomic_update(struct drm_plane *plane,
 	if (!fb)
 		return;
 
-	format = fb->pixel_format;
+	format = fb->format->format;
 	stride = fb->pitches[0];
 
 	src_x = plane->state->src_x >> 16;
include/drm/drm_framebuffer.h +0 -4
index 4efc5066475a..2734a87b2120 100644
@@ -175,10 +175,6 @@ struct drm_framebuffer {
 	 */
 	int flags;
 	/**
-	 * @pixel_format: DRM FOURCC code describing the pixel format.
-	 */
-	uint32_t pixel_format; /* fourcc format */
-	/**
 	 * @hot_x: X coordinate of the cursor hotspot. Used by the legacy cursor
 	 * IOCTL when the driver supports cursor through a DRM_PLANE_TYPE_CURSOR
 	 * universal plane.
Signature · 6 lines
2.7.4

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

Re: [PATCH v2 33/37] drm: Nuke fb->pixel_format

Hi Ville,

Thank you for the patch.

Quoted 110 lines · On Friday 18 Nov 2016 21:53:09 [email protected] wrote:

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

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(...) {
	...
(quoted diff) +0 -1
-	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(...) {
	...
(quoted diff) +0 -1
-	fb->pixel_format = E;
...
 }

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

 ironlake_get_initial_plane_config(...) {
	...
(quoted diff) +0 -1
-	fb->pixel_format = E;
...
 }

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

 skylake_get_initial_plane_config(...) {
	...
(quoted diff) +0 -1
-	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 {
	 ...
(quoted diff) +0 -1
-	 uint32_t pixel_format;
...
 };
Quoted 8 lines

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
Quoted 55 lines
---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c          |  4 +--
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c          |  4 +--
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c           |  4 +--
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c           |  4 +--
 drivers/gpu/drm/arc/arcpgu_crtc.c               |  2 +-
 drivers/gpu/drm/arm/hdlcd_crtc.c                |  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(-)
Signature · 8 lines
Regards,

Laurent Pinchart

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

PATCH v3 33/37 drm: Nuke fb->pixel_format

In reply to [email protected]

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

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

---
 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(-)
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +2 -2
index 8d0ff1c8db8e..84afaae97e65 100644
@@ -2072,7 +2072,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,
 
 	pipe_config = AMDGPU_TILING_GET(tiling_flags, PIPE_CONFIG);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format = REG_SET_FIELD(0, GRPH_CONTROL, GRPH_DEPTH, 0);
 		fb_format = REG_SET_FIELD(fb_format, GRPH_CONTROL, GRPH_FORMAT, 0);
@@ -2145,7 +2145,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +2 -2
index c25edecb46d4..7a7fa96d2e49 100644
@@ -2053,7 +2053,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,
 
 	pipe_config = AMDGPU_TILING_GET(tiling_flags, PIPE_CONFIG);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format = REG_SET_FIELD(0, GRPH_CONTROL, GRPH_DEPTH, 0);
 		fb_format = REG_SET_FIELD(fb_format, GRPH_CONTROL, GRPH_FORMAT, 0);
@@ -2126,7 +2126,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2 -2
index ffd20f90788c..59eff6e9a883 100644
@@ -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;
 	}
 
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +2 -2
index e6f446af3818..8de832dd981d 100644
@@ -1950,7 +1950,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
 
 	pipe_config = AMDGPU_TILING_GET(tiling_flags, PIPE_CONFIG);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format = ((GRPH_DEPTH_8BPP << GRPH_CONTROL__GRPH_DEPTH__SHIFT) |
 			     (GRPH_FORMAT_INDEXED << GRPH_CONTROL__GRPH_FORMAT__SHIFT));
@@ -2016,7 +2016,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
drivers/gpu/drm/arc/arcpgu_crtc.c +1 -1
index 5c26c5f126a3..ad9a95916f1f 100644
@@ -36,7 +36,7 @@ static void arc_pgu_set_pxl_fmt(struct drm_crtc *crtc)
 {
 	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
 	const struct drm_framebuffer *fb = crtc->primary->state->fb;
-	uint32_t pixel_format = fb->pixel_format;
+	uint32_t pixel_format = fb->format->format;
 	struct simplefb_format *format = NULL;
 	int i;
 
drivers/gpu/drm/arm/hdlcd_crtc.c +1 -1
index ecdcd99c92cc..20ebfb4fbdfa 100644
@@ -65,7 +65,7 @@ static int hdlcd_set_pxl_fmt(struct drm_crtc *crtc)
 	struct simplefb_format *format = NULL;
 	int i;
 
-	pixel_format = fb->pixel_format;
+	pixel_format = fb->format->format;
 
 	for (i = 0; i < ARRAY_SIZE(supported_formats); i++) {
 		if (supported_formats[i].fourcc == pixel_format)
drivers/gpu/drm/arm/malidp_planes.c +4 -4
index 533ee2fa64be..eff2fe47e26a 100644
@@ -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;
 
drivers/gpu/drm/armada/armada_crtc.c +1 -1
index 426e86f4cf96..41fc6ee9da91 100644
@@ -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);
drivers/gpu/drm/armada/armada_overlay.c +1 -1
index a0883a1b3387..34cb73d0db77 100644
@@ -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;
 
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +9 -9
index 3e00512ef187..bd2791c4b002 100644
@@ -356,7 +356,7 @@ atmel_hlcdc_plane_update_general_settings(struct atmel_hlcdc_plane *plane,
 		cfg |= ATMEL_HLCDC_LAYER_OVR | ATMEL_HLCDC_LAYER_ITER2BL |
 		       ATMEL_HLCDC_LAYER_ITER;
 
-		if (atmel_hlcdc_format_embeds_alpha(state->base.fb->pixel_format))
+		if (atmel_hlcdc_format_embeds_alpha(state->base.fb->format->format))
 			cfg |= ATMEL_HLCDC_LAYER_LAEN;
 		else
 			cfg |= ATMEL_HLCDC_LAYER_GAEN |
@@ -386,13 +386,13 @@ static void atmel_hlcdc_plane_update_format(struct atmel_hlcdc_plane *plane,
 	u32 cfg;
 	int ret;
 
-	ret = atmel_hlcdc_format_to_plane_mode(state->base.fb->pixel_format,
+	ret = atmel_hlcdc_format_to_plane_mode(state->base.fb->format->format,
 					       &cfg);
 	if (ret)
 		return;
 
-	if ((state->base.fb->pixel_format == DRM_FORMAT_YUV422 ||
-	     state->base.fb->pixel_format == DRM_FORMAT_NV61) &&
+	if ((state->base.fb->format->format == DRM_FORMAT_YUV422 ||
+	     state->base.fb->format->format == DRM_FORMAT_NV61) &&
 	    drm_rotation_90_or_270(state->base.rotation))
 		cfg |= ATMEL_HLCDC_YUV422ROT;
 
@@ -405,7 +405,7 @@ static void atmel_hlcdc_plane_update_format(struct atmel_hlcdc_plane *plane,
 	 * Rotation optimization is not working on RGB888 (rotation is still
 	 * working but without any optimization).
 	 */
-	if (state->base.fb->pixel_format == DRM_FORMAT_RGB888)
+	if (state->base.fb->format->format == DRM_FORMAT_RGB888)
 		cfg = ATMEL_HLCDC_LAYER_DMA_ROTDIS;
 	else
 		cfg = 0;
@@ -514,7 +514,7 @@ atmel_hlcdc_plane_prepare_disc_area(struct drm_crtc_state *c_state)
 		ovl_state = drm_plane_state_to_atmel_hlcdc_plane_state(ovl_s);
 
 		if (!ovl_s->fb ||
-		    atmel_hlcdc_format_embeds_alpha(ovl_s->fb->pixel_format) ||
+		    atmel_hlcdc_format_embeds_alpha(ovl_s->fb->format->format) ||
 		    ovl_state->alpha != 255)
 			continue;
 
@@ -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)
drivers/gpu/drm/drm_atomic.c +3 -3
index 62f0f57728e1..b602faf28367 100644
@@ -902,11 +902,11 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
 	}
 
 	/* Check whether this plane supports the fb pixel format. */
-	ret = drm_plane_check_pixel_format(plane, state->fb->pixel_format);
+	ret = drm_plane_check_pixel_format(plane, state->fb->format->format);
 	if (ret) {
 		struct drm_format_name_buf format_name;
 		DRM_DEBUG_ATOMIC("Invalid pixel format %s\n",
-		                 drm_get_format_name(state->fb->pixel_format,
+		                 drm_get_format_name(state->fb->format->format,
 		                                     &format_name));
 		return ret;
 	}
@@ -964,7 +964,7 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,
 		struct drm_format_name_buf format_name;
 
 		drm_printf(p, "\t\tformat=%s\n",
-		              drm_get_format_name(fb->pixel_format, &format_name));
+		              drm_get_format_name(fb->format->format, &format_name));
 		drm_printf(p, "\t\t\tmodifier=0x%llx\n", fb->modifier);
 		drm_printf(p, "\t\tsize=%dx%d\n", fb->width, fb->height);
 		drm_printf(p, "\t\tlayers:\n");
drivers/gpu/drm/drm_crtc.c +2 -2
index 14c58072651b..080c8d361f1f 100644
@@ -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;
 			}
drivers/gpu/drm/drm_crtc_helper.c +2 -2
index 5d2cb138eba6..94bce0b462aa 100644
@@ -588,8 +588,8 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
 		if (set->crtc->primary->fb == NULL) {
 			DRM_DEBUG_KMS("crtc has no fb, full mode set\n");
 			mode_changed = true;
-		} else if (set->fb->pixel_format !=
-			   set->crtc->primary->fb->pixel_format) {
+		} else if (set->fb->format->format !=
+			   set->crtc->primary->fb->format->format) {
 			mode_changed = true;
 		} else
 			fb_changed = true;
drivers/gpu/drm/drm_fb_cma_helper.c +1 -1
index 181a9eafe34a..aab4465307ed 100644
@@ -307,7 +307,7 @@ static void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file *m)
 	int i;
 
 	seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height,
-			(char *)&fb->pixel_format);
+			(char *)&fb->format->format);
 
 	for (i = 0; i < fb->fomat->num_planes; i++) {
 		seq_printf(m, "   %d: offset=%d pitch=%d, obj: ",
drivers/gpu/drm/drm_modeset_helper.c +0 -1
index 3c44409244dc..639e474e7d43 100644
@@ -94,7 +94,6 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
 		fb->offsets[i] = mode_cmd->offsets[i];
 	}
 	fb->modifier = mode_cmd->modifier[0];
-	fb->pixel_format = mode_cmd->pixel_format;
 	fb->flags = mode_cmd->flags;
 }
 EXPORT_SYMBOL(drm_helper_mode_fill_fb_struct);
drivers/gpu/drm/drm_plane.c +3 -3
index c2dc8e6f80ff..f479cda5fc2d 100644
@@ -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;
drivers/gpu/drm/exynos/exynos5433_drm_decon.c +1 -1
index e8ce4a318586..c5c01628c715 100644
@@ -200,7 +200,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
 	val = readl(ctx->addr + DECON_WINCONx(win));
 	val &= ~WINCONx_BPPMODE_MASK;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_XRGB1555:
 		val |= WINCONx_BPPMODE_16BPP_I1555;
 		val |= WINCONx_HAWSWP_F;
drivers/gpu/drm/exynos/exynos7_drm_decon.c +1 -1
index 58dc9a5196bc..f9ab19e205e2 100644
@@ -281,7 +281,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
 	val = readl(ctx->regs + WINCON(win));
 	val &= ~WINCONx_BPPMODE_MASK;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_RGB565:
 		val |= WINCONx_BPPMODE_16BPP_565;
 		val |= WINCONx_BURSTLEN_16WORD;
drivers/gpu/drm/exynos/exynos_drm_fimd.c +1 -1
index 0029065979b8..745cfbdf6b39 100644
@@ -804,7 +804,7 @@ static void fimd_update_plane(struct exynos_drm_crtc *crtc,
 		DRM_DEBUG_KMS("osd size = 0x%x\n", (unsigned int)val);
 	}
 
-	fimd_win_set_pixfmt(ctx, win, fb->pixel_format, state->src.w);
+	fimd_win_set_pixfmt(ctx, win, fb->format->format, state->src.w);
 
 	/* hardware window 0 doesn't support color key. */
 	if (win != 0)
drivers/gpu/drm/exynos/exynos_mixer.c +4 -4
index b313e61aab65..a106046e0c93 100644
@@ -485,7 +485,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
 	bool crcb_mode = false;
 	u32 val;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_NV12:
 		crcb_mode = false;
 		break;
@@ -494,7 +494,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
 		break;
 	default:
 		DRM_ERROR("pixel format for vp is wrong [%d].\n",
-				fb->pixel_format);
+				fb->format->format);
 		return;
 	}
 
@@ -597,7 +597,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
 	unsigned int fmt;
 	u32 val;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_XRGB4444:
 	case DRM_FORMAT_ARGB4444:
 		fmt = MXR_FORMAT_ARGB4444;
@@ -681,7 +681,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
 	mixer_cfg_scan(ctx, mode->vdisplay);
 	mixer_cfg_rgb_fmt(ctx, mode->vdisplay);
 	mixer_cfg_layer(ctx, win, priority, true);
-	mixer_cfg_gfx_blend(ctx, win, is_alpha_format(fb->pixel_format));
+	mixer_cfg_gfx_blend(ctx, win, is_alpha_format(fb->format->format));
 
 	/* layer update mandatory for mixer 16.0.33.0 */
 	if (ctx->mxr_ver == MXR_VER_16_0_33_0 ||
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c +2 -2
index a99f48847420..0a20723aa6e1 100644
@@ -44,7 +44,7 @@ static int fsl_dcu_drm_plane_atomic_check(struct drm_plane *plane,
 	if (!state->fb || !state->crtc)
 		return 0;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_RGB565:
 	case DRM_FORMAT_RGB888:
 	case DRM_FORMAT_XRGB8888:
@@ -96,7 +96,7 @@ static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane,
 
 	gem = drm_fb_cma_get_gem_obj(fb, 0);
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_RGB565:
 		bpp = FSL_DCU_RGB565;
 		break;
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +3 -3
index 3ea70459b901..307d460ab684 100644
@@ -617,7 +617,7 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb,
 			 ch + 1, y, in_h, stride, (u32)obj->paddr);
 	DRM_DEBUG_DRIVER("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n",
 			 addr, fb->width, fb->height, fmt,
-			 drm_get_format_name(fb->pixel_format, &format_name));
+			 drm_get_format_name(fb->format->format, &format_name));
 
 	/* get reg offset */
 	reg_ctrl = RD_CH_CTRL(ch);
@@ -773,7 +773,7 @@ static void ade_update_channel(struct ade_plane *aplane,
 {
 	struct ade_hw_ctx *ctx = aplane->ctx;
 	void __iomem *base = ctx->base;
-	u32 fmt = ade_get_format(fb->pixel_format);
+	u32 fmt = ade_get_format(fb->format->format);
 	u32 ch = aplane->ch;
 	u32 in_w;
 	u32 in_h;
@@ -835,7 +835,7 @@ static int ade_plane_atomic_check(struct drm_plane *plane,
 	if (!crtc || !fb)
 		return 0;
 
-	fmt = ade_get_format(fb->pixel_format);
+	fmt = ade_get_format(fb->format->format);
 	if (fmt == ADE_FORMAT_UNSUPPORT)
 		return -EINVAL;
 
drivers/gpu/drm/i915/i915_debugfs.c +2 -1
index 7eded0561f75..15deb2bc568b 100644
@@ -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");
 		}
drivers/gpu/drm/i915/intel_atomic_plane.c +2 -2
index dbe9fb41ae53..e049838159a1 100644
@@ -155,11 +155,11 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
 		 * RGB 16-bit 5:6:5, and Indexed 8-bit.
 		 * TBD: Add RGB64 case once its added in supported format list.
 		 */
-		switch (state->fb->pixel_format) {
+		switch (state->fb->format->format) {
 		case DRM_FORMAT_C8:
 		case DRM_FORMAT_RGB565:
 			DRM_DEBUG_KMS("Unsupported pixel format %s for 90/270!\n",
-			              drm_get_format_name(state->fb->pixel_format,
+			              drm_get_format_name(state->fb->format->format,
 			                                  &format_name));
 			return -EINVAL;
 
drivers/gpu/drm/i915/intel_display.c +15 -18
index d425d7efb9f8..463984a5a251 100644
@@ -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,
drivers/gpu/drm/i915/intel_fbdev.c +1 -1
index 06afce1eac49..73d02d21c768 100644
@@ -632,7 +632,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 
 		cur_size = intel_crtc->config->base.adjusted_mode.crtc_vdisplay;
 		cur_size = intel_fb_align_height(dev, cur_size,
-						 fb->base.pixel_format,
+						 fb->base.format->format,
 						 fb->base.modifier);
 		cur_size *= fb->base.pitches[0];
 		DRM_DEBUG_KMS("pipe %c area: %dx%d, bpp: %d, size: %d\n",
drivers/gpu/drm/i915/intel_overlay.c +1 -1
index 90bab516e891..489c14ff2cb9 100644
@@ -667,7 +667,7 @@ static void update_colorkey(struct intel_overlay *overlay,
 	if (overlay->color_key_enabled)
 		flags |= DST_KEY_ENABLE;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_C8:
 		key = 0;
 		flags |= CLK_RGB8I_MASK;
drivers/gpu/drm/i915/intel_pm.c +5 -5
index 351476e85452..d0834b3d4fb6 100644
@@ -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];
 
drivers/gpu/drm/i915/intel_sprite.c +6 -6
index c2448471fd93..7031bc733d97 100644
@@ -223,7 +223,7 @@ skl_update_plane(struct drm_plane *drm_plane,
 		PLANE_CTL_PIPE_GAMMA_ENABLE |
 		PLANE_CTL_PIPE_CSC_ENABLE;
 
-	plane_ctl |= skl_plane_ctl_format(fb->pixel_format);
+	plane_ctl |= skl_plane_ctl_format(fb->format->format);
 	plane_ctl |= skl_plane_ctl_tiling(fb->modifier);
 
 	plane_ctl |= skl_plane_ctl_rotation(rotation);
@@ -357,7 +357,7 @@ vlv_update_plane(struct drm_plane *dplane,
 
 	sprctl = SP_ENABLE;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_YUYV:
 		sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_YUYV;
 		break;
@@ -443,7 +443,7 @@ vlv_update_plane(struct drm_plane *dplane,
 		sprctl |= SP_SOURCE_KEY;
 
 	if (IS_CHERRYVIEW(dev_priv) && pipe == PIPE_B)
-		chv_update_csc(intel_plane, fb->pixel_format);
+		chv_update_csc(intel_plane, fb->format->format);
 
 	I915_WRITE(SPSTRIDE(pipe, plane_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;
 
drivers/gpu/drm/imx/ipuv3-plane.c +17 -17
index f44a83656310..0b945f077344 100644
@@ -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,
drivers/gpu/drm/mediatek/mtk_drm_plane.c +1 -1
index 71421923c592..e405e89ed5e5 100644
@@ -133,7 +133,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
 	mtk_gem = to_mtk_gem_obj(gem);
 	addr = mtk_gem->dma_addr;
 	pitch = fb->pitches[0];
-	format = fb->pixel_format;
+	format = fb->format->format;
 
 	addr += (plane->state->src.x1 >> 16) * fb->format->cpp[0];
 	addr += (plane->state->src.y1 >> 16) * pitch;
drivers/gpu/drm/meson/meson_plane.c +1 -1
index 4942ca090b46..642b2fab42ff 100644
@@ -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,
drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c +1 -1
index 911e4690d36a..53619d07677e 100644
@@ -43,7 +43,7 @@ enum mdp4_frame_format mdp4_get_frame_format(struct drm_framebuffer *fb)
 	if (fb->modifier == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE)
 		is_tile = true;
 
-	if (fb->pixel_format == DRM_FORMAT_NV12 && is_tile)
+	if (fb->format->format == DRM_FORMAT_NV12 && is_tile)
 		return FRAME_TILE_YCBCR_420;
 
 	return FRAME_LINEAR;
drivers/gpu/drm/msm/msm_fb.c +1 -1
index 0649863d7fd7..5cf165c9c3a9 100644
@@ -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++) {
drivers/gpu/drm/mxsfb/mxsfb_crtc.c +1 -1
index 081890336ce7..e10a4eda4078 100644
@@ -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;
drivers/gpu/drm/nouveau/dispnv04/overlay.c +4 -4
index a79514d440b3..6275c270df25 100644
@@ -145,16 +145,16 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	nvif_wr32(dev, NV_PVIDEO_POINT_OUT(flip), crtc_y << 16 | crtc_x);
 	nvif_wr32(dev, NV_PVIDEO_SIZE_OUT(flip), crtc_h << 16 | crtc_w);
 
-	if (fb->pixel_format != DRM_FORMAT_UYVY)
+	if (fb->format->format != DRM_FORMAT_UYVY)
 		format |= NV_PVIDEO_FORMAT_COLOR_LE_CR8YB8CB8YA8;
-	if (fb->pixel_format == DRM_FORMAT_NV12)
+	if (fb->format->format == DRM_FORMAT_NV12)
 		format |= NV_PVIDEO_FORMAT_PLANAR;
 	if (nv_plane->iturbt_709)
 		format |= NV_PVIDEO_FORMAT_MATRIX_ITURBT709;
 	if (nv_plane->colorkey & (1 << 24))
 		format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY;
 
-	if (fb->pixel_format == DRM_FORMAT_NV12) {
+	if (fb->format->format == DRM_FORMAT_NV12) {
 		nvif_wr32(dev, NV_PVIDEO_UVPLANE_BASE(flip), 0);
 		nvif_wr32(dev, NV_PVIDEO_UVPLANE_OFFSET_BUFF(flip),
 			nv_fb->nvbo->bo.offset + fb->offsets[1]);
@@ -411,7 +411,7 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 
 	if (nv_plane->colorkey & (1 << 24))
 		overlay |= 0x10;
-	if (fb->pixel_format == DRM_FORMAT_YUYV)
+	if (fb->format->format == DRM_FORMAT_YUYV)
 		overlay |= 0x100;
 
 	nvif_wr32(dev, NV_PVIDEO_OVERLAY, overlay);
drivers/gpu/drm/nouveau/nv50_display.c +2 -2
index b617e5d3277a..cb85cb72dc1c 100644
@@ -1153,7 +1153,7 @@ nv50_curs_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
 	if (asyw->state.fb->width != asyw->state.fb->height)
 		return -EINVAL;
 
-	switch (asyw->state.fb->pixel_format) {
+	switch (asyw->state.fb->format->format) {
 	case DRM_FORMAT_ARGB8888: asyh->curs.format = 1; break;
 	default:
 		WARN_ON(1);
@@ -1438,7 +1438,7 @@ nv50_base_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
 	asyh->base.w = asyw->state.fb->width;
 	asyh->base.h = asyw->state.fb->height;
 
-	switch (fb->pixel_format) {
+	switch (fb->format->format) {
 	case DRM_FORMAT_C8         : asyw->image.format = 0x1e; break;
 	case DRM_FORMAT_RGB565     : asyw->image.format = 0xe8; break;
 	case DRM_FORMAT_XRGB1555   :
drivers/gpu/drm/omapdrm/omap_fb.c +1 -1
index c6ef457b9fca..bd6b94c38613 100644
@@ -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];
drivers/gpu/drm/radeon/atombios_crtc.c +4 -4
index 0d7f84f7d71d..3c492a0aa6bd 100644
@@ -1195,7 +1195,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 	radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL);
 	radeon_bo_unreserve(rbo);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_8BPP) |
 			     EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_INDEXED));
@@ -1261,7 +1261,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
@@ -1511,7 +1511,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
 	radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL);
 	radeon_bo_unreserve(rbo);
 
-	switch (target_fb->pixel_format) {
+	switch (target_fb->format->format) {
 	case DRM_FORMAT_C8:
 		fb_format =
 		    AVIVO_D1GRPH_CONTROL_DEPTH_8BPP |
@@ -1564,7 +1564,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
 		break;
 	default:
 		DRM_ERROR("Unsupported screen format %s\n",
-		          drm_get_format_name(target_fb->pixel_format, &format_name));
+		          drm_get_format_name(target_fb->format->format, &format_name));
 		return -EINVAL;
 	}
 
drivers/gpu/drm/rcar-du/rcar_du_plane.c +2 -2
index a74f8ed8ca2e..dcde6288da6c 100644
@@ -567,10 +567,10 @@ static int rcar_du_plane_atomic_check(struct drm_plane *plane,
 		return -EINVAL;
 	}
 
-	rstate->format = rcar_du_format_info(state->fb->pixel_format);
+	rstate->format = rcar_du_format_info(state->fb->format->format);
 	if (rstate->format == NULL) {
 		dev_dbg(rcdu->dev, "%s: unsupported format %08x\n", __func__,
-			state->fb->pixel_format);
+			state->fb->format->format);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +2 -2
index 83ebd162f3ef..b5bfbe50bd87 100644
@@ -201,10 +201,10 @@ static int rcar_du_vsp_plane_atomic_check(struct drm_plane *plane,
 		return -EINVAL;
 	}
 
-	rstate->format = rcar_du_format_info(state->fb->pixel_format);
+	rstate->format = rcar_du_format_info(state->fb->format->format);
 	if (rstate->format == NULL) {
 		dev_dbg(rcdu->dev, "%s: unsupported format %08x\n", __func__,
-			state->fb->pixel_format);
+			state->fb->format->format);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9 -9
index 50e085e74214..fb5f001f51c3 100644
@@ -668,7 +668,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
 	if (!state->visible)
 		return 0;
 
-	ret = vop_convert_format(fb->pixel_format);
+	ret = vop_convert_format(fb->format->format);
 	if (ret < 0)
 		return ret;
 
@@ -676,7 +676,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
 	 * Src.x1 can be odd when do clip, but yuv plane start point
 	 * need align with 2 pixel.
 	 */
-	if (is_yuv_support(fb->pixel_format) && ((state->src.x1 >> 16) % 2))
+	if (is_yuv_support(fb->format->format) && ((state->src.x1 >> 16) % 2))
 		return -EINVAL;
 
 	return 0;
@@ -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) |
drivers/gpu/drm/shmobile/shmob_drm_crtc.c +3 -3
index dddbdd62bed0..445476551695 100644
@@ -174,7 +174,7 @@ static void shmob_drm_crtc_start(struct shmob_drm_crtc *scrtc)
 	if (scrtc->started)
 		return;
 
-	format = shmob_drm_format_info(crtc->primary->fb->pixel_format);
+	format = shmob_drm_format_info(crtc->primary->fb->format->format);
 	if (WARN_ON(format == NULL))
 		return;
 
@@ -376,10 +376,10 @@ static int shmob_drm_crtc_mode_set(struct drm_crtc *crtc,
 	const struct shmob_drm_format_info *format;
 	void *cache;
 
-	format = shmob_drm_format_info(crtc->primary->fb->pixel_format);
+	format = shmob_drm_format_info(crtc->primary->fb->format->format);
 	if (format == NULL) {
 		dev_dbg(sdev->dev, "mode_set: unsupported format %08x\n",
-			crtc->primary->fb->pixel_format);
+			crtc->primary->fb->format->format);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/shmobile/shmob_drm_plane.c +2 -2
index 1805bb23b113..2023a93cee2b 100644
@@ -183,10 +183,10 @@ shmob_drm_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 	struct shmob_drm_device *sdev = plane->dev->dev_private;
 	const struct shmob_drm_format_info *format;
 
-	format = shmob_drm_format_info(fb->pixel_format);
+	format = shmob_drm_format_info(fb->format->format);
 	if (format == NULL) {
 		dev_dbg(sdev->dev, "update_plane: unsupported format %08x\n",
-			fb->pixel_format);
+			fb->format->format);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/sti/sti_gdp.c +4 -4
index 58316bd6d7d6..877d053d86f4 100644
@@ -636,10 +636,10 @@ static int sti_gdp_atomic_check(struct drm_plane *drm_plane,
 	src_w = clamp_val(state->src_w >> 16, 0, GAM_GDP_SIZE_MAX);
 	src_h = clamp_val(state->src_h >> 16, 0, GAM_GDP_SIZE_MAX);
 
-	format = sti_gdp_fourcc2format(fb->pixel_format);
+	format = sti_gdp_fourcc2format(fb->format->format);
 	if (format == -1) {
 		DRM_ERROR("Format not supported by GDP %.4s\n",
-			  (char *)&fb->pixel_format);
+			  (char *)&fb->format->format);
 		return -EINVAL;
 	}
 
@@ -745,7 +745,7 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
 	/* build the top field */
 	top_field->gam_gdp_agc = GAM_GDP_AGC_FULL_RANGE;
 	top_field->gam_gdp_ctl = WAIT_NEXT_VSYNC;
-	format = sti_gdp_fourcc2format(fb->pixel_format);
+	format = sti_gdp_fourcc2format(fb->format->format);
 	top_field->gam_gdp_ctl |= format;
 	top_field->gam_gdp_ctl |= sti_gdp_get_alpharange(format);
 	top_field->gam_gdp_ppt &= ~GAM_GDP_PPT_IGNORE;
@@ -753,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 */
drivers/gpu/drm/sti/sti_hqvdp.c +1 -1
index f88130f2eb48..becf10d255c4 100644
@@ -1147,7 +1147,7 @@ static void sti_hqvdp_atomic_update(struct drm_plane *drm_plane,
 	cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
 
 	DRM_DEBUG_DRIVER("drm FB:%d format:%.4s phys@:0x%lx\n", fb->base.id,
-			 (char *)&fb->pixel_format,
+			 (char *)&fb->format->format,
 			 (unsigned long)cma_obj->paddr);
 
 	/* Buffer planes address */
drivers/gpu/drm/sun4i/sun4i_backend.c +2 -1
index a606207d4e25..a278e1f44661 100644
@@ -189,7 +189,8 @@ int sun4i_backend_update_layer_formats(struct sun4i_backend *backend,
 	DRM_DEBUG_DRIVER("Switching display backend interlaced mode %s\n",
 			 interlaced ? "on" : "off");
 
-	ret = sun4i_backend_drm_format_to_layer(plane, fb->pixel_format, &val);
+	ret = sun4i_backend_drm_format_to_layer(plane, fb->format->format,
+						&val);
 	if (ret) {
 		DRM_DEBUG_DRIVER("Invalid format\n");
 		return val;
drivers/gpu/drm/tegra/dc.c +1 -1
index 642dcff87e34..7561a95a54e3 100644
@@ -511,7 +511,7 @@ static int tegra_plane_atomic_check(struct drm_plane *plane,
 	if (!state->crtc)
 		return 0;
 
-	err = tegra_dc_format(state->fb->pixel_format, &plane_state->format,
+	err = tegra_dc_format(state->fb->format->format, &plane_state->format,
 			      &plane_state->swap);
 	if (err < 0)
 		return err;
drivers/gpu/drm/tilcdc/tilcdc_crtc.c +1 -1
index 0dc96e12fd06..47c2fe659fe3 100644
@@ -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;
drivers/gpu/drm/tilcdc/tilcdc_plane.c +1 -1
index c0fc874e91cf..4b7519dfd1b9 100644
@@ -77,7 +77,7 @@ static int tilcdc_plane_atomic_check(struct drm_plane *plane,
 	}
 
 	if (state->fb && old_state->fb &&
-	    state->fb->pixel_format != old_state->fb->pixel_format) {
+	    state->fb->format->format != old_state->fb->format->format) {
 		dev_dbg(plane->dev->dev,
 			"%s(): pixel format change requires mode_change\n",
 			__func__);
drivers/gpu/drm/vc4/vc4_plane.c +2 -2
index f84f6bddd015..110d1518f5d5 100644
@@ -295,7 +295,7 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
 	struct drm_framebuffer *fb = state->fb;
 	struct drm_gem_cma_object *bo = drm_fb_cma_get_gem_obj(fb, 0);
 	u32 subpixel_src_mask = (1 << 16) - 1;
-	u32 format = fb->pixel_format;
+	u32 format = fb->format->format;
 	int num_planes = 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;
drivers/gpu/drm/vmwgfx/vmwgfx_fb.c +1 -1
index 58643c5ca1d7..867a8442220c 100644
@@ -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;
 
drivers/gpu/drm/zte/zx_plane.c +1 -1
index 72d27b0a48b2..b634b090cdc1 100644
@@ -146,7 +146,7 @@ static void zx_gl_plane_atomic_update(struct drm_plane *plane,
 	if (!fb)
 		return;
 
-	format = fb->pixel_format;
+	format = fb->format->format;
 	stride = fb->pitches[0];
 
 	src_x = plane->state->src_x >> 16;
include/drm/drm_framebuffer.h +0 -4
index 72b9b4898915..f0dde1d02be4 100644
@@ -175,10 +175,6 @@ struct drm_framebuffer {
 	 */
 	int flags;
 	/**
-	 * @pixel_format: DRM FOURCC code describing the pixel format.
-	 */
-	uint32_t pixel_format; /* fourcc format */
-	/**
 	 * @hot_x: X coordinate of the cursor hotspot. Used by the legacy cursor
 	 * IOCTL when the driver supports cursor through a DRM_PLANE_TYPE_CURSOR
 	 * universal plane.
Signature · 6 lines
2.7.4

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

PATCH v2 34/37 drm: Replace 'format->format' comparisons to just 'format' comparisons

In reply to [email protected]

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

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

---
 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(-)
drivers/gpu/drm/armada/armada_crtc.c +1 -1
index 52e139dc9e38..baebf3775f60 100644
@@ -996,7 +996,7 @@ static int armada_drm_crtc_page_flip(struct drm_crtc *crtc,
 	int ret;
 
 	/* We don't support changing the pixel format */
-	if (fb->format->format != crtc->primary->fb->format->format)
+	if (fb->format != crtc->primary->fb->format)
 		return -EINVAL;
 
 	work = kmalloc(sizeof(*work), GFP_KERNEL);
drivers/gpu/drm/drm_crtc_helper.c +1 -2
index 94bce0b462aa..9d007f5f9732 100644
@@ -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;
drivers/gpu/drm/drm_plane.c +1 -1
index ac1e06df7280..1d90520457d7 100644
@@ -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;
drivers/gpu/drm/i915/intel_display.c +1 -1
index f5f9f1422d69..7b7135be3b9e 100644
@@ -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;
 
 	/*
drivers/gpu/drm/imx/ipuv3-plane.c +3 -3
index 0b945f077344..8b5294d47cee 100644
@@ -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;
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +1 -1
index b90e9e497260..6ecc6bc1f531 100644
@@ -340,7 +340,7 @@ static int mdp5_plane_atomic_check(struct drm_plane *plane,
 	if (plane_enabled(state) && plane_enabled(old_state)) {
 		/* we cannot change SMP block configuration during scanout: */
 		bool full_modeset = false;
-		if (state->fb->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;
 		}
drivers/gpu/drm/tilcdc/tilcdc_plane.c +1 -1
index 4b7519dfd1b9..ba0d66c0d8ac 100644
@@ -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__);
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v2 34/37
#79 lore raw

Re: [PATCH 34/37] drm: Replace 'format->format' comparisons to just 'format' comparisons

Hi Ville,

Thank you for the patch.

Quoted 54 lines · On Friday 18 Nov 2016 21:53:10 [email protected] wrote:

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

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

Quoted 3 lines
Quoted 29 lines
---
 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(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/armada/armada_crtc.c index 52e139dc9e38..baebf3775f60 100644

drivers/gpu/drm/armada/armada_crtc.c +1 -1
@@ -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);
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_crtc_helper.c index 94bce0b462aa..9d007f5f9732 100644

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

Quoted 6 lines
drivers/gpu/drm/drm_crtc_helper.c +1 -2
@@ -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) 

{

Quoted 44 lines
drivers/gpu/drm/drm_crtc_helper.c +0 -0
 			mode_changed = true;
 		} else
 			fb_changed = true;
drivers/gpu/drm/drm_plane.c +1 -1
index ac1e06df7280..1d90520457d7 100644
@@ -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;
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_display.c index f5f9f1422d69..7b7135be3b9e 100644

drivers/gpu/drm/i915/intel_display.c +1 -1
@@ -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;
 
 	/*
(quoted diff) +0 -0

b/drivers/gpu/drm/imx/ipuv3-plane.c index 0b945f077344..8b5294d47cee 100644

drivers/gpu/drm/imx/ipuv3-plane.c +1 -1
@@ -281,7 +281,7 @@ static int ipu_plane_atomic_check(struct drm_plane
 *plane, */
 	if (old_fb && (state->src_w != old_state->src_w ||
 			      state->src_h != old_state->src_h ||
-			      fb->format->format != old_fb->format->format))
+			      fb->format != old_fb->format))
 		crtc_state->mode_changed = true;
 
 	eba = drm_plane_state_to_eba(state);

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

Quoted 4 lines
drivers/gpu/drm/imx/ipuv3-plane.c +0 -1
@@ -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)) 

{

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

Quoted 9 lines
drivers/gpu/drm/imx/ipuv3-plane.c +1 -1
+		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)) 

{

Quoted 33 lines
drivers/gpu/drm/imx/ipuv3-plane.c +1 -0
+		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;
(quoted diff) +0 -0

b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c index
b90e9e497260..6ecc6bc1f531 100644

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

b/drivers/gpu/drm/tilcdc/tilcdc_plane.c index 4b7519dfd1b9..ba0d66c0d8ac 100644

drivers/gpu/drm/tilcdc/tilcdc_plane.c +1 -1
@@ -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__);
Signature · 8 lines
Regards,

Laurent Pinchart

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

PATCH v2 35/37 drm: Eliminate the useless "non-RGB fb" debug message

In reply to [email protected]

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

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.

---
 drivers/gpu/drm/drm_modeset_helper.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/gpu/drm/drm_modeset_helper.c +1 -12
index 639e474e7d43..5b051859b8d3 100644
@@ -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++) {
Signature · 6 lines
2.7.4

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

Re: [PATCH 35/37] drm: Eliminate the useless "non-RGB fb" debug message

Hi Ville,

Thank you for the patch.

Quoted 10 lines · On Friday 18 Nov 2016 21:53:11 [email protected] wrote:

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

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.

Quoted 32 lines
---
 drivers/gpu/drm/drm_modeset_helper.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_modeset_helper.c index 639e474e7d43..5b051859b8d3 100644

drivers/gpu/drm/drm_modeset_helper.c +1 -12
@@ -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++) {
Signature · 8 lines
Regards,

Laurent Pinchart

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

PATCH v2 36/37 drm: Add mode_config .get_format_info() hook

In reply to [email protected]

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

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.

---
 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(-)
drivers/gpu/drm/drm_fb_cma_helper.c +1 -1
index aab4465307ed..d7f8876cf5e9 100644
@@ -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);
 
drivers/gpu/drm/drm_fourcc.c +25 -0
index 90d2cc8da8eb..7cfaee689f0c 100644
@@ -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_*)
  *
drivers/gpu/drm/drm_framebuffer.c +7 -2
index 94ddab41f24f..292930a5dcc2 100644
@@ -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);
 
drivers/gpu/drm/drm_modeset_helper.c +1 -1
index 5b051859b8d3..f78df06a940d 100644
@@ -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++) {
include/drm/drm_fourcc.h +6 -0
index fcc08da850c8..6942e84b6edd 100644
@@ -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);
include/drm/drm_mode_config.h +15 -0
index bf9991b20611..80bb7e49bf8e 100644
@@ -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
Signature · 6 lines
2.7.4

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

Re: [PATCH 36/37] drm: Add mode_config .get_format_info() hook

Hi Ville,

Thank you for the patch.

Quoted 40 lines · On Friday 18 Nov 2016 21:53:12 [email protected] wrote:

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

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.

---
 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(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_fb_cma_helper.c index aab4465307ed..d7f8876cf5e9 100644

drivers/gpu/drm/drm_fb_cma_helper.c +1 -1
@@ -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);
 
drivers/gpu/drm/drm_fourcc.c +1 -0
index 90d2cc8da8eb..7cfaee689f0c 100644
@@ -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
Quoted 1 line

configuration

I assume you meant drm_get_format_info()

Quoted 1 line

+ * @dev: DRM device

Do we need the dev pointer ?

Quoted 6 lines

+ * @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.

Quoted 109 lines

+ */

drivers/gpu/drm/drm_fourcc.c +17 -0
+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_*)
  *
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_framebuffer.c index 94ddab41f24f..292930a5dcc2 100644

drivers/gpu/drm/drm_framebuffer.c +7 -2
@@ -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);
 
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_modeset_helper.c index 5b051859b8d3..f78df06a940d 100644

drivers/gpu/drm/drm_modeset_helper.c +1 -1
@@ -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++) {
include/drm/drm_fourcc.h +6 -0
index fcc08da850c8..6942e84b6edd 100644
@@ -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);
include/drm/drm_mode_config.h +1 -0
index bf9991b20611..80bb7e49bf8e 100644
@@ -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
Quoted 2 lines

functions @@ -70,6 +71,20 @@ struct drm_mode_config_funcs {
const struct drm_mode_fb_cmd2

*mode_cmd);

include/drm/drm_mode_config.h struct drm_mode_config_funcs {

Quoted 13 lines
include/drm/drm_mode_config.h +11 -0
 	/**
+	 * @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,

include/drm/drm_mode_config.h

Quoted 1 line
include/drm/drm_mode_config.h +1 -0
+							 const struct 

drm_mode_fb_cmd2 *mode_cmd);

include/drm/drm_mode_config.h struct drm_mode_config_funcs {

Quoted 5 lines
include/drm/drm_mode_config.h +2 -0
+
+	/**
 	 * @output_poll_changed:
 	 *
 	 * Callback used by helpers to inform the driver of output 

configuration

Signature · 8 lines
Regards,

Laurent Pinchart

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

Re: [PATCH 36/37] drm: Add mode_config .get_format_info() hook

Quoted 43 lines · Laurent Pinchart

Hi Ville,

Thank you for the patch.

Quoted 38 lines · On Friday 18 Nov 2016 21:53:12 [email protected] wrote:

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

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.

---
 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(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_fb_cma_helper.c index aab4465307ed..d7f8876cf5e9 100644

drivers/gpu/drm/drm_fb_cma_helper.c +1 -1
@@ -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);
 
drivers/gpu/drm/drm_fourcc.c +0 -0
index 90d2cc8da8eb..7cfaee689f0c 100644
@@ -199,6 +199,31 @@ const struct drm_format_info *drm_format_info(u32
 format) EXPORT_SYMBOL(drm_format_info);
 
Quoted 5 lines
Quoted 3 lines
drivers/gpu/drm/drm_fourcc.c +1 -0
 /**
+ * drm_format_info - query information for a given framebuffer

configuration

I assume you meant drm_get_format_info()

Yes.

Quoted 4 lines
Quoted 2 lines

+ * @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.

Quoted 8 lines
Quoted 7 lines

+ * @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.

Quoted 4 lines

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.

Quoted 140 lines
Quoted 110 lines

+ */

drivers/gpu/drm/drm_fourcc.c +17 -0
+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_*)
  *
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_framebuffer.c index 94ddab41f24f..292930a5dcc2 100644

drivers/gpu/drm/drm_framebuffer.c +7 -2
@@ -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);
 
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_modeset_helper.c index 5b051859b8d3..f78df06a940d 100644

drivers/gpu/drm/drm_modeset_helper.c +1 -1
@@ -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++) {
include/drm/drm_fourcc.h +6 -0
index fcc08da850c8..6942e84b6edd 100644
@@ -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);
include/drm/drm_mode_config.h +1 -0
index bf9991b20611..80bb7e49bf8e 100644
@@ -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
Quoted 2 lines

functions @@ -70,6 +71,20 @@ struct drm_mode_config_funcs {
const struct drm_mode_fb_cmd2

*mode_cmd);

include/drm/drm_mode_config.h struct drm_mode_config_funcs {

Quoted 13 lines
include/drm/drm_mode_config.h +11 -0
 	/**
+	 * @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,

include/drm/drm_mode_config.h

Quoted 1 line
include/drm/drm_mode_config.h +1 -0
+							 const struct 

drm_mode_fb_cmd2 *mode_cmd);

include/drm/drm_mode_config.h struct drm_mode_config_funcs {

Quoted 5 lines
include/drm/drm_mode_config.h +2 -0
+
+	/**
 	 * @output_poll_changed:
 	 *
 	 * Callback used by helpers to inform the driver of output 

configuration

Signature · 3 lines
Regards,

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

Re: [PATCH 36/37] drm: Add mode_config .get_format_info() hook

Hi Ville,

Quoted 66 lines · On Monday 21 Nov 2016 15:18:23 Ville Syrjälä wrote:
Quoted 42 lines · Laurent Pinchart
Quoted 41 lines · On Friday 18 Nov 2016 21:53:12 [email protected] wrote:

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

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.

---

 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(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_fb_cma_helper.c index aab4465307ed..d7f8876cf5e9 100644

drivers/gpu/drm/drm_fb_cma_helper.c +1 -1
@@ -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);
drivers/gpu/drm/drm_fourcc.c +0 -0
index 90d2cc8da8eb..7cfaee689f0c 100644
@@ -199,6 +199,31 @@ const struct drm_format_info *drm_format_info(u32
 format)
 EXPORT_SYMBOL(drm_format_info);
 
Quoted 5 lines
Quoted 3 lines
drivers/gpu/drm/drm_fourcc.c +1 -0
 /**
+ * drm_format_info - query information for a given framebuffer

configuration

I assume you meant drm_get_format_info()

Yes.

Quoted 3 lines
Quoted 1 line

+ * @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).

Quoted 2 lines

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.

Quoted 12 lines
Quoted 11 lines
Quoted 6 lines

+ * @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.

Quoted 4 lines

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.

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

+ */

drivers/gpu/drm/drm_fourcc.c +15 -0
+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);
Signature · 8 lines
Regards,

Laurent Pinchart

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

Re: [PATCH 36/37] drm: Add mode_config .get_format_info() hook

Quoted 86 lines · Laurent Pinchart

Hi Ville,

Quoted 66 lines · On Monday 21 Nov 2016 15:18:23 Ville Syrjälä wrote:
Quoted 42 lines · Laurent Pinchart
Quoted 41 lines · On Friday 18 Nov 2016 21:53:12 [email protected] wrote:

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

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.

---

 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(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_fb_cma_helper.c index aab4465307ed..d7f8876cf5e9 100644

drivers/gpu/drm/drm_fb_cma_helper.c +1 -1
@@ -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);
drivers/gpu/drm/drm_fourcc.c +0 -0
index 90d2cc8da8eb..7cfaee689f0c 100644
@@ -199,6 +199,31 @@ const struct drm_format_info *drm_format_info(u32
 format)
 EXPORT_SYMBOL(drm_format_info);
 
Quoted 5 lines
Quoted 3 lines
drivers/gpu/drm/drm_fourcc.c +1 -0
 /**
+ * drm_format_info - query information for a given framebuffer

configuration

I assume you meant drm_get_format_info()

Yes.

Quoted 3 lines
Quoted 1 line

+ * @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).

Quoted 2 lines

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.

Quoted 12 lines
Quoted 11 lines
Quoted 6 lines

+ * @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.

Quoted 6 lines
Quoted 4 lines

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.

Quoted 5 lines

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.

Quoted 22 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

+ */

drivers/gpu/drm/drm_fourcc.c +15 -0
+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);
Signature · 3 lines
Regards,

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

Re: [PATCH 36/37] drm: Add mode_config .get_format_info() hook

Hi Ville,

Quoted 22 lines · On Monday 21 Nov 2016 15:31:57 Ville Syrjälä wrote:
Quoted 21 lines · Laurent Pinchart
Quoted 20 lines · On Monday 21 Nov 2016 15:18:23 Ville Syrjälä wrote:
Quoted 19 lines · Laurent Pinchart
Quoted 18 lines · On Friday 18 Nov 2016 21:53:12 [email protected] wrote:

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

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.

---

 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]

Quoted 49 lines
Quoted 49 lines
Quoted 32 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/drm_fourcc.c +0 -0
index 90d2cc8da8eb..7cfaee689f0c 100644
@@ -199,6 +199,31 @@ const struct drm_format_info
 *drm_format_info(u32 format)
 EXPORT_SYMBOL(drm_format_info);
 
Quoted 5 lines
Quoted 3 lines
drivers/gpu/drm/drm_fourcc.c +1 -0
 /**
+ * drm_format_info - query information for a given framebuffer

configuration

I assume you meant drm_get_format_info()

Yes.

Quoted 3 lines
Quoted 1 line

+ * @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).

Quoted 2 lines

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.

Quoted 12 lines
Quoted 11 lines
Quoted 6 lines

+ * @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.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

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 ?

Quoted 11 lines
Quoted 5 lines

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.

Signature · 8 lines
Regards,

Laurent Pinchart

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

Re: [PATCH 36/37] drm: Add mode_config .get_format_info() hook

Quoted 82 lines · Laurent Pinchart

Hi Ville,

Quoted 22 lines · On Monday 21 Nov 2016 15:31:57 Ville Syrjälä wrote:
Quoted 21 lines · Laurent Pinchart
Quoted 20 lines · On Monday 21 Nov 2016 15:18:23 Ville Syrjälä wrote:
Quoted 19 lines · Laurent Pinchart
Quoted 18 lines · On Friday 18 Nov 2016 21:53:12 [email protected] wrote:

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

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.

---

 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]

Quoted 54 lines
Quoted 54 lines
Quoted 32 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/drm_fourcc.c +0 -0
index 90d2cc8da8eb..7cfaee689f0c 100644
@@ -199,6 +199,31 @@ const struct drm_format_info
 *drm_format_info(u32 format)
 EXPORT_SYMBOL(drm_format_info);
 
Quoted 5 lines
Quoted 3 lines
drivers/gpu/drm/drm_fourcc.c +1 -0
 /**
+ * drm_format_info - query information for a given framebuffer

configuration

I assume you meant drm_get_format_info()

Yes.

Quoted 3 lines
Quoted 1 line

+ * @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).

Quoted 2 lines

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.

Quoted 16 lines
Quoted 11 lines
Quoted 6 lines

+ * @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.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

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.

Quoted 13 lines
Quoted 7 lines
Quoted 6 lines

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.

Quoted 5 lines

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.

Quoted 7 lines

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.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#89 lore raw

PATCH v2 36/37 drm: Add mode_config .get_format_info() hook

In reply to [email protected]

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

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)

---
 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(-)
drivers/gpu/drm/drm_fb_cma_helper.c +1 -1
index aab4465307ed..d7f8876cf5e9 100644
@@ -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);
 
drivers/gpu/drm/drm_fourcc.c +25 -0
index 90d2cc8da8eb..f9b6445e846a 100644
@@ -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_*)
  *
drivers/gpu/drm/drm_framebuffer.c +7 -2
index 94ddab41f24f..292930a5dcc2 100644
@@ -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);
 
drivers/gpu/drm/drm_modeset_helper.c +1 -1
index 5b051859b8d3..f78df06a940d 100644
@@ -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++) {
include/drm/drm_fourcc.h +6 -0
index fcc08da850c8..6942e84b6edd 100644
@@ -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);
include/drm/drm_mode_config.h +14 -0
index bf9991b20611..3af17a3a69fb 100644
@@ -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
Signature · 6 lines
2.7.4

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

PATCH v2 37/37 drm/i915: Implement .get_format_info() hook for CCS

In reply to [email protected]

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

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.

---
 drivers/gpu/drm/i915/intel_display.c | 37 ++++++++++++++++++++++++++++++++++++
 include/uapi/drm/drm_fourcc.h        |  3 +++
 2 files changed, 40 insertions(+)
drivers/gpu/drm/i915/intel_display.c +37 -0
index 7b7135be3b9e..de6909770c68 100644
@@ -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,
include/uapi/drm/drm_fourcc.h +3 -0
index a5890bf44c0a..2926d916f199 100644
@@ -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
  *
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v2 37/37
#91 lore raw

Re: [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS

Quoted 6 lines · Ville Syrjälä

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

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.

Quoted 10 lines

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.

I have a comment below however, you can consider it:

Quoted 39 lines

---
drivers/gpu/drm/i915/intel_display.c | 37 ++++++++++++++++++++++++++++++++++++
include/uapi/drm/drm_fourcc.h | 3 +++

2 files changed, 40 insertions(+)
drivers/gpu/drm/i915/intel_display.c +26 -0
index 7b7135be3b9e..de6909770c68 100644
@@ -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]) {

drivers/gpu/drm/i915/intel_display.c static unsigned int intel_fb_modifier_to_tiling(uint64_t fb_modifier) · line 2526

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -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/

Quoted 25 lines

static int
intel_fill_fb_info(struct drm_i915_private *dev_priv,
struct drm_framebuffer *fb)

drivers/gpu/drm/i915/intel_display.c +1 -0
@@ -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,
include/uapi/drm/drm_fourcc.h +3 -0
index a5890bf44c0a..2926d916f199 100644
@@ -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
 *
Signature · 5 lines
Ben Widawsky, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#92 lore raw

Re: [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS

Quoted 72 lines · Ben Widawsky
Quoted 6 lines · Ville Syrjälä

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

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.

Quoted 10 lines

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.

I have a comment below however, you can consider it:

Quoted 45 lines

---
drivers/gpu/drm/i915/intel_display.c | 37 ++++++++++++++++++++++++++++++++++++
include/uapi/drm/drm_fourcc.h | 3 +++

2 files changed, 40 insertions(+)
drivers/gpu/drm/i915/intel_display.c +32 -0
index 7b7135be3b9e..de6909770c68 100644
@@ -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:
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static unsigned int intel_fb_modifier_to_tiling(uint64_t fb_modifier) · line 2526

Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +4 -0
+		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".

Quoted 3 lines

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.

Quoted 29 lines
Quoted 26 lines

static int
intel_fill_fb_info(struct drm_i915_private *dev_priv,
struct drm_framebuffer *fb)

drivers/gpu/drm/i915/intel_display.c +1 -0
@@ -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,
include/uapi/drm/drm_fourcc.h +3 -0
index a5890bf44c0a..2926d916f199 100644
@@ -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
 *
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#93 lore raw

Re: [Intel-gfx] [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS

In reply to [email protected]

Hi,

Quoted 81 lines · On 18/11/2016 19:53, [email protected] wrote:

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

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.

---
 drivers/gpu/drm/i915/intel_display.c | 37 ++++++++++++++++++++++++++++++++++++
 include/uapi/drm/drm_fourcc.h        |  3 +++
 2 files changed, 40 insertions(+)
drivers/gpu/drm/i915/intel_display.c +37 -0
index 7b7135be3b9e..de6909770c68 100644
@@ -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,
include/uapi/drm/drm_fourcc.h +0 -0
index a5890bf44c0a..2926d916f199 100644

include/uapi/drm/drm_fourcc.h extern "C" { · line 223

Quoted 6 lines
include/uapi/drm/drm_fourcc.h +3 -0
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#94 lore raw

Re: [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS

Quoted 96 lines · Tvrtko Ursulin

Hi,

Quoted 81 lines · On 18/11/2016 19:53, [email protected] wrote:

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

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.

---
 drivers/gpu/drm/i915/intel_display.c | 37 ++++++++++++++++++++++++++++++++++++
 include/uapi/drm/drm_fourcc.h        |  3 +++
 2 files changed, 40 insertions(+)
drivers/gpu/drm/i915/intel_display.c +37 -0
index 7b7135be3b9e..de6909770c68 100644
@@ -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,
include/uapi/drm/drm_fourcc.h +0 -0
index a5890bf44c0a..2926d916f199 100644

include/uapi/drm/drm_fourcc.h extern "C" { · line 223

Quoted 6 lines
include/uapi/drm/drm_fourcc.h +3 -0
@@ -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.

Quoted 5 lines

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.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#95 lore raw

Re: [PATCH 37/37] drm/i915: Implement .get_format_info() hook for CCS

Quoted 97 lines · Ville Syrjälä
Quoted 96 lines · Tvrtko Ursulin

Hi,

Quoted 81 lines · On 18/11/2016 19:53, [email protected] wrote:

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

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.

---
 drivers/gpu/drm/i915/intel_display.c | 37 ++++++++++++++++++++++++++++++++++++
 include/uapi/drm/drm_fourcc.h        |  3 +++
 2 files changed, 40 insertions(+)
drivers/gpu/drm/i915/intel_display.c +37 -0
index 7b7135be3b9e..de6909770c68 100644
@@ -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,
include/uapi/drm/drm_fourcc.h +0 -0
index a5890bf44c0a..2926d916f199 100644

include/uapi/drm/drm_fourcc.h extern "C" { · line 223

Quoted 6 lines
include/uapi/drm/drm_fourcc.h +3 -0
@@ -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.

Quoted 8 lines
Quoted 5 lines

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.

Quoted 4 lines

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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer
#96 lore raw
In reply to [email protected]

Patches #2 and #3 are Reviewed-by: Christian König <[email protected]>.

The rest is Acked-by: Christian König <[email protected]>.

Regards,
Christian.

Am 18.11.2016 um 20:52 schrieb [email protected]:

Quoted 189 lines

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

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 <[email protected]>
Cc Alexey Brodkin <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Ben Widawsky <[email protected]>
Cc Brian Starkey <[email protected]>
Cc "Christian König" <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Gerd Hoffmann <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc Mali DP Maintainers <[email protected]>
Cc Patrik Jakobsson <[email protected]>
Cc Paulo Zanoni <[email protected]>
Cc Sinclair Yeh <[email protected]>
Cc Thomas Hellstrom <[email protected]>

Ville Syrjälä (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 +-
Quoted 9 lines
  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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#97 lore raw
In reply to [email protected]
Quoted 44 lines · On Fri, Nov 18, 2016 at 09:52:36PM +0200, [email protected] wrote:

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

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 <[email protected]>
Cc Alexey Brodkin <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Ben Widawsky <[email protected]>
Cc Brian Starkey <[email protected]>
Cc "Christian König" <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Gerd Hoffmann <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc Mali DP Maintainers <[email protected]>
Cc Patrik Jakobsson <[email protected]>
Cc Paulo Zanoni <[email protected]>
Cc Sinclair Yeh <[email protected]>
Cc Thomas Hellstrom <[email protected]>
Quoted 12 lines

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.

Quoted 144 lines

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(-)
Signature · 1 line
2.7.4
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#98 lore raw
Quoted 58 lines · Ville Syrjälä
Quoted 44 lines · On Fri, Nov 18, 2016 at 09:52:36PM +0200, [email protected] wrote:

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

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 <[email protected]>
Cc Alexey Brodkin <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Ben Widawsky <[email protected]>
Cc Brian Starkey <[email protected]>
Cc "Christian König" <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Gerd Hoffmann <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc Mali DP Maintainers <[email protected]>
Cc Patrik Jakobsson <[email protected]>
Cc Paulo Zanoni <[email protected]>
Cc Sinclair Yeh <[email protected]>
Cc Thomas Hellstrom <[email protected]>
Quoted 12 lines

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

Quoted 33 lines

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.

Quoted 27 lines

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

Quoted 2 lines
Quoted 2 lines

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.

Quoted 123 lines
Quoted 115 lines
 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(-)
Signature · 1 line
2.7.4
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx