From 248dbc2350501e2c7b9f5ceb60c75515d82f4134 Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@redhat.com>
Date: Tue, 29 Nov 2011 20:02:54 +0000
Subject: drm: move the fb bpp/depth helper into the core.
Git-commit: 248dbc2350501e2c7b9f5ceb60c75515d82f4134 (partial)
Patch-mainline: v3.3-rc1
Patch-filtered: drivers/gpu/drm/ include/drm/

This is used by nearly everyone including vmwgfx which doesn't generally
use the fb helper.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Michal Srb <msrb@suse.com>
---

 drivers/gpu/drm/drm_crtc.c           |   41 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_crtc_helper.c    |   43 -----------------------------------
 drivers/gpu/drm/gma500/framebuffer.c |    2 -
 drivers/gpu/drm/radeon/radeon_fb.c   |    2 -
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  |    2 -
 include/drm/drm_crtc.h               |    3 ++
 include/drm/drm_crtc_helper.h        |    2 -
 7 files changed, 48 insertions(+), 47 deletions(-)

Index: linux-3.0-SLE11-SP3/drivers/gpu/drm/drm_crtc.c
===================================================================
--- linux-3.0-SLE11-SP3.orig/drivers/gpu/drm/drm_crtc.c
+++ linux-3.0-SLE11-SP3/drivers/gpu/drm/drm_crtc.c
@@ -3141,3 +3141,44 @@ int drm_mode_destroy_dumb_ioctl(struct d
 
 	return dev->driver->dumb_destroy(file_priv, dev, args->handle);
 }
+
+/*
+ * Just need to support RGB formats here for compat with code that doesn't
+ * use pixel formats directly yet.
+ */
+void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
+			  int *bpp)
+{
+	switch (format) {
+	case DRM_FOURCC_RGB332:
+		*depth = 8;
+		*bpp = 8;
+		break;
+	case DRM_FOURCC_RGB555:
+		*depth = 15;
+		*bpp = 16;
+		break;
+	case DRM_FOURCC_RGB565:
+		*depth = 16;
+		*bpp = 16;
+		break;
+	case DRM_FOURCC_RGB24:
+		*depth = 24;
+		*bpp = 32;
+		break;
+	case DRM_INTEL_RGB30:
+		*depth = 30;
+		*bpp = 32;
+		break;
+	case DRM_FOURCC_RGB32:
+		*depth = 32;
+		*bpp = 32;
+		break;
+	default:
+		DRM_DEBUG_KMS("unsupported pixel format\n");
+		*depth = 0;
+		*bpp = 0;
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_fb_get_bpp_depth);
Index: linux-3.0-SLE11-SP3/drivers/gpu/drm/drm_crtc_helper.c
===================================================================
--- linux-3.0-SLE11-SP3.orig/drivers/gpu/drm/drm_crtc_helper.c
+++ linux-3.0-SLE11-SP3/drivers/gpu/drm/drm_crtc_helper.c
@@ -847,54 +847,13 @@ void drm_helper_connector_dpms(struct dr
 }
 EXPORT_SYMBOL(drm_helper_connector_dpms);
 
-/*
- * Just need to support RGB formats here for compat with code that doesn't
- * use pixel formats directly yet.
- */
-void drm_helper_get_fb_bpp_depth(uint32_t format, unsigned int *depth,
-				 int *bpp)
-{
-	switch (format) {
-	case DRM_FOURCC_RGB332:
-		*depth = 8;
-		*bpp = 8;
-		break;
-	case DRM_FOURCC_RGB555:
-		*depth = 15;
-		*bpp = 16;
-		break;
-	case DRM_FOURCC_RGB565:
-		*depth = 16;
-		*bpp = 16;
-		break;
-	case DRM_FOURCC_RGB24:
-		*depth = 24;
-		*bpp = 32;
-		break;
-	case DRM_INTEL_RGB30:
-		*depth = 30;
-		*bpp = 32;
-		break;
-	case DRM_FOURCC_RGB32:
-		*depth = 32;
-		*bpp = 32;
-		break;
-	default:
-		DRM_DEBUG_KMS("unsupported pixel format\n");
-		*depth = 0;
-		*bpp = 0;
-		break;
-	}
-}
-EXPORT_SYMBOL(drm_helper_get_fb_bpp_depth);
-
 int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
 				   struct drm_mode_fb_cmd2 *mode_cmd)
 {
 	fb->width = mode_cmd->width;
 	fb->height = mode_cmd->height;
 	fb->pitch = mode_cmd->pitches[0];
-	drm_helper_get_fb_bpp_depth(mode_cmd->pixel_format, &fb->depth,
+	drm_fb_get_bpp_depth(mode_cmd->pixel_format, &fb->depth,
 				    &fb->bits_per_pixel);
 	fb->pixel_format = mode_cmd->pixel_format;
 
Index: linux-3.0-SLE11-SP3/drivers/gpu/drm/radeon/radeon_fb.c
===================================================================
--- linux-3.0-SLE11-SP3.orig/drivers/gpu/drm/radeon/radeon_fb.c
+++ linux-3.0-SLE11-SP3/drivers/gpu/drm/radeon/radeon_fb.c
@@ -116,7 +116,7 @@ static int radeonfb_create_pinned_object
 	int height = mode_cmd->height;
 	u32 bpp, depth;
 
-	drm_helper_get_fb_bpp_depth(mode_cmd->pixel_format, &depth, &bpp);
+	drm_fb_get_bpp_depth(mode_cmd->pixel_format, &depth, &bpp);
 
 	/* need to align pitch with crtc limits */
 	mode_cmd->pitches[0] = radeon_align_pitch(rdev, mode_cmd->width, bpp,
Index: linux-3.0-SLE11-SP3/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
===================================================================
--- linux-3.0-SLE11-SP3.orig/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ linux-3.0-SLE11-SP3/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -1100,7 +1100,7 @@ static struct drm_framebuffer *vmw_kms_f
 	mode_cmd.height = mode_cmd2->height;
 	mode_cmd.pitch = mode_cmd2->pitches[0];
 	mode_cmd.handle = mode_cmd2->handles[0];
-	drm_helper_get_fb_bpp_depth(mode_cmd2->pixel_format, &mode_cmd.depth,
+	drm_fb_get_bpp_depth(mode_cmd2->pixel_format, &mode_cmd.depth,
 				    &mode_cmd.bpp);
 
 	/**
Index: linux-3.0-SLE11-SP3/include/drm/drm_crtc.h
===================================================================
--- linux-3.0-SLE11-SP3.orig/include/drm/drm_crtc.h
+++ linux-3.0-SLE11-SP3/include/drm/drm_crtc.h
@@ -904,4 +904,7 @@ extern int drm_mode_mmap_dumb_ioctl(stru
 				    void *data, struct drm_file *file_priv);
 extern int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
 				      void *data, struct drm_file *file_priv);
+
+extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
+				 int *bpp);
 #endif /* __DRM_CRTC_H__ */
Index: linux-3.0-SLE11-SP3/include/drm/drm_crtc_helper.h
===================================================================
--- linux-3.0-SLE11-SP3.orig/include/drm/drm_crtc_helper.h
+++ linux-3.0-SLE11-SP3/include/drm/drm_crtc_helper.h
@@ -116,8 +116,6 @@ extern bool drm_helper_encoder_in_use(st
 
 extern void drm_helper_connector_dpms(struct drm_connector *connector, int mode);
 
-extern void drm_helper_get_fb_bpp_depth(uint32_t format, unsigned int *depth,
-					int *bpp);
 extern int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
 					  struct drm_mode_fb_cmd2 *mode_cmd);
 
