All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: sm7xx: Use kernel framebuffer mode setting
@ 2011-05-06 17:24 Javier M. Mellid
  2011-05-06 21:22 ` Greg KH
  2011-05-07  1:11 ` [PATCH RESEND 1/1] " Javier M. Mellid
  0 siblings, 2 replies; 6+ messages in thread
From: Javier M. Mellid @ 2011-05-06 17:24 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, devel, Javier M. Mellid

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>
---
 drivers/staging/sm7xx/TODO     |    1 -
 drivers/staging/sm7xx/smtcfb.c |  112 +++++++++++++++++++++++++---------------
 2 files changed, 71 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/sm7xx/TODO b/drivers/staging/sm7xx/TODO
index a66d9e4..9750516 100644
--- a/drivers/staging/sm7xx/TODO
+++ b/drivers/staging/sm7xx/TODO
@@ -4,7 +4,6 @@ TODO:
 - use kernel coding style
 - checkpatch.pl clean
 - refine the code and remove unused code
-- use kernel framebuffer mode setting instead of hard code
 - move it to drivers/video/sm7xx/ or make it be drivers/video/sm7xxfb.c
 
 Please send any patches to Greg Kroah-Hartman <greg@kroah.com> and
diff --git a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xx/smtcfb.c
index 3e2230f..140c148 100644
--- a/drivers/staging/sm7xx/smtcfb.c
+++ b/drivers/staging/sm7xx/smtcfb.c
@@ -8,6 +8,9 @@
  * Copyright (C) 2009 Lemote, Inc.
  * Author: Wu Zhangjin, wuzhangjin@gmail.com
  *
+ * Copyright (C) 2011 Igalia, S.L.
+ * Author: Javier M. Mellid <jmunhoz@igalia.com>
+ *
  *  This file is subject to the terms and conditions of the GNU General Public
  *  License. See the file COPYING in the main directory of this archive for
  *  more details.
@@ -39,16 +42,16 @@
 #include <linux/pm.h>
 #endif
 
-struct screen_info smtc_screen_info;
-
 #include "smtcfb.h"
 
 #ifdef DEBUG
-#define smdbg(format, arg...)	printk(KERN_DEBUG format , ## arg)
+#define smdbg(format, arg...) printk(KERN_DEBUG format , ## arg)
 #else
 #define smdbg(format, arg...)
 #endif
 
+struct screen_info smtc_screen_info;
+
 /*
 * Private structure
 */
