aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/sm7xx/smtcfb.c
diff options
context:
space:
mode:
authorJavier M. Mellid <jmunhoz@igalia.com>2011-05-06 21:11:58 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-05-06 21:33:13 -0400
commitdc762c4f8514f23094927e0a62ef305d90651535 (patch)
treee3c71c91a4e22cd2c986cec0664f80a1f07f0e44 /drivers/staging/sm7xx/smtcfb.c
parent4ce0a41f1054b58801f7e14f5036cf27a75152e2 (diff)
staging: sm7xx: Use kernel framebuffer mode setting
This patch implements dynamic framebuffer mode setting. Previous code works with mode setting in a hard code way. Previous hard code configuration is used as default configuration if dynamic mode setting or boot mode setting (via sm712vga_setup) is not used. Tested with SM712 supporting 1024x600x16 as default hardware resolution. Changes: - Implement fb_check_var and fb_set_par callbacks - Remove __maybe_unused decorator in function being used (sm712vga_setup) - Minor cleanup on initialization structs related with mode settings - Updated author copyright - Updated TODO file Signed-off-by: Javier M. Mellid <jmunhoz@igalia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/sm7xx/smtcfb.c')
-rw-r--r--drivers/staging/sm7xx/smtcfb.c112
1 files changed, 71 insertions, 41 deletions
diff --git a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xx/smtcfb.c
index c0d943f498c..94cb4e8dcaf 100644
--- a/drivers/staging/sm7xx/smtcfb.c
+++ b/drivers/staging/sm7xx/smtcfb.c
@@ -8,6 +8,9 @@
8 * Copyright (C) 2009 Lemote, Inc. 8 * Copyright (C) 2009 Lemote, Inc.
9 * Author: Wu Zhangjin, wuzhangjin@gmail.com 9 * Author: Wu Zhangjin, wuzhangjin@gmail.com
10 * 10 *
11 * Copyright (C) 2011 Igalia, S.L.
12 * Author: Javier M. Mellid <jmunhoz@igalia.com>
13 *
11 * This file is subject to the terms and conditions of the GNU General Public 14 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file COPYING in the main directory of this archive for 15 * License. See the file COPYING in the main directory of this archive for
13 * more details. 16 * more details.
@@ -39,16 +42,16 @@
39#include <linux/pm.h> 42#include <linux/pm.h>
40#endif 43#endif
41 44
42struct screen_info smtc_screen_info;
43
44#include "smtcfb.h" 45#include "smtcfb.h"
45 46
46#ifdef DEBUG 47#ifdef DEBUG
47#define smdbg(format, arg...) printk(KERN_DEBUG format , ## arg) 48#define smdbg(format, arg...) printk(KERN_DEBUG format , ## arg)
48#else 49#else
49#define smdbg(format, arg...) 50#define smdbg(format, arg...)
50#endif 51#endif
51 52
53struct screen_info smtc_screen_info;
54
52/* 55/*
53* Private structure 56* Private structure
54*/ 57*/
@@ -127,6 +130,29 @@ u16 smtc_ChipIDs[] = {
127 130
128#define numSMTCchipIDs (sizeof(smtc_ChipIDs) / sizeof(u16)) 131#define numSMTCchipIDs (sizeof(smtc_ChipIDs) / sizeof(u16))
129 132
133static struct fb_var_screeninfo smtcfb_var = {
134 .xres = 1024,
135 .yres = 600,
136 .xres_virtual = 1024,
137 .yres_virtual = 600,
138 .bits_per_pixel = 16,
139 .red = {16, 8, 0},
140 .green = {8, 8, 0},
141 .blue = {0, 8, 0},
142 .activate = FB_ACTIVATE_NOW,
143 .height = -1,
144 .width = -1,
145 .vmode = FB_VMODE_NONINTERLACED,
146};
147
148static struct fb_fix_screeninfo smtcfb_fix = {
149 .id = "sm712fb",
150 .type = FB_TYPE_PACKED_PIXELS,
151 .visual = FB_VISUAL_TRUECOLOR,
152 .line_length = 800 * 3,
153 .accel = FB_ACCEL_SMI_LYNX,
154};
155
130static void sm712_set_timing(struct smtcfb_info *sfb, 156static void sm712_set_timing(struct smtcfb_info *sfb,
131 struct par_info *ppar_info) 157 struct par_info *ppar_info)
132{ 158{
@@ -268,29 +294,6 @@ static void smtc_set_timing(struct smtcfb_info *sfb, struct par_info
268 } 294 }
269} 295}
270 296
271static struct fb_var_screeninfo smtcfb_var = {
272 .xres = 1024,
273 .yres = 600,
274 .xres_virtual = 1024,
275 .yres_virtual = 600,
276 .bits_per_pixel = 16,
277 .red = {16, 8, 0},
278 .green = {8, 8, 0},
279 .blue = {0, 8, 0},
280 .activate = FB_ACTIVATE_NOW,
281 .height = -1,
282 .width = -1,
283 .vmode = FB_VMODE_NONINTERLACED,
284};
285
286static struct fb_fix_screeninfo smtcfb_fix = {
287 .id = "sm712fb",
288 .type = FB_TYPE_PACKED_PIXELS,
289 .visual = FB_VISUAL_TRUECOLOR,
290 .line_length = 800 * 3,
291 .accel = FB_ACCEL_SMI_LYNX,
292};
293
294/* chan_to_field 297/* chan_to_field
295 * 298 *
296 * convert a colour value into a field position 299 * convert a colour value into a field position
@@ -604,20 +607,6 @@ smtcfb_write(struct fb_info *info, const char __user *buf, size_t count,
604} 607}
605#endif /* ! __BIG_ENDIAN */ 608#endif /* ! __BIG_ENDIAN */
606 609
607static struct fb_ops smtcfb_ops = {
608 .owner = THIS_MODULE,
609 .fb_setcolreg = smtc_setcolreg,
610 .fb_blank = cfb_blank,
611 .fb_fillrect = cfb_fillrect,
612 .fb_imageblit = cfb_imageblit,
613 .fb_copyarea = cfb_copyarea,
614#ifdef __BIG_ENDIAN
615 .fb_read = smtcfb_read,
616 .fb_write = smtcfb_write,
617#endif
618
619};
620
621void smtcfb_setmode(struct smtcfb_info *sfb) 610void smtcfb_setmode(struct smtcfb_info *sfb)
622{ 611{
623 switch (sfb->fb.var.bits_per_pixel) { 612 switch (sfb->fb.var.bits_per_pixel) {
@@ -676,6 +665,47 @@ void smtcfb_setmode(struct smtcfb_info *sfb)
676 smtc_set_timing(sfb, &hw); 665 smtc_set_timing(sfb, &hw);
677} 666}
678 667
668static int smtc_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
669{
670 /* sanity checks */
671 if (var->xres_virtual < var->xres)
672 var->xres_virtual = var->xres;
673
674 if (var->yres_virtual < var->yres)
675 var->yres_virtual = var->yres;
676
677 /* set valid default bpp */
678 if ((var->bits_per_pixel != 8) && (var->bits_per_pixel != 16) &&
679 (var->bits_per_pixel != 24) && (var->bits_per_pixel != 32))
680 var->bits_per_pixel = 16;
681
682 return 0;
683}
684
685static int smtc_set_par(struct fb_info *info)
686{
687 struct smtcfb_info *sfb = (struct smtcfb_info *)info;
688
689 smtcfb_setmode(sfb);
690
691 return 0;
692}
693
694static struct fb_ops smtcfb_ops = {
695 .owner = THIS_MODULE,
696 .fb_check_var = smtc_check_var,
697 .fb_set_par = smtc_set_par,
698 .fb_setcolreg = smtc_setcolreg,
699 .fb_blank = cfb_blank,
700 .fb_fillrect = cfb_fillrect,
701 .fb_imageblit = cfb_imageblit,
702 .fb_copyarea = cfb_copyarea,
703#ifdef __BIG_ENDIAN
704 .fb_read = smtcfb_read,
705 .fb_write = smtcfb_write,
706#endif
707};
708
679/* 709/*
680 * Alloc struct smtcfb_info and assign the default value 710 * Alloc struct smtcfb_info and assign the default value
681 */ 711 */
@@ -796,7 +826,7 @@ static void smtc_free_fb_info(struct smtcfb_info *sfb)
796 * Returns zero. 826 * Returns zero.
797 * 827 *
798 */ 828 */
799static int __init __maybe_unused sm712vga_setup(char *options) 829static int __init sm712vga_setup(char *options)
800{ 830{
801 int index; 831 int index;
802 832