diff options
author | Jesse Barnes <jbarnes@virtuousgeek.org> | 2011-11-14 17:51:28 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2011-11-15 14:53:23 -0500 |
commit | 308e5bcbdb10452e8aba31aa21432fb67ee46d72 (patch) | |
tree | 5e4eebef07685c4047f54d1727fc9bcbace8889d /drivers/gpu/drm/drm_crtc_helper.c | |
parent | 8cf5c9177151537e73ff1816540e4ba24b174391 (diff) |
drm: add an fb creation ioctl that takes a pixel format v5
To properly support the various plane formats supported by different
hardware, the kernel must know the pixel format of a framebuffer object.
So add a new ioctl taking a format argument corresponding to a fourcc
name from the new drm_fourcc.h header file. Implement the fb creation
hooks in terms of the new mode_fb_cmd2 using helpers where the old
bpp/depth values are needed.
v2: create DRM specific fourcc header file for sharing with libdrm etc
v3: fix rebase failure and use DRM fourcc codes in intel_display.c and
update commit message
v4: make fb_cmd2 handle field into an array for multi-object formats
pull in Ville's fix for the memcpy in drm_plane_init
apply Ville's cleanup to zero out fb_cmd2 arg in drm_mode_addfb
v5: add 'flags' field for interlaced support (from Ville)
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Reviewed-by: Rob Clark <rob.clark@linaro.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_crtc_helper.c')
-rw-r--r-- | drivers/gpu/drm/drm_crtc_helper.c | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c index 2957636161e8..432d5391b93c 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c | |||
@@ -34,6 +34,7 @@ | |||
34 | 34 | ||
35 | #include "drmP.h" | 35 | #include "drmP.h" |
36 | #include "drm_crtc.h" | 36 | #include "drm_crtc.h" |
37 | #include "drm_fourcc.h" | ||
37 | #include "drm_crtc_helper.h" | 38 | #include "drm_crtc_helper.h" |
38 | #include "drm_fb_helper.h" | 39 | #include "drm_fb_helper.h" |
39 | 40 | ||
@@ -810,14 +811,56 @@ void drm_helper_connector_dpms(struct drm_connector *connector, int mode) | |||
810 | } | 811 | } |
811 | EXPORT_SYMBOL(drm_helper_connector_dpms); | 812 | EXPORT_SYMBOL(drm_helper_connector_dpms); |
812 | 813 | ||
814 | /* | ||
815 | * Just need to support RGB formats here for compat with code that doesn't | ||
816 | * use pixel formats directly yet. | ||
817 | */ | ||
818 | void drm_helper_get_fb_bpp_depth(uint32_t format, unsigned int *depth, | ||
819 | int *bpp) | ||
820 | { | ||
821 | switch (format) { | ||
822 | case DRM_FOURCC_RGB332: | ||
823 | *depth = 8; | ||
824 | *bpp = 8; | ||
825 | break; | ||
826 | case DRM_FOURCC_RGB555: | ||
827 | *depth = 15; | ||
828 | *bpp = 16; | ||
829 | break; | ||
830 | case DRM_FOURCC_RGB565: | ||
831 | *depth = 16; | ||
832 | *bpp = 16; | ||
833 | break; | ||
834 | case DRM_FOURCC_RGB24: | ||
835 | *depth = 24; | ||
836 | *bpp = 32; | ||
837 | break; | ||
838 | case DRM_INTEL_RGB30: | ||
839 | *depth = 30; | ||
840 | *bpp = 32; | ||
841 | break; | ||
842 | case DRM_FOURCC_RGB32: | ||
843 | *depth = 32; | ||
844 | *bpp = 32; | ||
845 | break; | ||
846 | default: | ||
847 | DRM_DEBUG_KMS("unsupported pixel format\n"); | ||
848 | *depth = 0; | ||
849 | *bpp = 0; | ||
850 | break; | ||
851 | } | ||
852 | } | ||
853 | EXPORT_SYMBOL(drm_helper_get_fb_bpp_depth); | ||
854 | |||
813 | int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, | 855 | int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, |
814 | struct drm_mode_fb_cmd *mode_cmd) | 856 | struct drm_mode_fb_cmd2 *mode_cmd) |
815 | { | 857 | { |
816 | fb->width = mode_cmd->width; | 858 | fb->width = mode_cmd->width; |
817 | fb->height = mode_cmd->height; | 859 | fb->height = mode_cmd->height; |
818 | fb->pitch = mode_cmd->pitch; | 860 | fb->pitch = mode_cmd->pitches[0]; |
819 | fb->bits_per_pixel = mode_cmd->bpp; | 861 | drm_helper_get_fb_bpp_depth(mode_cmd->pixel_format, &fb->depth, |
820 | fb->depth = mode_cmd->depth; | 862 | &fb->bits_per_pixel); |
863 | fb->pixel_format = mode_cmd->pixel_format; | ||
821 | 864 | ||
822 | return 0; | 865 | return 0; |
823 | } | 866 | } |