diff options
author | Timur Tabi <timur@freescale.com> | 2011-12-19 17:26:17 -0500 |
---|---|---|
committer | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2012-01-03 10:59:09 -0500 |
commit | e09a8c3a42f4c90d300678b198410e6fcc8eddb6 (patch) | |
tree | 61832640811e3d84ee43f34e1dbb16f87d5158fd /drivers/video/fsl-diu-fb.c | |
parent | d397e916f313441d0c6b37df4b296c1dcc6aa202 (diff) |
drivers/video: fsl-diu-fb: add default platform ops functions
The DIU driver requires some platform-specific functions to be defined,
but two them can be optional because most platforms implement them the
same way. Functions set_gamma_table() and get_pixel_format() are only
needed because of quirks in the Freescale MPC8610 HPCD reference board.
For other boards, a generic implementation works, so we shouldn't
require the platform code to define them.
Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'drivers/video/fsl-diu-fb.c')
-rw-r--r-- | drivers/video/fsl-diu-fb.c | 64 |
1 files changed, 61 insertions, 3 deletions
diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c index d8d461d6c90b..e2f4f32692a1 100644 --- a/drivers/video/fsl-diu-fb.c +++ b/drivers/video/fsl-diu-fb.c | |||
@@ -832,7 +832,8 @@ static void update_lcdc(struct fb_info *info) | |||
832 | for (j = 0; j <= 255; j++) | 832 | for (j = 0; j <= 255; j++) |
833 | *gamma_table_base++ = j; | 833 | *gamma_table_base++ = j; |
834 | 834 | ||
835 | diu_ops.set_gamma_table(data->monitor_port, data->gamma); | 835 | if (diu_ops.set_gamma_table) |
836 | diu_ops.set_gamma_table(data->monitor_port, data->gamma); | ||
836 | 837 | ||
837 | disable_lcdc(info); | 838 | disable_lcdc(info); |
838 | 839 | ||
@@ -917,6 +918,59 @@ static int fsl_diu_set_aoi(struct fb_info *info) | |||
917 | return 0; | 918 | return 0; |
918 | } | 919 | } |
919 | 920 | ||
921 | /** | ||
922 | * fsl_diu_get_pixel_format: return the pixel format for a given color depth | ||
923 | * | ||
924 | * The pixel format is a 32-bit value that determine which bits in each | ||
925 | * pixel are to be used for each color. This is the default function used | ||
926 | * if the platform does not define its own version. | ||
927 | */ | ||
928 | static u32 fsl_diu_get_pixel_format(unsigned int bits_per_pixel) | ||
929 | { | ||
930 | #define PF_BYTE_F 0x10000000 | ||
931 | #define PF_ALPHA_C_MASK 0x0E000000 | ||
932 | #define PF_ALPHA_C_SHIFT 25 | ||
933 | #define PF_BLUE_C_MASK 0x01800000 | ||
934 | #define PF_BLUE_C_SHIFT 23 | ||
935 | #define PF_GREEN_C_MASK 0x00600000 | ||
936 | #define PF_GREEN_C_SHIFT 21 | ||
937 | #define PF_RED_C_MASK 0x00180000 | ||
938 | #define PF_RED_C_SHIFT 19 | ||
939 | #define PF_PALETTE 0x00040000 | ||
940 | #define PF_PIXEL_S_MASK 0x00030000 | ||
941 | #define PF_PIXEL_S_SHIFT 16 | ||
942 | #define PF_COMP_3_MASK 0x0000F000 | ||
943 | #define PF_COMP_3_SHIFT 12 | ||
944 | #define PF_COMP_2_MASK 0x00000F00 | ||
945 | #define PF_COMP_2_SHIFT 8 | ||
946 | #define PF_COMP_1_MASK 0x000000F0 | ||
947 | #define PF_COMP_1_SHIFT 4 | ||
948 | #define PF_COMP_0_MASK 0x0000000F | ||
949 | #define PF_COMP_0_SHIFT 0 | ||
950 | |||
951 | #define MAKE_PF(alpha, red, blue, green, size, c0, c1, c2, c3) \ | ||
952 | cpu_to_le32(PF_BYTE_F | (alpha << PF_ALPHA_C_SHIFT) | \ | ||
953 | (blue << PF_BLUE_C_SHIFT) | (green << PF_GREEN_C_SHIFT) | \ | ||
954 | (red << PF_RED_C_SHIFT) | (c3 << PF_COMP_3_SHIFT) | \ | ||
955 | (c2 << PF_COMP_2_SHIFT) | (c1 << PF_COMP_1_SHIFT) | \ | ||
956 | (c0 << PF_COMP_0_SHIFT) | (size << PF_PIXEL_S_SHIFT)) | ||
957 | |||
958 | switch (bits_per_pixel) { | ||
959 | case 32: | ||
960 | /* 0x88883316 */ | ||
961 | return MAKE_PF(3, 2, 0, 1, 3, 8, 8, 8, 8); | ||
962 | case 24: | ||
963 | /* 0x88082219 */ | ||
964 | return MAKE_PF(4, 0, 1, 2, 2, 0, 8, 8, 8); | ||
965 | case 16: | ||
966 | /* 0x65053118 */ | ||
967 | return MAKE_PF(4, 2, 1, 0, 1, 5, 6, 5, 0); | ||
968 | default: | ||
969 | pr_err("fsl-diu: unsupported color depth %u\n", bits_per_pixel); | ||
970 | return 0; | ||
971 | } | ||
972 | } | ||
973 | |||
920 | /* | 974 | /* |
921 | * Using the fb_var_screeninfo in fb_info we set the resolution of this | 975 | * Using the fb_var_screeninfo in fb_info we set the resolution of this |
922 | * particular framebuffer. This function alters the fb_fix_screeninfo stored | 976 | * particular framebuffer. This function alters the fb_fix_screeninfo stored |
@@ -952,8 +1006,12 @@ static int fsl_diu_set_par(struct fb_info *info) | |||
952 | } | 1006 | } |
953 | } | 1007 | } |
954 | 1008 | ||
955 | ad->pix_fmt = diu_ops.get_pixel_format(data->monitor_port, | 1009 | if (diu_ops.get_pixel_format) |
956 | var->bits_per_pixel); | 1010 | ad->pix_fmt = diu_ops.get_pixel_format(data->monitor_port, |
1011 | var->bits_per_pixel); | ||
1012 | else | ||
1013 | ad->pix_fmt = fsl_diu_get_pixel_format(var->bits_per_pixel); | ||
1014 | |||
957 | ad->addr = cpu_to_le32(info->fix.smem_start); | 1015 | ad->addr = cpu_to_le32(info->fix.smem_start); |
958 | ad->src_size_g_alpha = cpu_to_le32((var->yres_virtual << 12) | | 1016 | ad->src_size_g_alpha = cpu_to_le32((var->yres_virtual << 12) | |
959 | var->xres_virtual) | mfbi->g_alpha; | 1017 | var->xres_virtual) | mfbi->g_alpha; |