All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] staging: sm7xxfb: code improvements and cleanup
@ 2012-07-11 13:49 Javier M. Mellid
  2012-07-11 13:49 ` [PATCH 1/9] staging: sm7xxfb: fix struct names related to vesa modes Javier M. Mellid
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Javier M. Mellid @ 2012-07-11 13:49 UTC (permalink / raw)
  To: gregkh, gewang; +Cc: devel, linux-kernel, Javier M. Mellid

From: "Javier M. Mellid" <jmunhoz@igalia.com>

This patchset is part of the effort to get sm7xxfb in shape. It resolves
some issues in functions related with mode setting and timing logic
paths.

The first 5 patches work on sm712vga_setup in order to get a more
coherent and clear code.

Patches 6 and 7 work on timing path. They rename sm712_set_timing
together with the proper code relocation to ease reviewing and
maintenance.

Patch 8 erases a global variable. This patch moves pseudo palette into
smtcfb_info.

Patch 9 cleans on smtc_alloc_fb_info. This change looks for coherency
with the rest of functions.

Patches 3 and 5 warn about the same line going over 80 chars when
checked with checkpatch. I think it makes sense going over 80 chars in
this case since the readability improves.

Tested with SM712.

Javier M. Mellid (9):
  staging: sm7xxfb: fix struct names related to vesa modes
  staging: sm7xxfb: rename index var on sm712vga_setup
  staging: sm7xxfb: rename smtc_screen_info to smtc_scr_info
  staging: sm7xxfb: rename sm712vga_setup to sm7xx_vga_setup
  staging: sm7xxfb: minor maintenance on sm7xx_vga_setup
  staging: sm7xxfb: rename sm712_set_timing to sm7xx_set_timing
  staging: sm7xxfb: minor maintenance on timing path
  staging: sm7xxfb: move pseudo palette into smtcfb_info
  staging: sm7xxfb: cleanup on smtc_alloc_fb_info

 drivers/staging/sm7xxfb/sm7xxfb.c |  374 ++++++++++++++++++-------------------
 1 file changed, 183 insertions(+), 191 deletions(-)

-- 
1.7.10


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

* [PATCH 1/9] staging: sm7xxfb: fix struct names related to vesa modes
  2012-07-11 13:49 [PATCH 0/9] staging: sm7xxfb: code improvements and cleanup Javier M. Mellid
@ 2012-07-11 13:49 ` Javier M. Mellid
  2012-07-11 13:49 ` [PATCH 2/9] staging: sm7xxfb: rename index var on sm712vga_setup Javier M. Mellid
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Javier M. Mellid @ 2012-07-11 13:49 UTC (permalink / raw)
  To: gregkh, gewang; +Cc: devel, linux-kernel, Javier M. Mellid

From: "Javier M. Mellid" <jmunhoz@igalia.com>

This patch renames structs related to vesa modes in order to get more
readable code on sm712vga_setup.

Tested with SM712.

Signed-off-by: Javier M. Mellid <jmunhoz@igalia.com>
---
 drivers/staging/sm7xxfb/sm7xxfb.c |   24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c
index e3511ec..28aa903 100644
--- a/drivers/staging/sm7xxfb/sm7xxfb.c
+++ b/drivers/staging/sm7xxfb/sm7xxfb.c
@@ -56,14 +56,14 @@ struct smtcfb_info {
 	u_int hz;
 };
 
-struct vesa_mode_table	{
-	char mode_index[6];
-	u16 lfb_width;
-	u16 lfb_height;
-	u16 lfb_depth;
+struct vesa_mode {
+	char index[6];
+	u16  lfb_width;
+	u16  lfb_height;
+	u16  lfb_depth;
 };
 
-static struct vesa_mode_table vesa_mode[] = {
+static struct vesa_mode vesa_mode_table[] = {
 	{"0x301", 640,  480,  8},
 	{"0x303", 800,  600,  8},
 	{"0x305", 1024, 768,  8},
@@ -776,13 +776,15 @@ static int __init sm712vga_setup(char *options)
 	pr_debug("sm712vga_setup = %s\n", options);
 
 	for (index = 0;
-	     index < ARRAY_SIZE(vesa_mode);
+	     index < ARRAY_SIZE(vesa_mode_table);
 	     index++) {
-		if (strstr(options, vesa_mode[index].mode_index)) {
-			smtc_screen_info.lfb_width = vesa_mode[index].lfb_width;
+		if (strstr(options, vesa_mode_table[index].index)) {
+			smtc_screen_info.lfb_width =
+				vesa_mode_table[index].lfb_width;
 			smtc_screen_info.lfb_height =
-					vesa_mode[index].lfb_height;
-			smtc_screen_info.lfb_depth = vesa_mode[index].lfb_depth;
+				vesa_mode_table[index].lfb_height;
+			smtc_screen_info.lfb_depth =
+				vesa_mode_table[index].lfb_depth;
 			return 0;
 		}
 	}
-- 
1.7.10


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

* [PATCH 2/9] staging: sm7xxfb: rename index var on sm712vga_setup
  2012-07-11 13:49 [PATCH 0/9] staging: sm7xxfb: code improvements and cleanup Javier M. Mellid
  2012-07-11 13:49 ` [PATCH 1/9] staging: sm7xxfb: fix struct names related to vesa modes Javier M. Mellid