@@ -127,6 +130,29 @@ u16 smtc_ChipIDs[] = {
 
 #define numSMTCchipIDs (sizeof(smtc_ChipIDs) / sizeof(u16))
 
+static struct fb_var_screeninfo smtcfb_var = {
+	.xres           = 1024,
+	.yres           = 600,
+	.xres_virtual   = 1024,
+	.yres_virtual   = 600,
+	.bits_per_pixel = 16,
+	.red            = {16, 8, 0},
+	.green          = {8, 8, 0},
+	.blue           = {0, 8, 0},
+	.activate       = FB_ACTIVATE_NOW,
+	.height         = -1,
+	.width          = -1,
+	.vmode          = FB_VMODE_NONINTERLACED,
+};
+
+static struct fb_fix_screeninfo smtcfb_fix = {
+	.id             = "sm712fb",
+	.type           = FB_TYPE_PACKED_PIXELS,
+	.visual         = FB_VISUAL_TRUECOLOR,
+	.line_length    = 800 * 3,
+	.accel          = FB_ACCEL_SMI_LYNX,
+};
+
 static void sm712_set_timing(struct smtcfb_info *sfb,
 			     struct par_info *ppar_info)
 {
@@ -268,29 +294,6 @@ static void smtc_set_timing(struct smtcfb_info *sfb, struct par_info
 	}
 }
 
-static struct fb_var_screeninfo smtcfb_var = {
-	.xres = 1024,
-	.yres = 600,
-	.xres_virtual = 1024,
-	.yres_virtual = 600,
-	.bits_per_pixel = 16,
-	.red = {16, 8, 0},
-	.green = {8, 8, 0},
-	.blue = {0, 8, 0},
-	.activate = FB_ACTIVATE_NOW,
-	.height = -1,
-	.width = -1,
-	.vmode = FB_VMODE_NONINTERLACED,
-};
-
-static struct fb_fix_screeninfo smtcfb_fix = {
-	.id = "sm712fb",
-	.type = FB_TYPE_PACKED_PIXELS,
-	.visual = FB_VISUAL_TRUECOLOR,
-	.line_length = 800 * 3,
-	.accel = FB_ACCEL_SMI_LYNX,
-};
-
 /* chan_to_field
  *
  * 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,
 }
 #endif	/* ! __BIG_ENDIAN */
 
-static struct fb_ops smtcfb_ops = {
-	.owner = THIS_MODULE,
-	.fb_setcolreg = smtc_setcolreg,
-	.fb_blank = cfb_blank,
-	.fb_fillrect = cfb_fillrect,
-	.fb_imageblit = cfb_imageblit,
-	.fb_copyarea = cfb_copyarea,
-#ifdef __BIG_ENDIAN
-	.fb_read = smtcfb_read,
-	.fb_write = smtcfb_write,
-#endif
-
-};
-
 void smtcfb_setmode(struct smtcfb_info *sfb)
 {
 	switch (sfb->fb.var.bits_per_pixel) {
@@ -676,6 +665,47 @@ void smtcfb_setmode(struct smtcfb_info *sfb)
 	smtc_set_timing(sfb, &hw);
 }
 
+static int smtc_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
+{
+	/* sanity checks */
+	if (var->xres_virtual < var->xres)
+		var->xres_virtual = var->xres;
+
+	if (var->yres_virtual < var->yres)
+		var->yres_virtual = var->yres;
+
+	/* set valid default bpp */
+	if ((var->bits_per_pixel != 8)  && (var->bits_per_pixel != 16) &&
+	    (var->bits_per_pixel != 24) && (var->bits_per_pixel != 32))
+		var->bits_per_pixel = 16;
+
+	return 0;
+}
+
+static int smtc_set_par(struct fb_info *info)
+{
+	struct smtcfb_info *sfb = (struct smtcfb_info *)info;
+
+	smtcfb_setmode(sfb);
+
+	return 0;
+}
+
+static struct fb_ops smtcfb_ops = {
+	.owner        = THIS_MODULE,
+	.fb_check_var = smtc_check_var,
+	.fb_set_par   = smtc_set_par,
+	.fb_setcolreg = smtc_setcolreg,
+	.fb_blank     = cfb_blank,
+	.fb_fillrect  = cfb_fillrect,
+	.fb_imageblit = cfb_imageblit,
+	.fb_copyarea  = cfb_copyarea,
+#ifdef __BIG_ENDIAN
+	.fb_read      = smtcfb_read,
+	.fb_write     = smtcfb_write,
+#endif
+};
+
 /*
  * Alloc struct smtcfb_info and assign the default value
  */
@@ -796,7 +826,7 @@ static void smtc_free_fb_info(struct smtcfb_info *sfb)
  *	Returns zero.
  *
  */
-static int __init __maybe_unused sm712vga_setup(char *options)
+static int __init sm712vga_setup(char *options)
 {
 	int index;
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: sm7xx: Use kernel framebuffer mode setting
  2011-05-06 17:24 [PATCH] staging: sm7xx: Use kernel framebuffer mode setting Javier M. Mellid
@ 2011-05-06 21:22 ` Greg KH
  2011-05-06 22:26   ` Javier Muñoz
  2011-05-07  1:11 ` [PATCH RESEND 1/1] " Javier M. Mellid
  1 sibling, 1 reply; 6+ messages in thread
From: Greg KH @ 2011-05-06 21:22 UTC (permalink / raw)
  To: Javier M. Mellid; +Cc: gregkh, linux-kernel, devel

On Fri, May 06, 2011 at 07:24:56PM +0200, Javier M. Mellid wrote:
> 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>
> ---
>  drivers/staging/sm7xx/TODO     |    1 -

This applies with fuzz, this leads me to believe that you didn't test
this on the latest linux-next tree, right?

What did you make this patch against?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: sm7xx: Use kernel framebuffer mode setting
  2011-05-06 21:22 ` Greg KH
@ 2011-05-06 22:26   ` Javier Muñoz
  2011-05-06 23:55     ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Javier Muñoz @ 2011-05-06 22:26 UTC (permalink / raw)
  To: Greg KH; +Cc: gregkh, linux-kernel, devel

On 05/06/2011 11:22 PM, Greg KH wrote:
> On Fri, May 06, 2011 at 07:24:56PM +0200, Javier M. Mellid wrote:
>> 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>
>> ---
>>   drivers/staging/sm7xx/TODO     |    1 -
>
> This applies with fuzz, this leads me to believe that you didn't test
> this on the latest linux-next tree, right?
>
> What did you make this patch against?

Sorry, I didn't know. I made this patch against
linux-2.6 (bfd412db9e7b0d8f7b9c09d12d07aa2ac785f1d0) as I did with 
previous patches.

Testing was about creating, applying, compiling and running patch with 
kernel built from linux-2.6

Do you need a new patch against linux-next's master? I can redo this patch.

Sorry for the inconvenience.

javi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: sm7xx: Use kernel framebuffer mode setting
  2011-05-06 22:26   ` Javier Muñoz
@ 2011-05-06 23:55     ` Greg KH
  2011-05-07  1:16       ` Javier Muñoz
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2011-05-06 23:55 UTC (permalink / raw)
  To: Javier Muñoz; +Cc: Greg KH, linux-kernel, devel

On Sat, May 07, 2011 at 12:26:49AM +0200, Javier Muñoz wrote:
> On 05/06/2011 11:22 PM, Greg KH wrote:
> >On Fri, May 06, 2011 at 07:24:56PM +0200, Javier M. Mellid wrote:
> >>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>
> >>---
> >>  drivers/staging/sm7xx/TODO     |    1 -
> >
> >This applies with fuzz, this leads me to believe that you didn't test
> >this on the latest linux-next tree, right?
> >
> >What did you make this patch against?
> 
> Sorry, I didn't know. I made this patch against
> linux-2.6 (bfd412db9e7b0d8f7b9c09d12d07aa2ac785f1d0) as I did with
> previous patches.
> 
> Testing was about creating, applying, compiling and running patch
> with kernel built from linux-2.6
> 
> Do you need a new patch against linux-next's master? I can redo this patch.

Yes, please always make patches against linux-next as it includes any
other pending patches that are in my tree.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH RESEND 1/1] staging: sm7xx: Use kernel framebuffer mode setting
  2011-05-06 17:24 [PATCH] staging: sm7xx: Use kernel framebuffer mode setting Javier M. Mellid
  2011-05-06 21:22 ` Greg KH
@ 2011-05-07  1:11 ` Javier M. Mellid
  1 sibling, 0 replies; 6+ messages in thread
From: Javier M. Mellid @ 2011-05-07  1:11 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, devel, Javier M. Mellid

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>
---
 drivers/staging/sm7xx/TODO     |    1 -
 drivers/staging/sm7xx/smtcfb.c |  112 +++++++++++++++++++++++++---------------
 2 files changed, 71 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/sm7xx/TODO b/drivers/staging/sm7xx/TODO
index b0f5318..7304021 100644
--- a/drivers/staging/sm7xx/TODO
+++ b/drivers/staging/sm7xx/TODO
@@ -3,7 +3,6 @@ TODO:
 - 2D acceleration support
 - use kernel coding style
 - refine the code and remove unused code
-- use kernel framebuffer mode setting instead of hard code
 - move it to drivers/video/sm7xx/ or make it be drivers/video/sm7xxfb.c
 
 Please send any patches to Greg Kroah-Hartman <greg@kroah.com> and
diff --git a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xx/smtcfb.c
index c0d943f..94cb4e8 100644
--- a/drivers/staging/sm7xx/smtcfb.c
+++ b/drivers/staging/sm7xx/smtcfb.c
@@ -8,6 +8,9 @@
  * Copyright (C) 2009 Lemote, Inc.
  * Author: Wu Zhangjin, wuzhangjin@gmail.com
  *
+ * Copyright (C) 2011 Igalia, S.L.
+ * Author: Javier M. Mellid <jmunhoz@igalia.com>
+ *
  *  This file is subject to the terms and conditions of the GNU General Public
  *  License. See the file COPYING in the main directory of this archive for
  *  more details.
@@ -39,16 +42,16 @@
 #include <linux/pm.h>
 #endif
 
-struct screen_info smtc_screen_info;
-
 #include "smtcfb.h"
 
 #ifdef DEBUG
-#define smdbg(format, arg...)	printk(KERN_DEBUG format , ## arg)
+#define smdbg(format, arg...) printk(KERN_DEBUG format , ## arg)
 #else
 #define smdbg(format, arg...)
 #endif
 
+struct screen_info smtc_screen_info;
+
 /*
 * Private structure
 */
@@ -127,6 +130,29 @@ u16 smtc_ChipIDs[] = {
 
 #define numSMTCchipIDs (sizeof(smtc_ChipIDs) / sizeof(u16))
 
+static struct fb_var_screeninfo smtcfb_var = {
+	.xres           = 1024,
+	.yres           = 600,
+	.xres_virtual   = 1024,
+	.yres_virtual   = 600,
+	.bits_per_pixel = 16,
+	.red            = {16, 8, 0},
+	.green          = {8, 8, 0},
+	.blue           = {0, 8, 0},
+	.activate       = FB_ACTIVATE_NOW,
+	.height         = -1,
+	.width          = -1,
+	.vmode          = FB_VMODE_NONINTERLACED,
+};
+
+static struct fb_fix_screeninfo smtcfb_fix = {
+	.id             = "sm712fb",
+	.type           = FB_TYPE_PACKED_PIXELS,
+	.visual         = FB_VISUAL_TRUECOLOR,
+	.line_length    = 800 * 3,
+	.accel          = FB_ACCEL_SMI_LYNX,
+};
+
 static void sm712_set_timing(struct smtcfb_info *sfb,
 			     struct par_info *ppar_info)
 {
@@ -268,29 +294,6 @@ static void smtc_set_timing(struct smtcfb_info *sfb, struct par_info
 	}
 }
 
-static struct fb_var_screeninfo smtcfb_var = {
-	.xres = 1024,
-	.yres = 600,
-	.xres_virtual = 1024,
-	.yres_virtual = 600,
-	.bits_per_pixel = 16,
-	.red = {16, 8, 0},
-	.green = {8, 8, 0},
-	.blue = {0, 8, 0},
-	.activate = FB_ACTIVATE_NOW,
-	.height = -1,
-	.width = -1,
-	.vmode = FB_VMODE_NONINTERLACED,
-};
-
-static struct fb_fix_screeninfo smtcfb_fix = {
-	.id = "sm712fb",
-	.type = FB_TYPE_PACKED_PIXELS,
-	.visual = FB_VISUAL_TRUECOLOR,
-	.line_length = 800 * 3,
-	.accel = FB_ACCEL_SMI_LYNX,
-};
-
 /* chan_to_field
  *
  * 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,
 }
 #endif	/* ! __BIG_ENDIAN */
 
-static struct fb_ops smtcfb_ops = {
-	.owner = THIS_MODULE,
-	.fb_setcolreg = smtc_setcolreg,
-	.fb_blank = cfb_blank,
-	.fb_fillrect = cfb_fillrect,
-	.fb_imageblit = cfb_imageblit,
-	.fb_copyarea = cfb_copyarea,
-#ifdef __BIG_ENDIAN
-	.fb_read = smtcfb_read,
-	.fb_write = smtcfb_write,
-#endif
-
-};
-
 void smtcfb_setmode(struct smtcfb_info *sfb)
 {
 	switch (sfb->fb.var.bits_per_pixel) {
@@ -676,6 +665,47 @@ void smtcfb_setmode(struct smtcfb_info *sfb)
 	smtc_set_timing(sfb, &hw);
 }
 
+static int smtc_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
+{
+	/* sanity checks */
+	if (var->xres_virtual < var->xres)
+		var->xres_virtual = var->xres;
+
+	if (var->yres_virtual < var->yres)
+		var->yres_virtual = var->yres;
+
+	/* set valid default bpp */
+	if ((var->bits_per_pixel != 8)  && (var->bits_per_pixel != 16) &&
+	    (var->bits_per_pixel != 24) && (var->bits_per_pixel != 32))
+		var->bits_per_pixel = 16;
+
+	return 0;
+}
+
+static int smtc_set_par(struct fb_info *info)
+{
+	struct smtcfb_info *sfb = (struct smtcfb_info *)info;
+
+	smtcfb_setmode(sfb);
+
+	return 0;
+}
+
+static struct fb_ops smtcfb_ops = {
+	.owner        = THIS_MODULE,
+	.fb_check_var = smtc_check_var,
+	.fb_set_par   = smtc_set_par,
+	.fb_setcolreg = smtc_setcolreg,
+	.fb_blank     = cfb_blank,
+	.fb_fillrect  = cfb_fillrect,
+	.fb_imageblit = cfb_imageblit,
+	.fb_copyarea  = cfb_copyarea,
+#ifdef __BIG_ENDIAN
+	.fb_read      = smtcfb_read,
+	.fb_write     = smtcfb_write,
+#endif
+};
+
 /*
  * Alloc struct smtcfb_info and assign the default value
  */
@@ -796,7 +826,7 @@ static void smtc_free_fb_info(struct smtcfb_info *sfb)
  *	Returns zero.
  *
  */
-static int __init __maybe_unused sm712vga_setup(char *options)
+static int __init sm712vga_setup(char *options)
 {
 	int index;
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: sm7xx: Use kernel framebuffer mode setting
  2011-05-06 23:55     ` Greg KH
@ 2011-05-07  1:16       ` Javier Muñoz
  0 siblings, 0 replies; 6+ messages in thread
From: Javier Muñoz @ 2011-05-07  1:16 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, devel

[-- Attachment #1: Type: text/plain, Size: 1024 bytes --]

On 05/07/2011 01:55 AM, Greg KH wrote:
> On Sat, May 07, 2011 at 12:26:49AM +0200, Javier Muñoz wrote:
>> On 05/06/2011 11:22 PM, Greg KH wrote:
>>> On Fri, May 06, 2011 at 07:24:56PM +0200, Javier M. Mellid wrote:
>>>> This patch implements dynamic framebuffer mode setting.
[...]
>>>
>>> This applies with fuzz, this leads me to believe that you didn't test
>>> this on the latest linux-next tree, right?
>>>
>>> What did you make this patch against?
>>
>> Sorry, I didn't know. I made this patch against
>> linux-2.6 (bfd412db9e7b0d8f7b9c09d12d07aa2ac785f1d0) as I did with
>> previous patches.
>>
>> Testing was about creating, applying, compiling and running patch
>> with kernel built from linux-2.6
>>
>> Do you need a new patch against linux-next's master? I can redo this patch.
>
> Yes, please always make patches against linux-next as it includes any
> other pending patches that are in my tree.

OK, just resending a new patch made against linux-next. Please, let me 
know if it applies seamless.

Thanks!

javi

[-- Attachment #2: 0001-staging-sm7xx-Use-kernel-framebuffer-mode-setting.patch --]
[-- Type: text/x-diff, Size: 5921 bytes --]

>From 544f73e7e6f5e4e42f4384f82ee9b4bffe889efb Mon Sep 17 00:00:00 2001
From: Javier M. Mellid <jmunhoz@igalia.com>
Date: Sat, 7 May 2011 01:57:43 +0200
Subject: [PATCH] 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>
---
 drivers/staging/sm7xx/TODO     |    1 -
 drivers/staging/sm7xx/smtcfb.c |  112 +++++++++++++++++++++++++---------------
 2 files changed, 71 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/sm7xx/TODO b/drivers/staging/sm7xx/TODO
index b0f5318..7304021 100644
--- a/drivers/staging/sm7xx/TODO
+++ b/drivers/staging/sm7xx/TODO
@@ -3,7 +3,6 @@ TODO:
 - 2D acceleration support
 - use kernel coding style
 - refine the code and remove unused code
-- use kernel framebuffer mode setting instead of hard code
 - move it to drivers/video/sm7xx/ or make it be drivers/video/sm7xxfb.c
 
 Please send any patches to Greg Kroah-Hartman <greg@kroah.com> and
diff --git a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xx/smtcfb.c
index c0d943f..94cb4e8 100644
--- a/drivers/staging/sm7xx/smtcfb.c
+++ b/drivers/staging/sm7xx/smtcfb.c
@@ -8,6 +8,9 @@
  * Copyright (C) 2009 Lemote, Inc.
  * Author: Wu Zhangjin, wuzhangjin@gmail.com
  *
+ * Copyright (C) 2011 Igalia, S.L.
+ * Author: Javier M. Mellid <jmunhoz@igalia.com>
+ *
  *  This file is subject to the terms and conditions of the GNU General Public
  *  License. See the file COPYING in the main directory of this archive for
  *  more details.
@@ -39,16 +42,16 @@
 #include <linux/pm.h>
 #endif
 
-struct screen_info smtc_screen_info;
-
 #include "smtcfb.h"
 
 #ifdef DEBUG
-#define smdbg(format, arg...)	printk(KERN_DEBUG format , ## arg)
+#define smdbg(format, arg...) printk(KERN_DEBUG format , ## arg)
 #else
 #define smdbg(format, arg...)
 #endif
 
+struct screen_info smtc_screen_info;
+
 /*
 * Private structure
 */
@@ -127,6 +130,29 @@ u16 smtc_ChipIDs[] = {
 
 #define numSMTCchipIDs (sizeof(smtc_ChipIDs) / sizeof(u16))
 
+static struct fb_var_screeninfo smtcfb_var = {
+	.xres           = 1024,
+	.yres           = 600,
+	.xres_virtual   = 1024,
+	.yres_virtual   = 600,
+	.bits_per_pixel = 16,
+	.red            = {16, 8, 0},
+	.green          = {8, 8, 0},
+	.blue           = {0, 8, 0},
+	.activate       = FB_ACTIVATE_NOW,
+	.height         = -1,
+	.width          = -1,
+	.vmode          = FB_VMODE_NONINTERLACED,
+};
+
+static struct fb_fix_screeninfo smtcfb_fix = {
+	.id             = "sm712fb",
+	.type           = FB_TYPE_PACKED_PIXELS,
+	.visual         = FB_VISUAL_TRUECOLOR,
+	.line_length    = 800 * 3,
+	.accel          = FB_ACCEL_SMI_LYNX,
+};
+
 static void sm712_set_timing(struct smtcfb_info *sfb,
 			     struct par_info *ppar_info)
 {
@@ -268,29 +294,6 @@ static void smtc_set_timing(struct smtcfb_info *sfb, struct par_info
 	}
 }
 
-static struct fb_var_screeninfo smtcfb_var = {
-	.xres = 1024,
-	.yres = 600,
-	.xres_virtual = 1024,
-	.yres_virtual = 600,
-	.bits_per_pixel = 16,
-	.red = {16, 8, 0},
-	.green = {8, 8, 0},
-	.blue = {0, 8, 0},
-	.activate = FB_ACTIVATE_NOW,
-	.height = -1,
-	.width = -1,
-	.vmode = FB_VMODE_NONINTERLACED,
-};
-
-static struct fb_fix_screeninfo smtcfb_fix = {
-	.id = "sm712fb",
-	.type = FB_TYPE_PACKED_PIXELS,
-	.visual = FB_VISUAL_TRUECOLOR,
-	.line_length = 800 * 3,
-	.accel = FB_ACCEL_SMI_LYNX,
-};
-
 /* chan_to_field
  *
  * 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,
 }
 #endif	/* ! __BIG_ENDIAN */
 
-static struct fb_ops smtcfb_ops = {
-	.owner = THIS_MODULE,
-	.fb_setcolreg = smtc_setcolreg,
-	.fb_blank = cfb_blank,
-	.fb_fillrect = cfb_fillrect,
-	.fb_imageblit = cfb_imageblit,
-	.fb_copyarea = cfb_copyarea,
-#ifdef __BIG_ENDIAN
-	.fb_read = smtcfb_read,
-	.fb_write = smtcfb_write,
-#endif
-
-};
-
 void smtcfb_setmode(struct smtcfb_info *sfb)
 {
 	switch (sfb->fb.var.bits_per_pixel) {
@@ -676,6 +665,47 @@ void smtcfb_setmode(struct smtcfb_info *sfb)
 	smtc_set_timing(sfb, &hw);
 }
 
+static int smtc_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
+{
+	/* sanity checks */
+	if (var->xres_virtual < var->xres)
+		var->xres_virtual = var->xres;
+
+	if (var->yres_virtual < var->yres)
+		var->yres_virtual = var->yres;
+
+	/* set valid default bpp */
+	if ((var->bits_per_pixel != 8)  && (var->bits_per_pixel != 16) &&
+	    (var->bits_per_pixel != 24) && (var->bits_per_pixel != 32))
+		var->bits_per_pixel = 16;
+
+	return 0;
+}
+
+static int smtc_set_par(struct fb_info *info)
+{
+	struct smtcfb_info *sfb = (struct smtcfb_info *)info;
+
+	smtcfb_setmode(sfb);
+
+	return 0;
+}
+
+static struct fb_ops smtcfb_ops = {
+	.owner        = THIS_MODULE,
+	.fb_check_var = smtc_check_var,
+	.fb_set_par   = smtc_set_par,
+	.fb_setcolreg = smtc_setcolreg,
+	.fb_blank     = cfb_blank,
+	.fb_fillrect  = cfb_fillrect,
+	.fb_imageblit = cfb_imageblit,
+	.fb_copyarea  = cfb_copyarea,
+#ifdef __BIG_ENDIAN
+	.fb_read      = smtcfb_read,
+	.fb_write     = smtcfb_write,
+#endif
+};
+
 /*
  * Alloc struct smtcfb_info and assign the default value
  */
@@ -796,7 +826,7 @@ static void smtc_free_fb_info(struct smtcfb_info *sfb)
  *	Returns zero.
  *
  */
-static int __init __maybe_unused sm712vga_setup(char *options)
+static int __init sm712vga_setup(char *options)
 {
 	int index;
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-05-07  1:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-06 17:24 [PATCH] staging: sm7xx: Use kernel framebuffer mode setting Javier M. Mellid
2011-05-06 21:22 ` Greg KH
2011-05-06 22:26   ` Javier Muñoz
2011-05-06 23:55     ` Greg KH
2011-05-07  1:16       ` Javier Muñoz
2011-05-07  1:11 ` [PATCH RESEND 1/1] " Javier M. Mellid

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.