@ 2012-07-11 13:49 ` Javier M. Mellid
  2012-07-11 13:49 ` [PATCH 3/9] staging: sm7xxfb: rename smtc_screen_info to smtc_scr_info Javier M. Mellid
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Javier M. Mellid @ 2012-07-11 13:49 UTC (permalink / raw)
  To: gregkh, gewang; +Cc: devel, linux-kernel, Javier M. Mellid

From: "Javier M. Mellid" <jmunhoz@igalia.com>

This patchs renames index var on sm712vga_setup.

Tested with SM712.

Signed-off-by: Javier M. Mellid <jmunhoz@igalia.com>
---
 drivers/staging/sm7xxfb/sm7xxfb.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c
index 28aa903..88d4b79 100644
--- a/drivers/staging/sm7xxfb/sm7xxfb.c
+++ b/drivers/staging/sm7xxfb/sm7xxfb.c
@@ -764,7 +764,7 @@ static inline void sm7xx_init_hw(void)
  */
 static int __init sm712vga_setup(char *options)
 {
-	int index;
+	int i;
 
 	if (!options || !*options)
 		return -EINVAL;
@@ -775,16 +775,14 @@ static int __init sm712vga_setup(char *options)
 
 	pr_debug("sm712vga_setup = %s\n", options);
 
-	for (index = 0;
-	     index < ARRAY_SIZE(vesa_mode_table);
-	     index++) {
-		if (strstr(options, vesa_mode_table[index].index)) {
+	for (i = 0; i < ARRAY_SIZE(vesa_mode_table); i++) {
+		if (strstr(options, vesa_mode_table[i].index)) {
 			smtc_screen_info.lfb_width =
-				vesa_mode_table[index].lfb_width;
+				vesa_mode_table[i].lfb_width;
 			smtc_screen_info.lfb_height =
-				vesa_mode_table[index].lfb_height;
+				vesa_mode_table[i].lfb_height;
 			smtc_screen_info.lfb_depth =
-				vesa_mode_table[index].lfb_depth;
+				vesa_mode_table[i].lfb_depth;
 			return 0;
 		}
 	}
-- 
1.7.10


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

* [PATCH 3/9] staging: sm7xxfb: rename smtc_screen_info to smtc_scr_info
  2012-07-11 13:49 [PATCH 0/9] staging: sm7xxfb: code improvements and cleanup Javier M. Mellid
  2012-07-11 13:49 ` [PATCH 1/9] staging: sm7xxfb: fix struct names related to vesa modes Javier M. Mellid
  2012-07-11 13:49 ` [PATCH 2/9] staging: sm7xxfb: rename index var on sm712vga_setup Javier M. Mellid
@ 2012-07-11 13:49 ` Javier M. Mellid
  2012-07-11 13:49 ` [PATCH 4/9] staging: sm7xxfb: rename sm712vga_setup to sm7xx_vga_setup Javier M. Mellid
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Javier M. Mellid @ 2012-07-11 13:49 UTC (permalink / raw)
  To: gregkh, gewang; +Cc: devel, linux-kernel, Javier M. Mellid

From: "Javier M. Mellid" <jmunhoz@igalia.com>

This change of name improves readability on sm712_vga_setup and
smtcfb_pci_probe. It is coherent with the name of vars being used on
code while avoiding the use of extra long lines in functions.

Tested with SM712.

Signed-off-by: Javier M. Mellid <jmunhoz@igalia.com>
---
 drivers/staging/sm7xxfb/sm7xxfb.c |   27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c
index 88d4b79..d7d37bd 100644
--- a/drivers/staging/sm7xxfb/sm7xxfb.c
+++ b/drivers/staging/sm7xxfb/sm7xxfb.c
@@ -34,7 +34,7 @@
 
 #include "sm7xx.h"
 
-struct screen_info smtc_screen_info;
+struct screen_info smtc_scr_info;
 
 /*
 * Private structure
@@ -769,20 +769,17 @@ static int __init sm712vga_setup(char *options)
 	if (!options || !*options)
 		return -EINVAL;
 
-	smtc_screen_info.lfb_width = 0;
-	smtc_screen_info.lfb_height = 0;
-	smtc_screen_info.lfb_depth = 0;
+	smtc_scr_info.lfb_width = 0;
+	smtc_scr_info.lfb_height = 0;
+	smtc_scr_info.lfb_depth = 0;
 
 	pr_debug("sm712vga_setup = %s\n", options);
 
 	for (i = 0; i < ARRAY_SIZE(vesa_mode_table); i++) {
 		if (strstr(options, vesa_mode_table[i].index)) {
-			smtc_screen_info.lfb_width =
-				vesa_mode_table[i].lfb_width;
-			smtc_screen_info.lfb_height =
-				vesa_mode_table[i].lfb_height;
-			smtc_screen_info.lfb_depth =
-				vesa_mode_table[i].lfb_depth;
+			smtc_scr_info.lfb_width  = vesa_mode_table[i].lfb_width;
+			smtc_scr_info.lfb_height = vesa_mode_table[i].lfb_height;
+			smtc_scr_info.lfb_depth  = vesa_mode_table[i].lfb_depth;
 			return 0;
 		}
 	}
@@ -818,11 +815,11 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
 
 	sm7xx_init_hw();
 
-	/*get mode parameter from smtc_screen_info */
-	if (smtc_screen_info.lfb_width != 0) {
-		sfb->fb.var.xres = smtc_screen_info.lfb_width;
-		sfb->fb.var.yres = smtc_screen_info.lfb_height;
-		sfb->fb.var.bits_per_pixel = smtc_screen_info.lfb_depth;
+	/* get mode parameter from smtc_scr_info */
+	if (smtc_scr_info.lfb_width != 0) {
+		sfb->fb.var.xres = smtc_scr_info.lfb_width;
+		sfb->fb.var.yres = smtc_scr_info.lfb_height;
+		sfb->fb.var.bits_per_pixel = smtc_scr_info.lfb_depth;
 	} else {
 		/* default resolution 1024x600 16bit mode */
 		sfb->fb.var.xres = SCREEN_X_RES;
-- 
1.7.10


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

* [PATCH 4/9] staging: sm7xxfb: rename sm712vga_setup to sm7xx_vga_setup
  2012-07-11 13:49 [PATCH 0/9] staging: sm7xxfb: code improvements and cleanup Javier M. Mellid
                   ` (2 preceding siblings ...)
  2012-07-11 13:49 ` [PATCH 3/9] staging: sm7xxfb: rename smtc_screen_info to smtc_scr_info Javier M. Mellid
@ 2012-07-11 13:49 ` Javier M. Mellid
  2012-07-11 13:49 ` [PATCH 5/9] staging: sm7xxfb: minor maintenance on sm7xx_vga_setup Javier M. Mellid
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Javier M. Mellid @ 2012-07-11 13:49 UTC (permalink / raw)
  To: gregkh, gewang; +Cc: devel, linux-kernel, Javier M. Mellid

From: "Javier M. Mellid" <jmunhoz@igalia.com>

This patch renames sm712vga_setup to sm7xx_vga_setup. sm7xx_vga_setup
process command line options in order to get the vga parameter. This
parameter will be the lookup index to match the right vesa mode. It is
chip independent.

Signed-off-by: Javier M. Mellid <jmunhoz@igalia.com>
---
 drivers/staging/sm7xxfb/sm7xxfb.c |   13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c
index d7d37bd..7a597fd 100644
--- a/drivers/staging/sm7xxfb/sm7xxfb.c
+++ b/drivers/staging/sm7xxfb/sm7xxfb.c
@@ -756,13 +756,8 @@ static inline void sm7xx_init_hw(void)
 	outb_p(0x11, 0x3c5);
 }
 
-/*
- *	sm712vga_setup - process command line options, get vga parameter
- *	@options: string of options
- *	Returns zero.
- *
- */
-static int __init sm712vga_setup(char *options)
+/* process command line options, get vga parameter */
+static int __init sm7xx_vga_setup(char *options)
 {
 	int i;
 
@@ -773,7 +768,7 @@ static int __init sm712vga_setup(char *options)
 	smtc_scr_info.lfb_height = 0;
 	smtc_scr_info.lfb_depth = 0;
 
-	pr_debug("sm712vga_setup = %s\n", options);
+	pr_debug("sm7xx_vga_setup = %s\n", options);
 
 	for (i = 0; i < ARRAY_SIZE(vesa_mode_table); i++) {
 		if (strstr(options, vesa_mode_table[i].index)) {
@@ -786,7 +781,7 @@ static int __init sm712vga_setup(char *options)
 
 	return -1;
 }
-__setup("vga=", sm712vga_setup);
+__setup("vga=", sm7xx_vga_setup);
 
 static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
 				   const struct pci_device_id *ent)
-- 
1.7.10


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

* [PATCH 5/9] staging: sm7xxfb: minor maintenance on sm7xx_vga_setup
  2012-07-11 13:49 [PATCH 0/9] staging: sm7xxfb: code improvements and cleanup Javier M. Mellid
                   ` (3 preceding siblings ...)
  2012-07-11 13:49 ` [PATCH 4/9] staging: sm7xxfb: rename sm712vga_setup to sm7xx_vga_setup Javier M. Mellid
@ 2012-07-11 13:49 ` Javier M. Mellid
  2012-07-11 13:49 ` [PATCH 6/9] staging: sm7xxfb: rename sm712_set_timing to sm7xx_set_timing Javier M. Mellid
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Javier M. Mellid @ 2012-07-11 13:49 UTC (permalink / raw)
  To: gregkh, gewang; +Cc: devel, linux-kernel, Javier M. Mellid

From: "Javier M. Mellid" <jmunhoz@igalia.com>

This patch keeps code related to sm7xx_vga_setup closed. It is useful to
understand/maintain the logic behind sm7xx_vga_setup with a simple look.

Tested with SM712.

Signed-off-by: Javier M. Mellid <jmunhoz@igalia.com>
---
 drivers/staging/sm7xxfb/sm7xxfb.c |  106 ++++++++++++++++++-------------------
 1 file changed, 53 insertions(+), 53 deletions(-)

diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c
index 7a597fd..ac49c98 100644
--- a/drivers/staging/sm7xxfb/sm7xxfb.c
+++ b/drivers/staging/sm7xxfb/sm7xxfb.c
@@ -34,8 +34,6 @@
 
 #include "sm7xx.h"
 
-struct screen_info smtc_scr_info;
-
 /*
 * Private structure
 */
@@ -56,30 +54,6 @@ struct smtcfb_info {
 	u_int hz;
 };
 
-struct vesa_mode {
-	char index[6];
-	u16  lfb_width;
-	u16  lfb_height;
-	u16  lfb_depth;
-};
-
-static struct vesa_mode vesa_mode_table[] = {
-	{"0x301", 640,  480,  8},
-	{"0x303", 800,  600,  8},
-	{"0x305", 1024, 768,  8},
-	{"0x307", 1280, 1024, 8},
-
-	{"0x311", 640,  480,  16},
-	{"0x314", 800,  600,  16},
-	{"0x317", 1024, 768,  16},
-	{"0x31A", 1280, 1024, 16},
-
-	{"0x312", 640,  480,  24},
-	{"0x315", 800,  600,  24},
-	{"0x318", 1024, 768,  24},
-	{"0x31B", 1280, 1024, 24},
-};
-
 char __iomem *smtc_RegBaseAddress;	/* Memory Map IO starting address */
 char __iomem *smtc_VRAMBaseAddress;	/* video memory starting address */
 
@@ -108,6 +82,59 @@ static struct fb_fix_screeninfo smtcfb_fix = {
 	.accel          = FB_ACCEL_SMI_LYNX,
 };
 
+struct vesa_mode {
+	char index[6];
+	u16  lfb_width;
+	u16  lfb_height;
+	u16  lfb_depth;
+};
+
+static struct vesa_mode vesa_mode_table[] = {
+	{"0x301", 640,  480,  8},
+	{"0x303", 800,  600,  8},
+	{"0x305", 1024, 768,  8},
+	{"0x307", 1280, 1024, 8},
+
+	{"0x311", 640,  480,  16},
+	{"0x314", 800,  600,  16},
+	{"0x317", 1024, 768,  16},
+	{"0x31A", 1280, 1024, 16},
+
+	{"0x312", 640,  480,  24},
+	{"0x315", 800,  600,  24},
+	{"0x318", 1024, 768,  24},
+	{"0x31B", 1280, 1024, 24},
+};
+
+struct screen_info smtc_scr_info;
+
+/* process command line options, get vga parameter */
+static int __init sm7xx_vga_setup(char *options)
+{
+	int i;
+
+	if (!options || !*options)
+		return -EINVAL;
+
+	smtc_scr_info.lfb_width = 0;
+	smtc_scr_info.lfb_height = 0;
+	smtc_scr_info.lfb_depth = 0;
+
+	pr_debug("sm7xx_vga_setup = %s\n", options);
+
+	for (i = 0; i < ARRAY_SIZE(vesa_mode_table); i++) {
+		if (strstr(options, vesa_mode_table[i].index)) {
+			smtc_scr_info.lfb_width  = vesa_mode_table[i].lfb_width;
+			smtc_scr_info.lfb_height = vesa_mode_table[i].lfb_height;
+			smtc_scr_info.lfb_depth  = vesa_mode_table[i].lfb_depth;
+			return 0;
+		}
+	}
+
+	return -1;
+}
+__setup("vga=", sm7xx_vga_setup);
+
 static void sm712_set_timing(struct smtcfb_info *sfb)
 {
 	int i = 0, j = 0;
@@ -756,33 +783,6 @@ static inline void sm7xx_init_hw(void)
 	outb_p(0x11, 0x3c5);
 }
 
-/* process command line options, get vga parameter */
-static int __init sm7xx_vga_setup(char *options)
-{
-	int i;
-
-	if (!options || !*options)
-		return -EINVAL;
-
-	smtc_scr_info.lfb_width = 0;
-	smtc_scr_info.lfb_height = 0;
-	smtc_scr_info.lfb_depth = 0;
-
-	pr_debug("sm7xx_vga_setup = %s\n", options);
-
-	for (i = 0; i < ARRAY_SIZE(vesa_mode_table); i++) {
-		if (strstr(options, vesa_mode_table[i].index)) {
-			smtc_scr_info.lfb_width  = vesa_mode_table[i].lfb_width;
-			smtc_scr_info.lfb_height = vesa_mode_table[i].lfb_height;
-			smtc_scr_info.lfb_depth  = vesa_mode_table[i].lfb_depth;
-			return 0;
-		}
-	}
-
-	return -1;
-}
-__setup("vga=", sm7xx_vga_setup);
-
 static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
 				   const struct pci_device_id *ent)
 {
-- 
1.7.10


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

* [PATCH 6/9] staging: sm7xxfb: rename sm712_set_timing to sm7xx_set_timing
  2012-07-11 13:49 [PATCH 0/9] staging: sm7xxfb: code improvements and cleanup Javier M. Mellid
                   ` (4 preceding siblings ...)
  2012-07-11 13:49 ` [PATCH 5/9] staging: sm7xxfb: minor maintenance on sm7xx_vga_setup Javier M. Mellid
@ 2012-07-11 13:49 ` Javier M. Mellid
  2012-07-11 13:49 ` [PATCH 7/9] staging: sm7xxfb: minor maintenance on timing path Javier M. Mellid
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Javier M. Mellid @ 2012-07-11 13:49 UTC (permalink / raw)
  To: gregkh, gewang; +Cc: devel, linux-kernel, Javier M. Mellid

From: "Javier M. Mellid" <jmunhoz@igalia.com>

sm712_set_timing handles timing for 0x710, 0x712 and 0x720 chips. This
patch renames the name of the function of sm712_set_timing to
sm7xx_set_timing.

Tested with SM712.

Signed-off-by: Javier M. Mellid <jmunhoz@igalia.com>
---
 drivers/staging/sm7xxfb/sm7xxfb.c |   24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c
index ac49c98..119f6d1 100644
--- a/drivers/staging/sm7xxfb/sm7xxfb.c
+++ b/drivers/staging/sm7xxfb/sm7xxfb.c
@@ -135,7 +135,7 @@ static int __init sm7xx_vga_setup(char *options)
 }
 __setup("vga=", sm7xx_vga_setup);
 
-static void sm712_set_timing(struct smtcfb_info *sfb)
+static void sm7xx_set_timing(struct smtcfb_info *sfb)
 {
 	int i = 0, j = 0;
 	u32 m_nScreenStride;
@@ -243,6 +243,17 @@ static void sm712_set_timing(struct smtcfb_info *sfb)
 
 }
 
+static void smtc_set_timing(struct smtcfb_info *sfb)
+{
+	switch (sfb->chip_id) {
+	case 0x710:
+	case 0x712:
+	case 0x720:
+		sm7xx_set_timing(sfb);
+		break;
+	}
+}
+
 static void sm712_setpalette(int regno, unsigned red, unsigned green,
 			     unsigned blue, struct fb_info *info)
 {
@@ -255,17 +266,6 @@ static void sm712_setpalette(int regno, unsigned red, unsigned green,
 	smtc_mmiowb(blue >> 10, dac_val);
 }
 
-static void smtc_set_timing(struct smtcfb_info *sfb)
-{
-	switch (sfb->chip_id) {
-	case 0x710:
-	case 0x712:
-	case 0x720:
-		sm712_set_timing(sfb);
-		break;
-	}
-}
-
 /* chan_to_field
  *
  * convert a colour value into a field position
-- 
1.7.10


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

* [PATCH 7/9] staging: sm7xxfb: minor maintenance on timing path
  2012-07-11 13:49 [PATCH 0/9] staging: sm7xxfb: code improvements and cleanup Javier M. Mellid
                   ` (5 preceding siblings ...)
  2012-07-11 13:49 ` [PATCH 6/9] staging: sm7xxfb: rename sm712_set_timing to sm7xx_set_timing Javier M. Mellid
@ 2012-07-11 13:49 ` Javier M. Mellid
  2012-07-11 13:49 ` [PATCH 8/9] staging: sm7xxfb: move pseudo palette into smtcfb_info Javier M. Mellid
  2012-07-11 13:49 ` [PATCH 9/9] staging: sm7xxfb: cleanup on smtc_alloc_fb_info Javier M. Mellid
  8 siblings, 0 replies; 10+ messages in thread
From: Javier M. Mellid @ 2012-07-11 13:49 UTC (permalink / raw)
  To: gregkh, gewang; +Cc: devel, linux-kernel, Javier M. Mellid

From: "Javier M. Mellid" <jmunhoz@igalia.com>

This patch keeps smtc_set_timing and sm7xx_set_timing functions closed
to smtcfb_setmode. This change eases reviewing and maintaining this
logic path.

Tested with SM712.

Signed-off-by: Javier M. Mellid <jmunhoz@igalia.com>
---
 drivers/staging/sm7xxfb/sm7xxfb.c |  238 ++++++++++++++++++-------------------
 1 file changed, 119 insertions(+), 119 deletions(-)

diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c
index 119f6d1..9dd2ef7 100644
--- a/drivers/staging/sm7xxfb/sm7xxfb.c
+++ b/drivers/staging/sm7xxfb/sm7xxfb.c
@@ -135,125 +135,6 @@ static int __init sm7xx_vga_setup(char *options)
 }
 __setup("vga=", sm7xx_vga_setup);
 
-static void sm7xx_set_timing(struct smtcfb_info *sfb)
-{
-	int i = 0, j = 0;
-	u32 m_nScreenStride;
-
-	dev_dbg(&sfb->pdev->dev,
-		"sfb->width=%d sfb->height=%d "
-		"sfb->fb.var.bits_per_pixel=%d sfb->hz=%d\n",
-		sfb->width, sfb->height, sfb->fb.var.bits_per_pixel, sfb->hz);
-
-	for (j = 0; j < numVGAModes; j++) {
-		if (VGAMode[j].mmSizeX == sfb->width &&
-		    VGAMode[j].mmSizeY == sfb->height &&
-		    VGAMode[j].bpp == sfb->fb.var.bits_per_pixel &&
-		    VGAMode[j].hz == sfb->hz) {
-
-			dev_dbg(&sfb->pdev->dev,
-				"VGAMode[j].mmSizeX=%d VGAMode[j].mmSizeY=%d "
-				"VGAMode[j].bpp=%d VGAMode[j].hz=%d\n",
-				VGAMode[j].mmSizeX, VGAMode[j].mmSizeY,
-				VGAMode[j].bpp, VGAMode[j].hz);
-
-			dev_dbg(&sfb->pdev->dev, "VGAMode index=%d\n", j);
-
-			smtc_mmiowb(0x0, 0x3c6);
-
-			smtc_seqw(0, 0x1);
-
-			smtc_mmiowb(VGAMode[j].Init_MISC, 0x3c2);
-
-			/* init SEQ register SR00 - SR04 */
-			for (i = 0; i < SIZE_SR00_SR04; i++)
-				smtc_seqw(i, VGAMode[j].Init_SR00_SR04[i]);
-
-			/* init SEQ register SR10 - SR24 */
-			for (i = 0; i < SIZE_SR10_SR24; i++)
-				smtc_seqw(i + 0x10,
-					  VGAMode[j].Init_SR10_SR24[i]);
-
-			/* init SEQ register SR30 - SR75 */
-			for (i = 0; i < SIZE_SR30_SR75; i++)
-				if (((i + 0x30) != 0x62) \
-					&& ((i + 0x30) != 0x6a) \
-					&& ((i + 0x30) != 0x6b))
-					smtc_seqw(i + 0x30,
-						VGAMode[j].Init_SR30_SR75[i]);
-
-			/* init SEQ register SR80 - SR93 */
-			for (i = 0; i < SIZE_SR80_SR93; i++)
-				smtc_seqw(i + 0x80,
-					  VGAMode[j].Init_SR80_SR93[i]);
-
-			/* init SEQ register SRA0 - SRAF */
-			for (i = 0; i < SIZE_SRA0_SRAF; i++)
-				smtc_seqw(i + 0xa0,
-					  VGAMode[j].Init_SRA0_SRAF[i]);
-
-			/* init Graphic register GR00 - GR08 */
-			for (i = 0; i < SIZE_GR00_GR08; i++)
-				smtc_grphw(i, VGAMode[j].Init_GR00_GR08[i]);
-
-			/* init Attribute register AR00 - AR14 */
-			for (i = 0; i < SIZE_AR00_AR14; i++)
-				smtc_attrw(i, VGAMode[j].Init_AR00_AR14[i]);
-
-			/* init CRTC register CR00 - CR18 */
-			for (i = 0; i < SIZE_CR00_CR18; i++)
-				smtc_crtcw(i, VGAMode[j].Init_CR00_CR18[i]);
-
-			/* init CRTC register CR30 - CR4D */
-			for (i = 0; i < SIZE_CR30_CR4D; i++)
-				smtc_crtcw(i + 0x30,
-					   VGAMode[j].Init_CR30_CR4D[i]);
-
-			/* init CRTC register CR90 - CRA7 */
-			for (i = 0; i < SIZE_CR90_CRA7; i++)
-				smtc_crtcw(i + 0x90,
-					   VGAMode[j].Init_CR90_CRA7[i]);
-		}
-	}
-	smtc_mmiowb(0x67, 0x3c2);
-
-	/* set VPR registers */
-	writel(0x0, sfb->m_pVPR + 0x0C);
-	writel(0x0, sfb->m_pVPR + 0x40);
-
-	/* set data width */
-	m_nScreenStride =
-		(sfb->width * sfb->fb.var.bits_per_pixel) / 64;
-	switch (sfb->fb.var.bits_per_pixel) {
-	case 8:
-		writel(0x0, sfb->m_pVPR + 0x0);
-		break;
-	case 16:
-		writel(0x00020000, sfb->m_pVPR + 0x0);
-		break;
-	case 24:
-		writel(0x00040000, sfb->m_pVPR + 0x0);
-		break;
-	case 32:
-		writel(0x00030000, sfb->m_pVPR + 0x0);
-		break;
-	}
-	writel((u32) (((m_nScreenStride + 2) << 16) | m_nScreenStride),
-	       sfb->m_pVPR + 0x10);
-
-}
-
-static void smtc_set_timing(struct smtcfb_info *sfb)
-{
-	switch (sfb->chip_id) {
-	case 0x710:
-	case 0x712:
-	case 0x720:
-		sm7xx_set_timing(sfb);
-		break;
-	}
-}
-
 static void sm712_setpalette(int regno, unsigned red, unsigned green,
 			     unsigned blue, struct fb_info *info)
 {
@@ -581,6 +462,125 @@ smtcfb_write(struct fb_info *info, const char __user *buf, size_t count,
 }
 #endif	/* ! __BIG_ENDIAN */
 
+static void sm7xx_set_timing(struct smtcfb_info *sfb)
+{
+	int i = 0, j = 0;
+	u32 m_nScreenStride;
+
+	dev_dbg(&sfb->pdev->dev,
+		"sfb->width=%d sfb->height=%d "
+		"sfb->fb.var.bits_per_pixel=%d sfb->hz=%d\n",
+		sfb->width, sfb->height, sfb->fb.var.bits_per_pixel, sfb->hz);
+
+	for (j = 0; j < numVGAModes; j++) {
+		if (VGAMode[j].mmSizeX == sfb->width &&
+		    VGAMode[j].mmSizeY == sfb->height &&
+		    VGAMode[j].bpp == sfb->fb.var.bits_per_pixel &&
+		    VGAMode[j].hz == sfb->hz) {
+
+			dev_dbg(&sfb->pdev->dev,
+				"VGAMode[j].mmSizeX=%d VGAMode[j].mmSizeY=%d "
+				"VGAMode[j].bpp=%d VGAMode[j].hz=%d\n",
+				VGAMode[j].mmSizeX, VGAMode[j].mmSizeY,
+				VGAMode[j].bpp, VGAMode[j].hz);
+
+			dev_dbg(&sfb->pdev->dev, "VGAMode index=%d\n", j);
+
+			smtc_mmiowb(0x0, 0x3c6);
+
+			smtc_seqw(0, 0x1);
+
+			smtc_mmiowb(VGAMode[j].Init_MISC, 0x3c2);
+
+			/* init SEQ register SR00 - SR04 */
+			for (i = 0; i < SIZE_SR00_SR04; i++)
+				smtc_seqw(i, VGAMode[j].Init_SR00_SR04[i]);
+
+			/* init SEQ register SR10 - SR24 */
+			for (i = 0; i < SIZE_SR10_SR24; i++)
+				smtc_seqw(i + 0x10,
+					  VGAMode[j].Init_SR10_SR24[i]);
+
+			/* init SEQ register SR30 - SR75 */
+			for (i = 0; i < SIZE_SR30_SR75; i++)
+				if (((i + 0x30) != 0x62) \
+					&& ((i + 0x30) != 0x6a) \
+					&& ((i + 0x30) != 0x6b))
+					smtc_seqw(i + 0x30,
+						VGAMode[j].Init_SR30_SR75[i]);
+
+			/* init SEQ register SR80 - SR93 */
+			for (i = 0; i < SIZE_SR80_SR93; i++)
+				smtc_seqw(i + 0x80,
+					  VGAMode[j].Init_SR80_SR93[i]);
+
+			/* init SEQ register SRA0 - SRAF */
+			for (i = 0; i < SIZE_SRA0_SRAF; i++)
+				smtc_seqw(i + 0xa0,
+					  VGAMode[j].Init_SRA0_SRAF[i]);
+
+			/* init Graphic register GR00 - GR08 */
+			for (i = 0; i < SIZE_GR00_GR08; i++)
+				smtc_grphw(i, VGAMode[j].Init_GR00_GR08[i]);
+
+			/* init Attribute register AR00 - AR14 */
+			for (i = 0; i < SIZE_AR00_AR14; i++)
+				smtc_attrw(i, VGAMode[j].Init_AR00_AR14[i]);
+
+			/* init CRTC register CR00 - CR18 */
+			for (i = 0; i < SIZE_CR00_CR18; i++)
+				smtc_crtcw(i, VGAMode[j].Init_CR00_CR18[i]);
+
+			/* init CRTC register CR30 - CR4D */
+			for (i = 0; i < SIZE_CR30_CR4D; i++)
+				smtc_crtcw(i + 0x30,
+					   VGAMode[j].Init_CR30_CR4D[i]);
+
+			/* init CRTC register CR90 - CRA7 */
+			for (i = 0; i < SIZE_CR90_CRA7; i++)
+				smtc_crtcw(i + 0x90,
+					   VGAMode[j].Init_CR90_CRA7[i]);
+		}
+	}
+	smtc_mmiowb(0x67, 0x3c2);
+
+	/* set VPR registers */
+	writel(0x0, sfb->m_pVPR + 0x0C);
+	writel(0x0, sfb->m_pVPR + 0x40);
+
+	/* set data width */
+	m_nScreenStride =
+		(sfb->width * sfb->fb.var.bits_per_pixel) / 64;
+	switch (sfb->fb.var.bits_per_pixel) {
+	case 8:
+		writel(0x0, sfb->m_pVPR + 0x0);
+		break;
+	case 16:
+		writel(0x00020000, sfb->m_pVPR + 0x0);
+		break;
+	case 24:
+		writel(0x00040000, sfb->m_pVPR + 0x0);
+		break;
+	case 32:
+		writel(0x00030000, sfb->m_pVPR + 0x0);
+		break;
+	}
+	writel((u32) (((m_nScreenStride + 2) << 16) | m_nScreenStride),
+	       sfb->m_pVPR + 0x10);
+
+}
+
+static void smtc_set_timing(struct smtcfb_info *sfb)
+{
+	switch (sfb->chip_id) {
+	case 0x710:
+	case 0x712:
+	case 0x720:
+		sm7xx_set_timing(sfb);
+		break;
+	}
+}
+
 void smtcfb_setmode(struct smtcfb_info *sfb)
 {
 	switch (sfb->fb.var.bits_per_pixel) {
-- 
1.7.10


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

* [PATCH 8/9] staging: sm7xxfb: move pseudo palette into smtcfb_info
  2012-07-11 13:49 [PATCH 0/9] staging: sm7xxfb: code improvements and cleanup Javier M. Mellid
                   ` (6 preceding siblings ...)
  2012-07-11 13:49 ` [PATCH 7/9] staging: sm7xxfb: minor maintenance on timing path Javier M. Mellid
@ 2012-07-11 13:49 ` Javier M. Mellid
  2012-07-11 13:49 ` [PATCH 9/9] staging: sm7xxfb: cleanup on smtc_alloc_fb_info Javier M. Mellid
  8 siblings, 0 replies; 10+ messages in thread
From: Javier M. Mellid @ 2012-07-11 13:49 UTC (permalink / raw)
  To: gregkh, gewang; +Cc: devel, linux-kernel, Javier M. Mellid

From: "Javier M. Mellid" <jmunhoz@igalia.com>

This patch moves pseudo palette into smtcfb_info struct.

Tested with SM712.

Signed-off-by: Javier M. Mellid <jmunhoz@igalia.com>
---
 drivers/staging/sm7xxfb/sm7xxfb.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c
index 9dd2ef7..baee015 100644
--- a/drivers/staging/sm7xxfb/sm7xxfb.c
+++ b/drivers/staging/sm7xxfb/sm7xxfb.c
@@ -52,13 +52,13 @@ struct smtcfb_info {
 	u_int width;
 	u_int height;
 	u_int hz;
+
+	u32 colreg[17];
 };
 
 char __iomem *smtc_RegBaseAddress;	/* Memory Map IO starting address */
 char __iomem *smtc_VRAMBaseAddress;	/* video memory starting address */
 
-static u32 colreg[17];
-
 static struct fb_var_screeninfo smtcfb_var = {
 	.xres           = 1024,
 	.yres           = 600,
@@ -709,9 +709,9 @@ static struct smtcfb_info *smtc_alloc_fb_info(struct pci_dev *pdev, char *name)
 	sfb->fb.var.accel_flags = FB_ACCELF_TEXT;
 	sfb->fb.var.vmode = FB_VMODE_NONINTERLACED;
 
-	sfb->fb.par = sfb;
+	sfb->fb.pseudo_palette = sfb->colreg;
 
-	sfb->fb.pseudo_palette = colreg;
+	sfb->fb.par = sfb;
 
 	return sfb;
 }
-- 
1.7.10


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

* [PATCH 9/9] staging: sm7xxfb: cleanup on smtc_alloc_fb_info
  2012-07-11 13:49 [PATCH 0/9] staging: sm7xxfb: code improvements and cleanup Javier M. Mellid
                   ` (7 preceding siblings ...)
  2012-07-11 13:49 ` [PATCH 8/9] staging: sm7xxfb: move pseudo palette into smtcfb_info Javier M. Mellid
@ 2012-07-11 13:49 ` Javier M. Mellid
  8 siblings, 0 replies; 10+ messages in thread
From: Javier M. Mellid @ 2012-07-11 13:49 UTC (permalink / raw)
  To: gregkh, gewang; +Cc: devel, linux-kernel, Javier M. Mellid

From: "Javier M. Mellid" <jmunhoz@igalia.com>

This patch improves coding style on smtc_alloc_fb_info.

Tested with SM712.

Signed-off-by: Javier M. Mellid <jmunhoz@igalia.com>
---
 drivers/staging/sm7xxfb/sm7xxfb.c |   36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c
index baee015..d9b1cd3 100644
--- a/drivers/staging/sm7xxfb/sm7xxfb.c
+++ b/drivers/staging/sm7xxfb/sm7xxfb.c
@@ -673,7 +673,7 @@ static struct fb_ops smtcfb_ops = {
 };
 
 /*
- * Alloc struct smtcfb_info and assign the default value
+ * alloc struct smtcfb_info and assign the default value
  */
 static struct smtcfb_info *smtc_alloc_fb_info(struct pci_dev *pdev, char *name)
 {
@@ -686,30 +686,30 @@ static struct smtcfb_info *smtc_alloc_fb_info(struct pci_dev *pdev, char *name)
 
 	sfb->pdev = pdev;
 
-	/*** Init sfb->fb with default value ***/
+	/* init sfb->fb with default value */
+
 	sfb->fb.flags = FBINFO_FLAG_DEFAULT;
 	sfb->fb.fbops = &smtcfb_ops;
-	sfb->fb.var = smtcfb_var;
-	sfb->fb.fix = smtcfb_fix;
 
+	sfb->fb.fix = smtcfb_fix;
 	strcpy(sfb->fb.fix.id, name);
 
-	sfb->fb.fix.type = FB_TYPE_PACKED_PIXELS;
-	sfb->fb.fix.type_aux = 0;
-	sfb->fb.fix.xpanstep = 0;
-	sfb->fb.fix.ypanstep = 0;
-	sfb->fb.fix.ywrapstep = 0;
-	sfb->fb.fix.accel = FB_ACCEL_SMI_LYNX;
-
-	sfb->fb.var.nonstd = 0;
-	sfb->fb.var.activate = FB_ACTIVATE_NOW;
-	sfb->fb.var.height = -1;
-	sfb->fb.var.width = -1;
-	/* text mode acceleration */
+	sfb->fb.fix.type        = FB_TYPE_PACKED_PIXELS;
+	sfb->fb.fix.type_aux    = 0;
+	sfb->fb.fix.xpanstep    = 0;
+	sfb->fb.fix.ypanstep    = 0;
+	sfb->fb.fix.ywrapstep   = 0;
+	sfb->fb.fix.accel       = FB_ACCEL_SMI_LYNX;
+
+	sfb->fb.var             = smtcfb_var;
+	sfb->fb.var.nonstd      = 0;
+	sfb->fb.var.activate    = FB_ACTIVATE_NOW;
+	sfb->fb.var.height      = -1;
+	sfb->fb.var.width       = -1;
 	sfb->fb.var.accel_flags = FB_ACCELF_TEXT;
-	sfb->fb.var.vmode = FB_VMODE_NONINTERLACED;
+	sfb->fb.var.vmode       = FB_VMODE_NONINTERLACED;
 
-	sfb->fb.pseudo_palette = sfb->colreg;
+	sfb->fb.pseudo_palette  = sfb->colreg;
 
 	sfb->fb.par = sfb;
 
-- 
1.7.10


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

end of thread, other threads:[~2012-07-11 13:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-11 13:49 [PATCH 0/9] staging: sm7xxfb: code improvements and cleanup Javier M. Mellid
2012-07-11 13:49 ` [PATCH 1/9] staging: sm7xxfb: fix struct names related to vesa modes Javier M. Mellid
2012-07-11 13:49 ` [PATCH 2/9] staging: sm7xxfb: rename index var on sm712vga_setup Javier M. Mellid
2012-07-11 13:49 ` [PATCH 3/9] staging: sm7xxfb: rename smtc_screen_info to smtc_scr_info Javier M. Mellid
2012-07-11 13:49 ` [PATCH 4/9] staging: sm7xxfb: rename sm712vga_setup to sm7xx_vga_setup Javier M. Mellid
2012-07-11 13:49 ` [PATCH 5/9] staging: sm7xxfb: minor maintenance on sm7xx_vga_setup Javier M. Mellid
2012-07-11 13:49 ` [PATCH 6/9] staging: sm7xxfb: rename sm712_set_timing to sm7xx_set_timing Javier M. Mellid
2012-07-11 13:49 ` [PATCH 7/9] staging: sm7xxfb: minor maintenance on timing path Javier M. Mellid
2012-07-11 13:49 ` [PATCH 8/9] staging: sm7xxfb: move pseudo palette into smtcfb_info Javier M. Mellid
2012-07-11 13:49 ` [PATCH 9/9] staging: sm7xxfb: cleanup on smtc_alloc_fb_info 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.