Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset
From: Lorenzo Stoakes @ 2015-03-18 10:55 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: devel, linux-fbdev, Teddy Wang, Greg KH, linux-kernel,
	Sudip Mukherjee
In-Reply-To: <20150318105256.GR16501@mwanda>

On 18 March 2015 at 10:52, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> I often say "don't resend" because something is minor and I don't want
> to slow you down but since you were resending it anyway then please fix
> it.  Also changelogs are really easy to fix.  In mutt, you can do it
> without leaving your email client.  So I have revised my earlier
> statement, please fix it.  :)

Will do!

I have experimented with mutt, I tend to just use git send-email
directly at the moment and edit patch files manually and use the gmail
web interface for reading/discussion, I am sure I will learn to do
things a little more sanely in time, the hard way :)

Best,

-- 
Lorenzo Stoakes
https:/ljs.io

^ permalink raw reply

* Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset
From: Dan Carpenter @ 2015-03-18 10:59 UTC (permalink / raw)
  To: Lorenzo Stoakes
  Cc: Sudip Mukherjee, Teddy Wang, Greg KH, devel, linux-fbdev,
	linux-kernel
In-Reply-To: <CAA5enKZTjSsfX_4XkZFjbpDchZuBDfTNaK1_5GjFFwthjFZM7Q@mail.gmail.com>

On Wed, Mar 18, 2015 at 10:46:52AM +0000, Lorenzo Stoakes wrote:
> On 18 March 2015 at 10:17, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > Why is there a RESEND in the subject.
> 
> To avoid confusion (and Sudip explicitly mentioned there might be
> some), and in addition I had to update my patch series to take into
> account that it no longer applied due to another patch which applies
> the ANSI C function prototype fixes having already been applied.

Btw, sorry for coming down hard on you.  You're a newbie and expected to
make these mistakes.  Your patches are good and appreciated.

Call it a v2 patch.  Put a note under the --- cut off line:
v2: updated to apply to latest linux-next

http://kernelnewbies.org/PatchTipsAndTricks

regards,
dan carpenter


^ permalink raw reply

* Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset
From: Lorenzo Stoakes @ 2015-03-18 11:12 UTC (permalink / raw)
  To: Vitaly Kuznetsov
  Cc: Sudip Mukherjee, Teddy Wang, Greg KH, devel, linux-fbdev,
	linux-kernel
In-Reply-To: <87oanqo9zi.fsf@vitty.brq.redhat.com>

On 18 March 2015 at 10:50, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
> ERROR is reported by scripts/checkpatch.pl (spaces are missing after
> ','). This coding style problem was there before your patch but I don't
> think it makes sense to preserve it.

[snip]

> WARNING: please, no spaces at the start of a line
> #137: FILE: drivers/staging/sm750fb/sm750.c:833:

[snip]

Hi Vitaly, these style issues have vexed me and I was not sure whether
to make changes or preserve all the obvious errors so as not to blend
the two changes inappropriately, however it does indeed make sense to
fix these on the lines I'm changing, will fix these!

Best,

-- 
Lorenzo Stoakes
https:/ljs.io

^ permalink raw reply

* Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset
From: Lorenzo Stoakes @ 2015-03-18 11:14 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Sudip Mukherjee, Teddy Wang, Greg KH, devel, linux-fbdev,
	linux-kernel
In-Reply-To: <20150318105920.GS16501@mwanda>

On 18 March 2015 at 10:59, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Btw, sorry for coming down hard on you.  You're a newbie and expected to
> make these mistakes.  Your patches are good and appreciated.

Thanks and no problem, I expect to receive robust criticism given the
high standards in the kernel and see it as a means to improve my
contributions :)

>
> Call it a v2 patch.  Put a note under the --- cut off line:
> v2: updated to apply to latest linux-next
>
> http://kernelnewbies.org/PatchTipsAndTricks
>

Great, thanks, will do! Very useful link!

Best,

-- 
Lorenzo Stoakes
https:/ljs.io

^ permalink raw reply

* Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset
From: Dan Carpenter @ 2015-03-18 11:25 UTC (permalink / raw)
  To: Lorenzo Stoakes
  Cc: Vitaly Kuznetsov, devel, linux-fbdev, Teddy Wang, Greg KH,
	linux-kernel, Sudip Mukherjee
In-Reply-To: <CAA5enKZYqmysuFqPPptgVvyBJAzX8UYBkod1t3Atvu3Q5TUEjQ@mail.gmail.com>

On Wed, Mar 18, 2015 at 11:12:20AM +0000, Lorenzo Stoakes wrote:
> On 18 March 2015 at 10:50, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
> > ERROR is reported by scripts/checkpatch.pl (spaces are missing after
> > ','). This coding style problem was there before your patch but I don't
> > think it makes sense to preserve it.
> 
> [snip]
> 
> > WARNING: please, no spaces at the start of a line
> > #137: FILE: drivers/staging/sm750fb/sm750.c:833:
> 
> [snip]
> 
> Hi Vitaly, these style issues have vexed me and I was not sure whether
> to make changes or preserve all the obvious errors so as not to blend
> the two changes inappropriately, however it does indeed make sense to
> fix these on the lines I'm changing, will fix these!

If it's a white space thing on the same line then it's generally ok to
fix it.  The "one thing per patch" is meant to make patches easier to
review.  If it's a trivial thing and it doesn't make it harder to review
then we are reasonable people.

Could you read your patches again and find other similar white space
issues.

+       void __iomem * pbuffer,*pstart;

Should be:

+	void __iomem *pbuffer, *pstart;

regards,
dan carpenter


^ permalink raw reply

* Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset
From: Sudip Mukherjee @ 2015-03-18 13:18 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Lorenzo Stoakes, Vitaly Kuznetsov, devel, linux-fbdev, Teddy Wang,
	Greg KH, linux-kernel
In-Reply-To: <20150318112509.GP10964@mwanda>

On Wed, Mar 18, 2015 at 02:25:09PM +0300, Dan Carpenter wrote:
> On Wed, Mar 18, 2015 at 11:12:20AM +0000, Lorenzo Stoakes wrote:
> > On 18 March 2015 at 10:50, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
> If it's a white space thing on the same line then it's generally ok to
> fix it.  The "one thing per patch" is meant to make patches easier to
> review.  If it's a trivial thing and it doesn't make it harder to review
> then we are reasonable people.
> 
but Greg K-H has explisitely mentiond not to do so.
I did just that and fixed few whitespace things in the patch to fix the
build failure.

https://lkml.org/lkml/2015/3/10/685

regards
sudip

^ permalink raw reply

* Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset
From: Dan Carpenter @ 2015-03-18 13:23 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: devel, linux-fbdev, Lorenzo Stoakes, Greg KH, linux-kernel,
	Teddy Wang
In-Reply-To: <20150318130607.GB32758@sudip-PC>

On Wed, Mar 18, 2015 at 06:36:07PM +0530, Sudip Mukherjee wrote:
> On Wed, Mar 18, 2015 at 02:25:09PM +0300, Dan Carpenter wrote:
> > On Wed, Mar 18, 2015 at 11:12:20AM +0000, Lorenzo Stoakes wrote:
> > > On 18 March 2015 at 10:50, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
> > If it's a white space thing on the same line then it's generally ok to
> > fix it.  The "one thing per patch" is meant to make patches easier to
> > review.  If it's a trivial thing and it doesn't make it harder to review
> > then we are reasonable people.
> > 
> but Greg K-H has explisitely mentiond not to do so.
> I did just that and fixed few whitespace things in the patch to fix the
> build failure.
> 
> https://lkml.org/lkml/2015/3/10/685
> 

You were making random white space changes and not on the same line.  It
was hard to review because you had to count how many u32 arguments there
were (a million) and really look at it to see what the compile warning
was.  There was no compile warning in the end.  Very annoying.

regards,
dan carpenter


^ permalink raw reply

* Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset
From: Sudip Mukherjee @ 2015-03-18 13:41 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: devel, linux-fbdev, Lorenzo Stoakes, Greg KH, linux-kernel,
	Teddy Wang
In-Reply-To: <20150318132339.GR10964@mwanda>

On Wed, Mar 18, 2015 at 04:23:39PM +0300, Dan Carpenter wrote:
> > https://lkml.org/lkml/2015/3/10/685
> > 
> 
> You were making random white space changes and not on the same line.  It
> was hard to review because you had to count how many u32 arguments there
> were (a million) and really look at it to see what the compile warning
> was.  There was no compile warning in the end.  Very annoying.
ok, now understood. Thanks.
like you said once - combining different changes in a single patch is
an art. :)

regards
sudip
> 
> regards,
> dan carpenter
> 

^ permalink raw reply

* Re: [PATCHv4 02/10] fbdev: ssd1307fb: Allocate page aligned video memory.
From: Maxime Ripard @ 2015-03-18 17:38 UTC (permalink / raw)
  To: Thomas Niederprüm
  Cc: plagnioj, tomi.valkeinen, kernel, shawn.guo, robh+dt, linux-fbdev,
	linux-kernel
In-Reply-To: <1426525918-12745-3-git-send-email-niederp@physik.uni-kl.de>

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

On Mon, Mar 16, 2015 at 06:11:50PM +0100, Thomas Niederprüm wrote:
> Currently the videomemory is allocated by kmalloc, making it a memory
> region that is not necessarily page aligend. This leads to problems
> upon mmap call, where the video memory's address gets aligned to the
> next page boundary. The result is that the userspace program that issued
> the mmap call is not able to access the video memory from the start to
> the next page boundary.
> 
> This patch changes the allocation of the video memory to use
> __get_free_pages() in order to obtain memory that is aligned
> to page boundaries.
> 
> Signed-off-by: Thomas Niederprüm <niederp@physik.uni-kl.de>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* [PATCH RESEND v2 1/5] staging: sm750fb: Use memset_io instead of memset
From: Lorenzo Stoakes @ 2015-03-18 19:04 UTC (permalink / raw)
  To: sudipm.mukherjee, teddy.wang, gregkh
  Cc: linux-fbdev, devel, linux-kernel, Lorenzo Stoakes

This patch takes into account that cursor->vstart, crtc->vScreen and
share->pvMem are pointers to memory-mapped I/O and thus we should use memset_io
to make this explicit. In addition, some architectures require special treatment
of memory-mapped I/O so the previous code could actually break without this
change.

This fixes the following sparse warnings:-

drivers/staging/sm750fb/sm750.c:489:17: warning: incorrect type in argument 1 (different address spaces)
drivers/staging/sm750fb/sm750.c:490:17: warning: incorrect type in argument 1 (different address spaces)
drivers/staging/sm750fb/sm750.c:501:17: warning: incorrect type in argument 1 (different address spaces)
drivers/staging/sm750fb/sm750.c:502:17: warning: incorrect type in argument 1 (different address spaces)
drivers/staging/sm750fb/sm750.c:833:5: warning: incorrect type in argument 1 (different address spaces)
drivers/staging/sm750fb/sm750.c:1154:9: warning: incorrect type in argument 1 (different address spaces)

Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
---
v2: Whitespace fixups, updated commit message

 drivers/staging/sm750fb/sm750.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index aa0888c..3e36b6a 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -486,8 +486,8 @@ static int lynxfb_resume(struct pci_dev* pdev)
 		par = info->par;
 		crtc = &par->crtc;
 		cursor = &crtc->cursor;
-		memset(cursor->vstart, 0x0, cursor->size);
-		memset(crtc->vScreen,0x0,crtc->vidmem_size);
+		memset_io(cursor->vstart, 0x0, cursor->size);
+		memset_io(crtc->vScreen, 0x0, crtc->vidmem_size);
 		lynxfb_ops_set_par(info);
 		fb_set_suspend(info, 0);
 	}
@@ -498,8 +498,8 @@ static int lynxfb_resume(struct pci_dev* pdev)
 		par = info->par;
 		crtc = &par->crtc;
 		cursor = &crtc->cursor;
-		memset(cursor->vstart, 0x0, cursor->size);
-		memset(crtc->vScreen,0x0,crtc->vidmem_size);
+		memset_io(cursor->vstart, 0x0, cursor->size);
+		memset_io(crtc->vScreen, 0x0, crtc->vidmem_size);
 		lynxfb_ops_set_par(info);
 		fb_set_suspend(info, 0);
 	}
@@ -830,7 +830,7 @@ static int lynxfb_set_fbinfo(struct fb_info* info,int index)


     crtc->cursor.share = share;
-    memset(crtc->cursor.vstart, 0, crtc->cursor.size);
+	memset_io(crtc->cursor.vstart, 0, crtc->cursor.size);
     if(!g_hwcursor){
         lynxfb_ops.fb_cursor = NULL;
         crtc->cursor.disable(&crtc->cursor);
@@ -1151,7 +1151,7 @@ static int lynxfb_pci_probe(struct pci_dev * pdev,
 	}
 #endif

-	memset(share->pvMem,0,share->vidmem_size);
+	memset_io(share->pvMem, 0, share->vidmem_size);

 	pr_info("sm%3x mmio address = %p\n",share->devid,share->pvReg);

--
2.3.2

^ permalink raw reply related

* [PATCH RESEND v2 4/5] staging: sm750fb: Fix __iomem pointer types
From: Lorenzo Stoakes @ 2015-03-18 19:04 UTC (permalink / raw)
  To: sudipm.mukherjee, teddy.wang, gregkh
  Cc: linux-fbdev, devel, linux-kernel, Lorenzo Stoakes
In-Reply-To: <1426705493-26615-1-git-send-email-lstoakes@gmail.com>

This patch annotates pointers as referring to I/O mapped memory where they ought
to be, removes now unnecessary ugly casts, eliminates an incorrect deref on I/O
mapped memory by using iowrite16 instead, and updates the pointer arithmetic
accordingly to take into account that the pointers are now byte-sized. This
fixes the following sparse warnings:-

drivers/staging/sm750fb/sm750_cursor.c:113:19: warning: cast removes address space of expression
drivers/staging/sm750fb/sm750_cursor.c:204:19: warning: cast removes address space of expression

Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
---
v2: Whitespace fixups

 drivers/staging/sm750fb/sm750_cursor.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750_cursor.c b/drivers/staging/sm750fb/sm750_cursor.c
index 6cceef1..c2ff3bd 100644
--- a/drivers/staging/sm750fb/sm750_cursor.c
+++ b/drivers/staging/sm750fb/sm750_cursor.c
@@ -98,7 +98,7 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
 	int i,j,count,pitch,offset;
 	u8 color,mask,opr;
 	u16 data;
-	u16 * pbuffer,*pstart;
+	void __iomem *pbuffer, *pstart;

 	/*  in byte*/
 	pitch = cursor->w >> 3;
@@ -106,11 +106,11 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
 	/* in byte	*/
 	count = pitch * cursor->h;

-	/* in ushort */
-	offset = cursor->maxW * 2 / 8 / 2;
+	/* in byte */
+	offset = cursor->maxW * 2 / 8;

 	data = 0;
-	pstart = (u16 *)cursor->vstart;
+	pstart = cursor->vstart;
 	pbuffer = pstart;

 /*
@@ -161,7 +161,7 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
 			}
 		}
 #endif
-		*pbuffer = data;
+		iowrite16(data, pbuffer);

 		/* assume pitch is 1,2,4,8,...*/
 #if 0
@@ -174,7 +174,7 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
 			pstart += offset;
 			pbuffer = pstart;
 		}else{
-			pbuffer++;
+			pbuffer += sizeof(u16);
 		}

 	}
@@ -189,7 +189,7 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
 	int i,j,count,pitch,offset;
 	u8 color, mask;
 	u16 data;
-	u16 * pbuffer,*pstart;
+	void __iomem *pbuffer, *pstart;

 	/*  in byte*/
 	pitch = cursor->w >> 3;
@@ -197,11 +197,11 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
 	/* in byte	*/
 	count = pitch * cursor->h;

-	/* in ushort */
-	offset = cursor->maxW * 2 / 8 / 2;
+	/* in byte */
+	offset = cursor->maxW * 2 / 8;

 	data = 0;
-	pstart = (u16 *)cursor->vstart;
+	pstart = cursor->vstart;
 	pbuffer = pstart;

 	for(i=0;i<count;i++)
@@ -234,7 +234,7 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
 				data |= ((color & (1<<j))?1:2)<<(j*2);
 		}
 #endif
-		*pbuffer = data;
+		iowrite16(data, pbuffer);

 		/* assume pitch is 1,2,4,8,...*/
 		if(!(i&(pitch-1)))
@@ -244,7 +244,7 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
 			pstart += offset;
 			pbuffer = pstart;
 		}else{
-			pbuffer++;
+			pbuffer += sizeof(u16);
 		}

 	}
--
2.3.2

^ permalink raw reply related

* Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset
From: Lorenzo Stoakes @ 2015-03-18 19:09 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Sudip Mukherjee, Teddy Wang, Greg KH, devel, linux-fbdev,
	linux-kernel
In-Reply-To: <20150318105920.GS16501@mwanda>

On 18 March 2015 at 10:59, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Call it a v2 patch.  Put a note under the --- cut off line:
> v2: updated to apply to latest linux-next
>
> http://kernelnewbies.org/PatchTipsAndTricks

Since each changed patch in the resend already incorporates changes to
update to apply to the latest linux-next, I instead referenced
whitespace/description changes (let me know if this isn't usually
something you'd reference) to avoid confusion, as otherwise I'd have
to resend other patches unchanged with just a v2 applied, then
additionally update the ones that need changes.

Let me know if you'd like this done differently!

Best,

-- 
Lorenzo Stoakes
https:/ljs.io

^ permalink raw reply

* Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset
From: Lorenzo Stoakes @ 2015-03-18 19:10 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Vitaly Kuznetsov, devel, linux-fbdev, Teddy Wang, Greg KH,
	linux-kernel, Sudip Mukherjee
In-Reply-To: <20150318112509.GP10964@mwanda>

On 18 March 2015 at 11:25, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Could you read your patches again and find other similar white space
> issues.

Done.

Best,

-- 
Lorenzo Stoakes
https:/ljs.io

^ permalink raw reply

* Re: [PATCHv4 04/10] fbdev: ssd1307fb: Unify init code and obtain hw specific bits from DT
From: Maxime Ripard @ 2015-03-18 19:27 UTC (permalink / raw)
  To: Thomas Niederprüm
  Cc: plagnioj, tomi.valkeinen, kernel, shawn.guo, robh+dt, linux-fbdev,
	linux-kernel
In-Reply-To: <1426525918-12745-5-git-send-email-niederp@physik.uni-kl.de>

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

Hi Thomas,

On Mon, Mar 16, 2015 at 06:11:52PM +0100, Thomas Niederprüm wrote:
> The 130X controllers are very similar from the configuration point of view.
> The configuration registers for the SSD1305/6/7 are bit identical (except the
> the VHCOM register and the the default values for clock setup register). This
> patch unifies the init code of the controller and adds hardware specific
> properties to DT that are needed to correctly initialize the device.
> 
> The SSD130X can be wired to the OLED panel in various ways. Even for the
> same controller this wiring can differ from one display module to another
> and can not be probed by software. The added DT properties reflect these
> hardware decisions of the display module manufacturer.
> The 'com-sequential', 'com-lrremap' and 'com-invdir' values define different
> possibilities for the COM signals pin configuration and readout direction
> of the video memory. The 'segment-no-remap' allows the inversion of the
> memory-to-pin mapping ultimately inverting the order of the controllers
> output pins. The 'prechargepX' values need to be adapted according the
> capacitance of the OLEDs pixel cells.
> 
> So far these hardware specific bits are hard coded in the init code, making
> the driver usable only for one certain wiring of the controller. This patch
> makes the driver usable with all possible hardware setups, given a valid hw
> description in DT. If these values are not set in DT the default values,
> as they are set in the ssd1307 init code right now, are used. This implies
> that without the corresponding DT property "segment-no-remap" the segment
> remap of the ssd130X controller gets activated. Even though this is not the
> default behaviour according to the datasheet it maintains backward
> compatibility with older DTBs.
> 
> Note that the SSD1306 does not seem to be using the configuration written to
> the registers at all. Therefore this patch does not try to maintain these
> values without changes in DT. For reference an example is added to the DT
> bindings documentation that reproduces the configuration that is set in the
> current init code.
> 
> Signed-off-by: Thomas Niederprüm <niederp@physik.uni-kl.de>

This looks mostly fine, thanks for your effort on this.

> ---
>  .../devicetree/bindings/video/ssd1307fb.txt        |  21 +++
>  drivers/video/fbdev/ssd1307fb.c                    | 195 ++++++++++++---------
>  2 files changed, 137 insertions(+), 79 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/video/ssd1307fb.txt b/Documentation/devicetree/bindings/video/ssd1307fb.txt
> index 7a12542..be27562 100644
> --- a/Documentation/devicetree/bindings/video/ssd1307fb.txt
> +++ b/Documentation/devicetree/bindings/video/ssd1307fb.txt
> @@ -15,6 +15,16 @@ Required properties:
>  
>  Optional properties:
>    - reset-active-low: Is the reset gpio is active on physical low?
> +  - solomon,segment-no-remap: Display needs normal (non-inverted) data column
> +                              to segment mapping
> +  - solomon,com-sequential: Display uses sequential COM pin configuration
> +  - solomon,com-lrremap: Display uses left-right COM pin remap
> +  - solomon,com-invdir: Display uses inverted COM pin scan direction
> +  - solomon,com-offset: Offset of the first COM pin wired to the panel

Documenting the offset unit would be fine.

> +  - solomon,prechargep1: Length of deselect period (phase 1) in clock cycles.
> +  - solomon,prechargep2: Length of precharge period (phase 2) in clock cycles.
> +                         This needs to be the higher, the higher the capacitance
> +                         of the OLED's pixels is
>  
>  [0]: Documentation/devicetree/bindings/pwm/pwm.txt
>  
> @@ -26,3 +36,14 @@ ssd1307: oled@3c {
>          reset-gpios = <&gpio2 7>;
>          reset-active-low;
>  };
> +
> +ssd1306: oled@3c {
> +        compatible = "solomon,ssd1306fb-i2c";
> +        reg = <0x3c>;
> +        pwms = <&pwm 4 3000>;
> +        reset-gpios = <&gpio2 7>;
> +        reset-active-low;
> +        solomon,com-lrremap;
> +        solomon,com-invdir;
> +        solomon,com-offset = <32>;
> +};
> diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
> index 8d34c56..9a66118 100644
> --- a/drivers/video/fbdev/ssd1307fb.c
> +++ b/drivers/video/fbdev/ssd1307fb.c
> @@ -16,6 +16,9 @@
>  #include <linux/pwm.h>
>  #include <linux/delay.h>
>  
> +#define DEVID_SSD1306 6
> +#define DEVID_SSD1307 7
> +
>  #define SSD1307FB_DATA			0x40
>  #define SSD1307FB_COMMAND		0x80
>  
> @@ -38,22 +41,38 @@
>  #define	SSD1307FB_SET_COM_PINS_CONFIG	0xda
>  #define	SSD1307FB_SET_VCOMH		0xdb
>  
> +static u_int contrast = 128;
> +module_param(contrast, uint, S_IRUGO);
> +

Why is this patch adding a contrast parameter? You don't even mention
it in your commit log. This should be a separate patch.

>  struct ssd1307fb_par;
>  
> -struct ssd1307fb_ops {
> -	int (*init)(struct ssd1307fb_par *);
> -	int (*remove)(struct ssd1307fb_par *);
> +struct ssd1307fb_deviceinfo {
> +	int device_id;
> +	u32 default_vcomh;
> +	u32 default_dclk_div;
> +	u32 default_dclk_frq;
>  };
>  
>  struct ssd1307fb_par {
> +	u32 com_invdir;
> +	u32 com_lrremap;
> +	u32 com_offset;
> +	u32 com_seq;
> +	u32 contrast;
> +	u32 dclk_div;
> +	u32 dclk_frq;
> +	struct ssd1307fb_deviceinfo *device_info;
>  	struct i2c_client *client;
>  	u32 height;
>  	struct fb_info *info;
> -	struct ssd1307fb_ops *ops;
>  	u32 page_offset;
> +	u32 prechargep1;
> +	u32 prechargep2;
>  	struct pwm_device *pwm;
>  	u32 pwm_period;
>  	int reset;
> +	u32 seg_remap;
> +	u32 vcomh;
>  	u32 width;
>  };
>  
> @@ -254,69 +273,46 @@ static struct fb_deferred_io ssd1307fb_defio = {
>  	.deferred_io	= ssd1307fb_deferred_io,
>  };
>  
> -static int ssd1307fb_ssd1307_init(struct ssd1307fb_par *par)
> +static int ssd1307fb_init(struct ssd1307fb_par *par)
>  {
>  	int ret;
> +	u32 precharge, dclk, com_invdir, compins;
>  
> -	par->pwm = pwm_get(&par->client->dev, NULL);
> -	if (IS_ERR(par->pwm)) {
> -		dev_err(&par->client->dev, "Could not get PWM from device tree!\n");
> -		return PTR_ERR(par->pwm);
> -	}
> -
> -	par->pwm_period = pwm_get_period(par->pwm);
> -	/* Enable the PWM */
> -	pwm_config(par->pwm, par->pwm_period / 2, par->pwm_period);
> -	pwm_enable(par->pwm);
> -
> -	dev_dbg(&par->client->dev, "Using PWM%d with a %dns period.\n",
> -		par->pwm->pwm, par->pwm_period);
> -
> -	/* Map column 127 of the OLED to segment 0 */
> -	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SEG_REMAP_ON);
> -	if (ret < 0)
> -		return ret;
> -
> -	/* Turn on the display */
> -	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_ON);
> -	if (ret < 0)
> -		return ret;
> -
> -	return 0;
> -}
> -
> -static int ssd1307fb_ssd1307_remove(struct ssd1307fb_par *par)
> -{
> -	pwm_disable(par->pwm);
> -	pwm_put(par->pwm);
> -	return 0;
> -}
> +	if (par->device_info->device_id == DEVID_SSD1307) {
> +		par->pwm = pwm_get(&par->client->dev, NULL);
> +		if (IS_ERR(par->pwm)) {
> +			dev_err(&par->client->dev, "Could not get PWM from device tree!\n");
> +			return PTR_ERR(par->pwm);
> +		}
>  
> -static struct ssd1307fb_ops ssd1307fb_ssd1307_ops = {
> -	.init	= ssd1307fb_ssd1307_init,
> -	.remove	= ssd1307fb_ssd1307_remove,
> -};
> +		par->pwm_period = pwm_get_period(par->pwm);
> +		/* Enable the PWM */
> +		pwm_config(par->pwm, par->pwm_period / 2, par->pwm_period);
> +		pwm_enable(par->pwm);
>  
> -static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par)
> -{
> -	int ret;
> +		dev_dbg(&par->client->dev, "Using PWM%d with a %dns period.\n",
> +			par->pwm->pwm, par->pwm_period);
> +	};
>  
>  	/* Set initial contrast */
>  	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST);
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = ssd1307fb_write_cmd(par->client, 0x7f);
> -	if (ret < 0)
> -		return ret;
> -
> -	/* Set COM direction */
> -	ret = ssd1307fb_write_cmd(par->client, 0xc8);
> +	ret = ssd1307fb_write_cmd(par->client, par->contrast);
>  	if (ret < 0)
>  		return ret;
>  
>  	/* Set segment re-map */
> -	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SEG_REMAP_ON);
> +	if (par->seg_remap) {
> +		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SEG_REMAP_ON);
> +		if (ret < 0)
> +			return ret;
> +	};
> +
> +	/* Set COM direction */
> +	com_invdir = 0xc0 | (par->com_invdir & 0xf) << 3;
> +	ret = ssd1307fb_write_cmd(par->client,  com_invdir);
>  	if (ret < 0)
>  		return ret;
>  
> @@ -334,34 +330,38 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par)
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = ssd1307fb_write_cmd(par->client, 0x20);
> +	ret = ssd1307fb_write_cmd(par->client, par->com_offset);
>  	if (ret < 0)
>  		return ret;
>  
>  	/* Set clock frequency */
> +	dclk = (par->dclk_div & 0xf) | (par->dclk_frq & 0xf) << 4;
>  	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_CLOCK_FREQ);
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = ssd1307fb_write_cmd(par->client, 0xf0);
> +	ret = ssd1307fb_write_cmd(par->client, dclk);

It would make more sense to assign the variable where you use it.

>  	if (ret < 0)
>  		return ret;
>  
>  	/* Set precharge period in number of ticks from the internal clock */
> +	precharge = (par->prechargep1 & 0xf) | (par->prechargep2 & 0xf) << 4;
>  	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PRECHARGE_PERIOD);
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = ssd1307fb_write_cmd(par->client, 0x22);
> +	ret = ssd1307fb_write_cmd(par->client, precharge);

Here too.

>  	if (ret < 0)
>  		return ret;
>  
>  	/* Set COM pins configuration */
> +	compins = 0x02 | (!par->com_seq & 0x1) << 4
> +				   | (par->com_lrremap & 0x1) << 5;
>  	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COM_PINS_CONFIG);
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = ssd1307fb_write_cmd(par->client, 0x22);
> +	ret = ssd1307fb_write_cmd(par->client, compins);

And here.

>  	if (ret < 0)
>  		return ret;
>  
> @@ -370,18 +370,20 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par)
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = ssd1307fb_write_cmd(par->client, 0x49);
> +	ret = ssd1307fb_write_cmd(par->client, par->vcomh);
>  	if (ret < 0)
>  		return ret;
>  
> -	/* Turn on the DC-DC Charge Pump */
> -	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CHARGE_PUMP);
> -	if (ret < 0)
> -		return ret;
> +	if (par->device_info->device_id == DEVID_SSD1306) {
> +		/* Turn on the DC-DC Charge Pump */
> +		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CHARGE_PUMP);
> +		if (ret < 0)
> +			return ret;
>  
> -	ret = ssd1307fb_write_cmd(par->client, 0x14);
> -	if (ret < 0)
> -		return ret;
> +		ret = ssd1307fb_write_cmd(par->client, 0x14);
> +		if (ret < 0)
> +			return ret;
> +	};
>  
>  	/* Switch to horizontal addressing mode */
>  	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_ADDRESS_MODE);
> @@ -393,6 +395,7 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par)
>  	if (ret < 0)
>  		return ret;
>  
> +    /* Set column range */

The indentation is wrong.

>  	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE);
>  	if (ret < 0)
>  		return ret;
> @@ -405,6 +408,7 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par)
>  	if (ret < 0)
>  		return ret;
>  
> +    /* Set page range */

Here too.

>  	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE);
>  	if (ret < 0)
>  		return ret;
> @@ -426,18 +430,28 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par)
>  	return 0;
>  }
>  
> -static struct ssd1307fb_ops ssd1307fb_ssd1306_ops = {
> -	.init	= ssd1307fb_ssd1306_init,
> +static struct ssd1307fb_deviceinfo ssd1307fb_ssd1306_deviceinfo = {
> +	.device_id  = DEVID_SSD1306,
> +	.default_vcomh = 0x20,
> +	.default_dclk_div = 0,
> +	.default_dclk_frq = 8,
> +};
> +
> +static struct ssd1307fb_deviceinfo ssd1307fb_ssd1307_deviceinfo = {
> +	.device_id  = DEVID_SSD1307,
> +	.default_vcomh = 0x20,
> +	.default_dclk_div = 1,
> +	.default_dclk_frq = 12,
>  };
>  
>  static const struct of_device_id ssd1307fb_of_match[] = {
>  	{
>  		.compatible = "solomon,ssd1306fb-i2c",
> -		.data = (void *)&ssd1307fb_ssd1306_ops,
> +		.data = (void *)&ssd1307fb_ssd1306_deviceinfo,
>  	},
>  	{
>  		.compatible = "solomon,ssd1307fb-i2c",
> -		.data = (void *)&ssd1307fb_ssd1307_ops,
> +		.data = (void *)&ssd1307fb_ssd1307_deviceinfo,

Do we need this ID? Wouldn't it make more sense to pass the pointer to
the struct we need to use?

>  	},
>  	{},
>  };
> @@ -468,8 +482,8 @@ static int ssd1307fb_probe(struct i2c_client *client,
>  	par->info = info;
>  	par->client = client;
>  
> -	par->ops = (struct ssd1307fb_ops *)of_match_device(ssd1307fb_of_match,
> -							   &client->dev)->data;
> +	par->device_info = (struct ssd1307fb_deviceinfo *)of_match_device(
> +			ssd1307fb_of_match, &client->dev)->data;
>  
>  	par->reset = of_get_named_gpio(client->dev.of_node,
>  					 "reset-gpios", 0);
> @@ -487,6 +501,27 @@ static int ssd1307fb_probe(struct i2c_client *client,
>  	if (of_property_read_u32(node, "solomon,page-offset", &par->page_offset))
>  		par->page_offset = 1;
>  
> +	if (of_property_read_u32(node, "solomon,com-offset", &par->com_offset))
> +		par->com_offset = 0;
> +
> +	if (of_property_read_u32(node, "solomon,prechargep1", &par->prechargep1))
> +		par->prechargep1 = 2;
> +
> +	if (of_property_read_u32(node, "solomon,prechargep2", &par->prechargep2))
> +		par->prechargep2 = 0;
> +
> +	par->seg_remap = !of_property_read_bool(node, "solomon,segment-no-remap");
> +	par->com_seq = of_property_read_bool(node, "solomon,com-sequential");
> +	par->com_lrremap = of_property_read_bool(node, "solomon,com-lrremap");
> +	par->com_invdir = of_property_read_bool(node, "solomon,com-invdir");
> +
> +	par->contrast = contrast;
> +	par->vcomh = par->device_info->default_vcomh;
> +
> +	/* Setup display timing */
> +	par->dclk_div = par->device_info->default_dclk_div;
> +	par->dclk_frq = par->device_info->default_dclk_frq;
> +
>  	vmem_size = par->width * par->height / 8;
>  
>  	vmem = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
> @@ -539,11 +574,9 @@ static int ssd1307fb_probe(struct i2c_client *client,
>  	gpio_set_value(par->reset, 1);
>  	udelay(4);
>  
> -	if (par->ops->init) {
> -		ret = par->ops->init(par);
> -		if (ret)
> -			goto reset_oled_error;
> -	}
> +	ret = ssd1307fb_init(par);
> +	if (ret)
> +		goto reset_oled_error;
>  
>  	ret = register_framebuffer(info);
>  	if (ret) {
> @@ -556,8 +589,10 @@ static int ssd1307fb_probe(struct i2c_client *client,
>  	return 0;
>  
>  panel_init_error:
> -	if (par->ops->remove)
> -		par->ops->remove(par);
> +	if (par->device_info->device_id == DEVID_SSD1307) {
> +		pwm_disable(par->pwm);
> +		pwm_put(par->pwm);
> +	};
>  reset_oled_error:
>  	fb_deferred_io_cleanup(info);
>  fb_alloc_error:
> @@ -571,8 +606,10 @@ static int ssd1307fb_remove(struct i2c_client *client)
>  	struct ssd1307fb_par *par = info->par;
>  
>  	unregister_framebuffer(info);
> -	if (par->ops->remove)
> -		par->ops->remove(par);
> +	if (par->device_info->device_id == DEVID_SSD1307) {
> +		pwm_disable(par->pwm);
> +		pwm_put(par->pwm);
> +	};
>  	fb_deferred_io_cleanup(info);
>  	__free_pages(__va(info->fix.smem_start), get_order(info->fix.smem_len));
>  	framebuffer_release(info);
> -- 
> 2.3.0
> 

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* [PATCH v3] video: mxsfb: Make sure axi clock is enabled when accessing registers
From: Liu Ying @ 2015-03-19  6:07 UTC (permalink / raw)
  To: linux-fbdev
  Cc: Peter Chen, Jean-Christophe Plagniol-Villard, Tomi Valkeinen,
	Fabio Estevam, Greg Kroah-Hartman, linux-kernel, stable

The LCDIF engines embedded in i.MX6sl and i.MX6sx SoCs need the axi clock
as the engine's system clock.  The clock should be enabled when accessing
LCDIF registers, otherwise the kernel would hang up.  We should also keep
the clock enabled when the engine is being active to scan out frames from
memory.  This patch makes sure the axi clock is enabled when accessing
registers so that the kernel hang up issue can be fixed.

Reported-by: Peter Chen <peter.chen@freescale.com>
Tested-by: Peter Chen <peter.chen@freescale.com>
Cc: <stable@vger.kernel.org> # 3.19+
Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
---
v2->v3:
* To address Tomi's comment, improve the commit message only.

v1->v2:
* Add 'Tested-by: Peter Chen <peter.chen@freescale.com>' tag.
* Add 'Cc: <stable@vger.kernel.org> # 3.19+' tag.

 drivers/video/fbdev/mxsfb.c | 70 ++++++++++++++++++++++++++++++++++++---------
 1 file changed, 56 insertions(+), 14 deletions(-)

diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c
index f8ac4a4..a8cf3b2 100644
--- a/drivers/video/fbdev/mxsfb.c
+++ b/drivers/video/fbdev/mxsfb.c
@@ -316,6 +316,18 @@ static int mxsfb_check_var(struct fb_var_screeninfo *var,
 	return 0;
 }
 
+static inline void mxsfb_enable_axi_clk(struct mxsfb_info *host)
+{
+	if (host->clk_axi)
+		clk_prepare_enable(host->clk_axi);
+}
+
+static inline void mxsfb_disable_axi_clk(struct mxsfb_info *host)
+{
+	if (host->clk_axi)
+		clk_disable_unprepare(host->clk_axi);
+}
+
 static void mxsfb_enable_controller(struct fb_info *fb_info)
 {
 	struct mxsfb_info *host = to_imxfb_host(fb_info);
@@ -333,14 +345,13 @@ static void mxsfb_enable_controller(struct fb_info *fb_info)
 		}
 	}
 
-	if (host->clk_axi)
-		clk_prepare_enable(host->clk_axi);
-
 	if (host->clk_disp_axi)
 		clk_prepare_enable(host->clk_disp_axi);
 	clk_prepare_enable(host->clk);
 	clk_set_rate(host->clk, PICOS2KHZ(fb_info->var.pixclock) * 1000U);
 
+	mxsfb_enable_axi_clk(host);
+
 	/* if it was disabled, re-enable the mode again */
 	writel(CTRL_DOTCLK_MODE, host->base + LCDC_CTRL + REG_SET);
 
@@ -380,11 +391,11 @@ static void mxsfb_disable_controller(struct fb_info *fb_info)
 	reg = readl(host->base + LCDC_VDCTRL4);
 	writel(reg & ~VDCTRL4_SYNC_SIGNALS_ON, host->base + LCDC_VDCTRL4);
 
+	mxsfb_disable_axi_clk(host);
+
 	clk_disable_unprepare(host->clk);
 	if (host->clk_disp_axi)
 		clk_disable_unprepare(host->clk_disp_axi);
-	if (host->clk_axi)
-		clk_disable_unprepare(host->clk_axi);
 
 	host->enabled = 0;
 
@@ -421,6 +432,8 @@ static int mxsfb_set_par(struct fb_info *fb_info)
 		mxsfb_disable_controller(fb_info);
 	}
 
+	mxsfb_enable_axi_clk(host);
+
 	/* clear the FIFOs */
 	writel(CTRL1_FIFO_CLEAR, host->base + LCDC_CTRL1 + REG_SET);
 
@@ -438,6 +451,7 @@ static int mxsfb_set_par(struct fb_info *fb_info)
 		ctrl |= CTRL_SET_WORD_LENGTH(3);
 		switch (host->ld_intf_width) {
 		case STMLCDIF_8BIT:
+			mxsfb_disable_axi_clk(host);
 			dev_err(&host->pdev->dev,
 					"Unsupported LCD bus width mapping\n");
 			return -EINVAL;
@@ -451,6 +465,7 @@ static int mxsfb_set_par(struct fb_info *fb_info)
 		writel(CTRL1_SET_BYTE_PACKAGING(0x7), host->base + LCDC_CTRL1);
 		break;
 	default:
+		mxsfb_disable_axi_clk(host);
 		dev_err(&host->pdev->dev, "Unhandled color depth of %u\n",
 				fb_info->var.bits_per_pixel);
 		return -EINVAL;
@@ -504,6 +519,8 @@ static int mxsfb_set_par(struct fb_info *fb_info)
 			fb_info->fix.line_length * fb_info->var.yoffset,
 			host->base + host->devdata->next_buf);
 
+	mxsfb_disable_axi_clk(host);
+
 	if (reenable)
 		mxsfb_enable_controller(fb_info);
 
@@ -582,10 +599,16 @@ static int mxsfb_pan_display(struct fb_var_screeninfo *var,
 
 	offset = fb_info->fix.line_length * var->yoffset;
 
+	if (!host->enabled)
+		mxsfb_enable_axi_clk(host);
+
 	/* update on next VSYNC */
 	writel(fb_info->fix.smem_start + offset,
 			host->base + host->devdata->next_buf);
 
+	if (!host->enabled)
+		mxsfb_disable_axi_clk(host);
+
 	return 0;
 }
 
@@ -608,13 +631,17 @@ static int mxsfb_restore_mode(struct mxsfb_info *host,
 	unsigned line_count;
 	unsigned period;
 	unsigned long pa, fbsize;
-	int bits_per_pixel, ofs;
+	int bits_per_pixel, ofs, ret = 0;
 	u32 transfer_count, vdctrl0, vdctrl2, vdctrl3, vdctrl4, ctrl;
 
+	mxsfb_enable_axi_clk(host);
+
 	/* Only restore the mode when the controller is running */
 	ctrl = readl(host->base + LCDC_CTRL);
-	if (!(ctrl & CTRL_RUN))
-		return -EINVAL;
+	if (!(ctrl & CTRL_RUN)) {
+		ret = -EINVAL;
+		goto err;
+	}
 
 	vdctrl0 = readl(host->base + LCDC_VDCTRL0);
 	vdctrl2 = readl(host->base + LCDC_VDCTRL2);
@@ -635,7 +662,8 @@ static int mxsfb_restore_mode(struct mxsfb_info *host,
 		break;
 	case 1:
 	default:
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err;
 	}
 
 	fb_info->var.bits_per_pixel = bits_per_pixel;
@@ -673,10 +701,14 @@ static int mxsfb_restore_mode(struct mxsfb_info *host,
 
 	pa = readl(host->base + host->devdata->cur_buf);
 	fbsize = fb_info->fix.line_length * vmode->yres;
-	if (pa < fb_info->fix.smem_start)
-		return -EINVAL;
-	if (pa + fbsize > fb_info->fix.smem_start + fb_info->fix.smem_len)
-		return -EINVAL;
+	if (pa < fb_info->fix.smem_start) {
+		ret = -EINVAL;
+		goto err;
+	}
+	if (pa + fbsize > fb_info->fix.smem_start + fb_info->fix.smem_len) {
+		ret = -EINVAL;
+		goto err;
+	}
 	ofs = pa - fb_info->fix.smem_start;
 	if (ofs) {
 		memmove(fb_info->screen_base, fb_info->screen_base + ofs, fbsize);
@@ -689,7 +721,11 @@ static int mxsfb_restore_mode(struct mxsfb_info *host,
 	clk_prepare_enable(host->clk);
 	host->enabled = 1;
 
-	return 0;
+err:
+	if (ret)
+		mxsfb_disable_axi_clk(host);
+
+	return ret;
 }
 
 static int mxsfb_init_fbinfo_dt(struct mxsfb_info *host,
@@ -915,7 +951,9 @@ static int mxsfb_probe(struct platform_device *pdev)
 	}
 
 	if (!host->enabled) {
+		mxsfb_enable_axi_clk(host);
 		writel(0, host->base + LCDC_CTRL);
+		mxsfb_disable_axi_clk(host);
 		mxsfb_set_par(fb_info);
 		mxsfb_enable_controller(fb_info);
 	}
@@ -954,11 +992,15 @@ static void mxsfb_shutdown(struct platform_device *pdev)
 	struct fb_info *fb_info = platform_get_drvdata(pdev);
 	struct mxsfb_info *host = to_imxfb_host(fb_info);
 
+	mxsfb_enable_axi_clk(host);
+
 	/*
 	 * Force stop the LCD controller as keeping it running during reboot
 	 * might interfere with the BootROM's boot mode pads sampling.
 	 */
 	writel(CTRL_RUN, host->base + LCDC_CTRL + REG_CLR);
+
+	mxsfb_disable_axi_clk(host);
 }
 
 static struct platform_driver mxsfb_driver = {
-- 
2.1.0


^ permalink raw reply related

* possible typo in ancient radeon code
From: Dan Carpenter @ 2015-03-19 12:30 UTC (permalink / raw)
  To: linux-fbdev

Hello FB devs,

This ancient code from 1da177e4c3f4: "Linux-2.6.12-rc2" from Apr 16,
2005, leads to the following static checker warning:

	drivers/video/fbdev/aty/radeon_pm.c:417 radeon_pm_enable_dynamic_mode()
	warn: we tested 'tmp & (1 << 21)' before and it was 'true'

include/video/radeon.h
  1216  #define MCLK_CNTL__MRDCKA1_SOUTSEL_MASK                 0x0c000000L
  1217  #define MCLK_CNTL__MRDCKB0_SOUTSEL_MASK                 0x30000000L
  1218  #define MCLK_CNTL__MRDCKB1_SOUTSEL_MASK                 0xc0000000L
  1219  #define MCLK_CNTL__R300_DISABLE_MC_MCLKA                (1 << 21)
  1220  #define MCLK_CNTL__R300_DISABLE_MC_MCLKB                (1 << 21)

These are probably supposed to refer to different bits.

  1221  
  1222  // MCLK_MISC

drivers/video/fbdev/aty/radeon_pm.c
   411                  /* Some releases of vbios have set DISABLE_MC_MCLKA
   412                   * and DISABLE_MC_MCLKB bits in the vbios table.  Setting these
   413                   * bits will cause H/W hang when reading video memory with dynamic
   414                   * clocking enabled.
   415                   */
   416                  if ((tmp & MCLK_CNTL__R300_DISABLE_MC_MCLKA) &&
   417                      (tmp & MCLK_CNTL__R300_DISABLE_MC_MCLKB)) {

The duplicate check here causes a warning.  I guess it probably doesn't
matter if no one complains...

   418                          /* If both bits are set, then check the active channels */
   419                          tmp = INPLL(pllMCLK_CNTL);
   420                          if (rinfo->vram_width = 64) {
   421                              if (INREG(MEM_CNTL) & R300_MEM_USE_CD_CH_ONLY)
   422                                  tmp &= ~MCLK_CNTL__R300_DISABLE_MC_MCLKB;
   423                              else
   424                                  tmp &= ~MCLK_CNTL__R300_DISABLE_MC_MCLKA;
   425                          } else {
   426                              tmp &= ~(MCLK_CNTL__R300_DISABLE_MC_MCLKA |
   427                                       MCLK_CNTL__R300_DISABLE_MC_MCLKB);
   428                          }
   429                  }


regards,
dan carpenter

^ permalink raw reply

* Re: possible typo in ancient radeon code
From: Geert Uytterhoeven @ 2015-03-19 12:52 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <20150319123021.GA12264@mwanda>

CC BenH

On Thu, Mar 19, 2015 at 1:30 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Hello FB devs,
>
> This ancient code from 1da177e4c3f4: "Linux-2.6.12-rc2" from Apr 16,
> 2005, leads to the following static checker warning:

Nah, it's a little bit older (in full-history-linux ;-)

commit 9ff343f3d155aa35f79bae8607d7c4500d7ef848
Author: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date:   Thu Feb 10 16:03:30 2005 -0800

    [PATCH] radeonfb update

>
>         drivers/video/fbdev/aty/radeon_pm.c:417 radeon_pm_enable_dynamic_mode()
>         warn: we tested 'tmp & (1 << 21)' before and it was 'true'
>
> include/video/radeon.h
>   1216  #define MCLK_CNTL__MRDCKA1_SOUTSEL_MASK                 0x0c000000L
>   1217  #define MCLK_CNTL__MRDCKB0_SOUTSEL_MASK                 0x30000000L
>   1218  #define MCLK_CNTL__MRDCKB1_SOUTSEL_MASK                 0xc0000000L
>   1219  #define MCLK_CNTL__R300_DISABLE_MC_MCLKA                (1 << 21)
>   1220  #define MCLK_CNTL__R300_DISABLE_MC_MCLKB                (1 << 21)
>
> These are probably supposed to refer to different bits.
>
>   1221
>   1222  // MCLK_MISC
>
> drivers/video/fbdev/aty/radeon_pm.c
>    411                  /* Some releases of vbios have set DISABLE_MC_MCLKA
>    412                   * and DISABLE_MC_MCLKB bits in the vbios table.  Setting these
>    413                   * bits will cause H/W hang when reading video memory with dynamic
>    414                   * clocking enabled.
>    415                   */
>    416                  if ((tmp & MCLK_CNTL__R300_DISABLE_MC_MCLKA) &&
>    417                      (tmp & MCLK_CNTL__R300_DISABLE_MC_MCLKB)) {
>
> The duplicate check here causes a warning.  I guess it probably doesn't
> matter if no one complains...
>
>    418                          /* If both bits are set, then check the active channels */
>    419                          tmp = INPLL(pllMCLK_CNTL);
>    420                          if (rinfo->vram_width = 64) {
>    421                              if (INREG(MEM_CNTL) & R300_MEM_USE_CD_CH_ONLY)
>    422                                  tmp &= ~MCLK_CNTL__R300_DISABLE_MC_MCLKB;
>    423                              else
>    424                                  tmp &= ~MCLK_CNTL__R300_DISABLE_MC_MCLKA;
>    425                          } else {
>    426                              tmp &= ~(MCLK_CNTL__R300_DISABLE_MC_MCLKA |
>    427                                       MCLK_CNTL__R300_DISABLE_MC_MCLKB);
>    428                          }
>    429                  }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* Re: [PATCHv4 07/10] fbdev: ssd1307fb: Add a module parameter to set the refresh rate
From: Maxime Ripard @ 2015-03-19 13:18 UTC (permalink / raw)
  To: Thomas Niederprüm
  Cc: plagnioj, tomi.valkeinen, kernel, shawn.guo, robh+dt, linux-fbdev,
	linux-kernel
In-Reply-To: <1426525918-12745-8-git-send-email-niederp@physik.uni-kl.de>

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

On Mon, Mar 16, 2015 at 06:11:55PM +0100, Thomas Niederprüm wrote:
> This patch adds the module parameter "refreshrate" to set delay for the
> deferred io. The refresh rate is given in units of Hertz. The default
> refresh rate is 1 Hz. The refresh rate set through the newly introduced
> parameter applies to all instances of the driver and for now it is not
> possible to change it individually.
> 
> Signed-off-by: Thomas Niederprüm <niederp@physik.uni-kl.de>
> ---
>  drivers/video/fbdev/ssd1307fb.c | 23 +++++++++++++++++------
>  1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
> index 6fecec8..8a8d305 100644
> --- a/drivers/video/fbdev/ssd1307fb.c
> +++ b/drivers/video/fbdev/ssd1307fb.c
> @@ -42,6 +42,11 @@
>  #define	SSD1307FB_SET_COM_PINS_CONFIG	0xda
>  #define	SSD1307FB_SET_VCOMH		0xdb
>  
> +#define REFRASHRATE 1
> +
> +static u_int refreshrate = REFRASHRATE;

s/REFRASH/REFRESH/ :)

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* Re: [PATCHv4 09/10] fbdev: ssd1307fb: add backlight controls for setting the contrast
From: Maxime Ripard @ 2015-03-19 13:22 UTC (permalink / raw)
  To: Thomas Niederprüm
  Cc: plagnioj, tomi.valkeinen, kernel, shawn.guo, robh+dt, linux-fbdev,
	linux-kernel
In-Reply-To: <1426525918-12745-10-git-send-email-niederp@physik.uni-kl.de>

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

On Mon, Mar 16, 2015 at 06:11:57PM +0100, Thomas Niederprüm wrote:
> The backlight class is used to create userspace handles for
> setting the OLED contrast.
> 
> Signed-off-by: Thomas Niederprüm <niederp@physik.uni-kl.de>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* Re: [PATCH] sm750fb: Fix C99 Comments and if else braces
From: Giedrius Statkevičius @ 2015-03-19 17:42 UTC (permalink / raw)
  To: Amitoj Kaur Chawla, sudipm.mukherjee, teddy.wang, gregkh,
	linux-fbdev, devel, linux-kernel
In-Reply-To: <20150319173947.GA12061@amitoj-Inspiron-3542>

Hi Amitoj Kaur Chawla,

On 2015.03.19 19:39, Amitoj Kaur Chawla wrote:
> The edits have been made to remove C99 Comments and properly indent
> the if-else statements in the file while taking care of the braces according to
> Linux coding style.
> 
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> ---
>  drivers/staging/sm750fb/ddk750_chip.c | 25 +++++++++++--------------
>  1 file changed, 11 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c
> index 33add64..33fa456 100644
> --- a/drivers/staging/sm750fb/ddk750_chip.c
> +++ b/drivers/staging/sm750fb/ddk750_chip.c
> @@ -17,25 +17,22 @@ logical_chip_type_t getChipType(void)
>  	char physicalRev;
>  	logical_chip_type_t chip;
>  
> -	physicalID = devId750;//either 0x718 or 0x750
> +	physicalID = devId750;/* either 0x718 or 0x750 */

Add a space here after ;?

>  	physicalRev = revId750;
>  
> -    if (physicalID = 0x718)
> -    {
> -        chip = SM718;
> -    }
> -    else if (physicalID = 0x750)
> -    {
> -        chip = SM750;
> +	if (physicalID = 0x718) {
> +		chip = SM718;
> +	}
> +	else if (physicalID = 0x750) {
> +		chip = SM750;
>  		/* SM750 and SM750LE are different in their revision ID only. */
> -		if (physicalRev = SM750LE_REVISION_ID){
> +		if (physicalRev = SM750LE_REVISION_ID) {
>  			chip = SM750LE;
>  		}
> -    }
> -    else
> -    {
> -        chip = SM_UNKNOWN;
> -    }
> +	}
> +	else {
> +		chip = SM_UNKNOWN;
> +	}
>  
>  	return chip;
>  }
> 


-- 
Thanks,
Giedrius

^ permalink raw reply

* [PATCH] sm750fb: Fix C99 Comments and if else braces
From: Amitoj Kaur Chawla @ 2015-03-19 17:51 UTC (permalink / raw)
  To: sudipm.mukherjee, teddy.wang, gregkh, linux-fbdev, devel,
	linux-kernel
In-Reply-To: <550B0A6B.5090008@gmail.com>

The edits have been made to remove C99 Comments and properly indent
the if-else statements in the file while taking care of the braces according to
Linux coding style.

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/staging/sm750fb/ddk750_chip.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c
index 33add64..33fa456 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -17,25 +17,22 @@ logical_chip_type_t getChipType(void)
 	char physicalRev;
 	logical_chip_type_t chip;
 
-	physicalID = devId750;//either 0x718 or 0x750
+	physicalID = devId750;/* either 0x718 or 0x750 */
 	physicalRev = revId750;
 
-    if (physicalID = 0x718)
-    {
-        chip = SM718;
-    }
-    else if (physicalID = 0x750)
-    {
-        chip = SM750;
+	if (physicalID = 0x718) {
+		chip = SM718;
+	}
+	else if (physicalID = 0x750) {
+		chip = SM750;
 		/* SM750 and SM750LE are different in their revision ID only. */
-		if (physicalRev = SM750LE_REVISION_ID){
+		if (physicalRev = SM750LE_REVISION_ID) {
 			chip = SM750LE;
 		}
-    }
-    else
-    {
-        chip = SM_UNKNOWN;
-    }
+	}
+	else {
+		chip = SM_UNKNOWN;
+	}
 
 	return chip;
 }
-- 
1.9.1


^ permalink raw reply related

* Re: [PATCH] sm750fb: Fix C99 Comments and if else braces
From: Joe Perches @ 2015-03-19 18:06 UTC (permalink / raw)
  To: Amitoj Kaur Chawla
  Cc: sudipm.mukherjee, teddy.wang, gregkh, linux-fbdev, devel,
	linux-kernel
In-Reply-To: <20150319173947.GA12061@amitoj-Inspiron-3542>

On Thu, 2015-03-19 at 23:09 +0530, Amitoj Kaur Chawla wrote:
> The edits have been made to remove C99 Comments and properly indent
> the if-else statements in the file while taking care of the braces according to
> Linux coding style.

Please scan your proposed patches with checkpatch
and fix possible style defects before sending them.





^ permalink raw reply

* Re: [PATCH] sm750fb: Fix Comment and if else braces
From: Giedrius Statkevičius @ 2015-03-19 18:13 UTC (permalink / raw)
  To: Amitoj Kaur Chawla, sudipm.mukherjee, teddy.wang, gregkh,
	linux-fbdev, devel, linux-kernel
In-Reply-To: <20150319180556.GA12241@amitoj-Inspiron-3542>

Hi Amitoj Kaur Chawla,

On 2015.03.19 20:05, Amitoj Kaur Chawla wrote:
> The edits have been made to add a space before the comment and the errors in
> braces in the if-else statements.
> Previously in commit 2d34f53f1065878cd881ac61a183f8e836583d51, removed
> the C99 comments and errors in if-else indentation and braces.

The previous patch isn't in the git repo yet so it doesn't have a commit
id thus this one is wrong. You should've just made a v2 and made that
change. I recommend you to look over this:
http://kernelnewbies.org/FirstKernelPatch Just remove the HEAD commit in
your local git repo, add that space and then when using `git
format-patch` use the "--subject-prefix" option to add that it's a
second version. Then after "---" you can say what was changed in the
second version. For example (I'm sure you can think of a better one!):

Signed-off-by: ...
---
v2: added a space after a statement in a line where a coding style error
was fixed.

drivers/...

>  
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> ---
>  drivers/staging/sm750fb/ddk750_chip.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c
> index 33fa456..bdf6a73 100644
> --- a/drivers/staging/sm750fb/ddk750_chip.c
> +++ b/drivers/staging/sm750fb/ddk750_chip.c
> @@ -17,20 +17,17 @@ logical_chip_type_t getChipType(void)
>  	char physicalRev;
>  	logical_chip_type_t chip;
>  
> -	physicalID = devId750;/* either 0x718 or 0x750 */
> +	physicalID = devId750; /* either 0x718 or 0x750 */
>  	physicalRev = revId750;
>  
>  	if (physicalID = 0x718) {
>  		chip = SM718;
> -	}
> -	else if (physicalID = 0x750) {
> +	} else if (physicalID = 0x750) {
>  		chip = SM750;
>  		/* SM750 and SM750LE are different in their revision ID only. */
> -		if (physicalRev = SM750LE_REVISION_ID) {
> +		if (physicalRev = SM750LE_REVISION_ID)
>  			chip = SM750LE;
> -		}
> -	}
> -	else {
> +	} else {
>  		chip = SM_UNKNOWN;
>  	}
>  
> 


-- 
Thanks,
Giedrius

^ permalink raw reply

* [PATCH] sm750fb: Fix Comment and if else braces
From: Amitoj Kaur Chawla @ 2015-03-19 18:17 UTC (permalink / raw)
  To: sudipm.mukherjee, teddy.wang, gregkh, linux-fbdev, devel,
	linux-kernel
In-Reply-To: <550B11C0.1030300@gmail.com>

The edits have been made to add a space before the comment and the errors in
braces in the if-else statements.
Previously in commit 2d34f53f1065878cd881ac61a183f8e836583d51, removed
the C99 comments and errors in if-else indentation and braces.
 
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/staging/sm750fb/ddk750_chip.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c
index 33fa456..bdf6a73 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -17,20 +17,17 @@ logical_chip_type_t getChipType(void)
 	char physicalRev;
 	logical_chip_type_t chip;
 
-	physicalID = devId750;/* either 0x718 or 0x750 */
+	physicalID = devId750; /* either 0x718 or 0x750 */
 	physicalRev = revId750;
 
 	if (physicalID = 0x718) {
 		chip = SM718;
-	}
-	else if (physicalID = 0x750) {
+	} else if (physicalID = 0x750) {
 		chip = SM750;
 		/* SM750 and SM750LE are different in their revision ID only. */
-		if (physicalRev = SM750LE_REVISION_ID) {
+		if (physicalRev = SM750LE_REVISION_ID)
 			chip = SM750LE;
-		}
-	}
-	else {
+	} else {
 		chip = SM_UNKNOWN;
 	}
 
-- 
1.9.1


^ permalink raw reply related

* [PATCH] staging: sm750fb: fixing multiple checkpatch errors and warnings
From: Michel von Czettritz @ 2015-03-19 19:26 UTC (permalink / raw)
  To: sudipm.mukherjee
  Cc: teddy.wang, gregkh, linux-kernel, kernel-janitors, linux-fbdev

This patch formats sm750.c to
- correct intendations
- no leading or trailing whitespaces
- no C99 Style comments
- correct braces and spacings for if, for and functions
- no initalisation of static variables to 0 or NULL
- no assignments in if conditions
- correct spacings arround pointers and function arguments

and some other warnings


Signed-off-by: Michel von Czettritz <michel.von.czettritz@gmail.com>
---
 drivers/staging/sm750fb/sm750.c | 1306 ++++++++++++++++++++-------------------
 1 file changed, 674 insertions(+), 632 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index a7b1b9c..b81e5b7 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -33,15 +33,15 @@ int smi_indent = 0;
 /*
 #ifdef __BIG_ENDIAN
 ssize_t lynxfb_ops_write(struct fb_info *info, const char __user *buf,
- 	    size_t count, loff_t *ppos);
+			size_t count, loff_t *ppos);
 ssize_t lynxfb_ops_read(struct fb_info *info, char __user *buf,
-			   size_t count, loff_t *ppos);
+			size_t count, loff_t *ppos);
 #endif
  */
 
-typedef void (*PROC_SPEC_SETUP)(struct lynx_share*,char *);
-typedef int (*PROC_SPEC_MAP)(struct lynx_share*,struct pci_dev*);
-typedef int (*PROC_SPEC_INITHW)(struct lynx_share*,struct pci_dev*);
+typedef void (*PROC_SPEC_SETUP)(struct lynx_share*, char *);
+typedef int (*PROC_SPEC_MAP)(struct lynx_share*, struct pci_dev*);
+typedef int (*PROC_SPEC_INITHW)(struct lynx_share*, struct pci_dev*);
 
 
 /* common var for all device */
@@ -50,59 +50,61 @@ static int g_noaccel;
 #ifdef CONFIG_MTRR
 static int g_nomtrr;
 #endif
-static const char * g_fbmode[] = {NULL,NULL};
-static const char * g_def_fbmode = "800x600-16@60";
-static char * g_settings = NULL;
+static const char *g_fbmode[] = {NULL, NULL};
+static const char *g_def_fbmode = "800x600-16@60";
+static char *g_settings;
 static int g_dualview;
-static char * g_option = NULL;
+static char *g_option;
 
 /* if not use spin_lock,system will die if user load driver
  * and immediatly unload driver frequently (dual)*/
-static inline void myspin_lock(spinlock_t * sl){
-	struct lynx_share * share;
-	share = container_of(sl,struct lynx_share,slock);
-	if(share->dual){
+static inline void myspin_lock(spinlock_t *sl)
+{
+	struct lynx_share *share;
+
+	share = container_of(sl, struct lynx_share, slock);
+	if (share->dual)
 		spin_lock(sl);
-	}
 }
 
-static inline void myspin_unlock(spinlock_t * sl){
-	struct lynx_share * share;
-	share = container_of(sl,struct lynx_share,slock);
-	if(share->dual){
+static inline void myspin_unlock(spinlock_t *sl)
+{
+	struct lynx_share *share;
+
+	share = container_of(sl, struct lynx_share, slock);
+	if (share->dual)
 		spin_unlock(sl);
-	}
 }
 static const struct fb_videomode lynx750_ext[] = {
-	/*  	1024x600-60 VESA 	[1.71:1]	*/
-	{NULL,  60, 1024, 600, 20423, 144,  40, 18, 1, 104, 3,
+	/*	1024x600-60 VESA	[1.71:1]	*/
+	{NULL, 60, 1024, 600, 20423, 144,  40, 18, 1, 104, 3,
 	FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
 
-	/* 	1024x600-70 VESA */
-	{NULL,  70, 1024, 600, 17211, 152,  48, 21, 1, 104, 3,
+	/*	1024x600-70 VESA */
+	{NULL, 70, 1024, 600, 17211, 152,  48, 21, 1, 104, 3,
 	FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
 
-	/*  	1024x600-75 VESA */
-	{NULL,  75, 1024, 600, 15822, 160,  56, 23, 1, 104, 3,
+	/*	1024x600-75 VESA */
+	{NULL, 75, 1024, 600, 15822, 160,  56, 23, 1, 104, 3,
 	FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
 
-	/*  	1024x600-85 VESA */
-	{NULL,  85, 1024, 600, 13730, 168,  56, 26, 1, 112, 3,
+	/*	1024x600-85 VESA */
+	{NULL, 85, 1024, 600, 13730, 168,  56, 26, 1, 112, 3,
 	FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
 
 	/*	720x480	*/
-	{NULL, 60,  720,  480,  37427, 88,   16, 13, 1,   72,  3,
+	{NULL, 60, 720,  480, 37427, 88,   16, 13, 1, 72, 3,
 	FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
 
-	/*	1280x720		[1.78:1]	*/
-	{NULL, 60,  1280,  720,  13426, 162, 86, 22, 1,  136, 3,
-	FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,FB_VMODE_NONINTERLACED},
+	/*	1280x720	[1.78:1]	*/
+	{NULL, 60, 1280, 720, 13426, 162, 86, 22, 1,  136, 3,
+	FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
 
-	/* 1280x768@60 */
-	{NULL,60,1280,768,12579,192,64,20,3,128,7,
-	FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,FB_VMODE_NONINTERLACED},
+	/*	1280x768@60 */
+	{NULL, 60, 1280, 768, 12579, 192, 64, 20, 3, 128, 7,
+	FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
 
-	{NULL,60,1360,768,11804,208,64,23,1,144,3,
+	{NULL, 60, 1360, 768, 11804, 208, 64, 23, 1, 144, 3,
 	FB_SYNC_HOR_HIGH_ACT|FB_VMODE_NONINTERLACED},
 
 	/*	1360 x 768	[1.77083:1]	*/
@@ -113,89 +115,87 @@ static const struct fb_videomode lynx750_ext[] = {
 	{NULL, 60,  1368,  768,  11647, 216, 72, 23, 1,  144, 3,
 	FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
 
-	/* 	1440 x 900		[16:10]	*/
+	/*	1440 x 900	[16:10]	*/
 	{NULL, 60, 1440, 900, 9392, 232, 80, 28, 1, 152, 3,
-	FB_SYNC_VERT_HIGH_ACT,FB_VMODE_NONINTERLACED},
+	FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
 
-	/*	1440x960		[15:10]	*/
+	/*	1440x960	[15:10]	*/
 	{NULL, 60, 1440, 960, 8733, 240, 88, 30, 1, 152, 3,
 	FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
 
 	/*	1920x1080	[16:9]	*/
 	{NULL, 60, 1920, 1080, 6734, 148, 88, 41, 1, 44, 3,
-	FB_SYNC_VERT_HIGH_ACT,FB_VMODE_NONINTERLACED},
+	FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
 };
 
 
 
 
 /* no hardware cursor supported under version 2.6.10, kernel bug */
-static int lynxfb_ops_cursor(struct fb_info* info,struct fb_cursor* fbcursor)
+static int lynxfb_ops_cursor(struct fb_info *info, struct fb_cursor *fbcursor)
 {
-	struct lynxfb_par * par;
-	struct lynxfb_crtc * crtc;
-	struct lynx_cursor * cursor;
+	struct lynxfb_par *par;
+	struct lynxfb_crtc *crtc;
+	struct lynx_cursor *cursor;
 
 	par = info->par;
 	crtc = &par->crtc;
 	cursor = &crtc->cursor;
 
-	if(fbcursor->image.width > cursor->maxW ||
+	if (fbcursor->image.width > cursor->maxW ||
 		fbcursor->image.height > cursor->maxH ||
-		 fbcursor->image.depth > 1){
+		fbcursor->image.depth > 1) {
 		return -ENXIO;
 	}
 
 	cursor->disable(cursor);
-	if(fbcursor->set & FB_CUR_SETSIZE){
-		cursor->setSize(cursor,fbcursor->image.width,fbcursor->image.height);
-	}
+	if (fbcursor->set & FB_CUR_SETSIZE)
+		cursor->setSize(cursor, fbcursor->image.width,
+				fbcursor->image.height);
 
-	if(fbcursor->set & FB_CUR_SETPOS){
-		cursor->setPos(cursor,fbcursor->image.dx - info->var.xoffset,
-								fbcursor->image.dy - info->var.yoffset);
-	}
+	if (fbcursor->set & FB_CUR_SETPOS)
+		cursor->setPos(cursor, fbcursor->image.dx - info->var.xoffset,
+				fbcursor->image.dy - info->var.yoffset);
 
-	if(fbcursor->set & FB_CUR_SETCMAP){
+	if (fbcursor->set & FB_CUR_SETCMAP) {
 		/* get the 16bit color of kernel means */
-		u16 fg,bg;
-		fg = ((info->cmap.red[fbcursor->image.fg_color] & 0xf800))|
-				((info->cmap.green[fbcursor->image.fg_color] & 0xfc00) >> 5)|
-				((info->cmap.blue[fbcursor->image.fg_color] & 0xf800) >> 11);
+		u16 fg, bg;
 
-		bg = ((info->cmap.red[fbcursor->image.bg_color] & 0xf800))|
-				((info->cmap.green[fbcursor->image.bg_color] & 0xfc00) >> 5)|
-				((info->cmap.blue[fbcursor->image.bg_color] & 0xf800) >> 11);
+		fg = ((info->cmap.red[fbcursor->image.fg_color] & 0xf800)) |
+			((info->cmap.green[fbcursor->image.fg_color] & 0xfc00) >> 5) |
+			((info->cmap.blue[fbcursor->image.fg_color] & 0xf800) >> 11);
 
-		cursor->setColor(cursor,fg,bg);
+		bg = ((info->cmap.red[fbcursor->image.bg_color] & 0xf800)) |
+			((info->cmap.green[fbcursor->image.bg_color] & 0xfc00) >> 5) |
+			((info->cmap.blue[fbcursor->image.bg_color] & 0xf800) >> 11);
+
+		cursor->setColor(cursor, fg, bg);
 	}
 
 
-	if(fbcursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE))
-	{
+	if (fbcursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE)) {
 		cursor->setData(cursor,
-						fbcursor->rop,
-						fbcursor->image.data,
-						fbcursor->mask);
+				fbcursor->rop,
+				fbcursor->image.data,
+				fbcursor->mask);
 	}
 
-	if(fbcursor->enable){
+	if (fbcursor->enable)
 		cursor->enable(cursor);
-	}
 
 	return 0;
 }
 
-static void lynxfb_ops_fillrect(struct fb_info* info,const struct fb_fillrect* region)
+static void lynxfb_ops_fillrect(struct fb_info *info,
+		const struct fb_fillrect *region)
 {
-	struct lynxfb_par * par;
-	struct lynx_share * share;
-	unsigned int base,pitch,Bpp,rop;
+	struct lynxfb_par *par;
+	struct lynx_share *share;
+	unsigned int base, pitch, Bpp, rop;
 	u32 color;
 
-	if(info->state != FBINFO_STATE_RUNNING){
+	if (info->state != FBINFO_STATE_RUNNING)
 		return;
-	}
 
 	par = info->par;
 	share = par->share;
@@ -206,23 +206,29 @@ static void lynxfb_ops_fillrect(struct fb_info* info,const struct fb_fillrect* r
 	pitch = info->fix.line_length;
 	Bpp = info->var.bits_per_pixel >> 3;
 
-	color = (Bpp = 1)?region->color:((u32*)info->pseudo_palette)[region->color];
-	rop = ( region->rop != ROP_COPY ) ? HW_ROP2_XOR:HW_ROP2_COPY;
+	color = (Bpp = 1)?region->color:((u32 *)info->pseudo_palette)[region->color];
+	rop = (region->rop != ROP_COPY) ? HW_ROP2_XOR:HW_ROP2_COPY;
 
 	myspin_lock(&share->slock);
 	share->accel.de_fillrect(&share->accel,
-							base,pitch,Bpp,
-							region->dx,region->dy,
-							region->width,region->height,
-							color,rop);
+				base,
+				pitch,
+				Bpp,
+				region->dx,
+				region->dy,
+				region->width,
+				region->height,
+				color,
+				rop);
 	myspin_unlock(&share->slock);
 }
 
-static void lynxfb_ops_copyarea(struct fb_info * info,const struct fb_copyarea * region)
+static void lynxfb_ops_copyarea(struct fb_info *info,
+		const struct fb_copyarea *region)
 {
-	struct lynxfb_par * par;
-	struct lynx_share * share;
-	unsigned int base,pitch,Bpp;
+	struct lynxfb_par *par;
+	struct lynx_share *share;
+	unsigned int base, pitch, Bpp;
 
 	par = info->par;
 	share = par->share;
@@ -235,18 +241,28 @@ static void lynxfb_ops_copyarea(struct fb_info * info,const struct fb_copyarea *
 
 	myspin_lock(&share->slock);
 	share->accel.de_copyarea(&share->accel,
-							base,pitch,region->sx,region->sy,
-							base,pitch,Bpp,region->dx,region->dy,
-							region->width,region->height,HW_ROP2_COPY);
+				base,
+				pitch,
+				region->sx,
+				region->sy,
+				base,
+				pitch,
+				Bpp,
+				region->dx,
+				region->dy,
+				region->width,
+				region->height,
+				HW_ROP2_COPY);
 	myspin_unlock(&share->slock);
 }
 
-static void lynxfb_ops_imageblit(struct fb_info*info,const struct fb_image* image)
+static void lynxfb_ops_imageblit(struct fb_info *info,
+		const struct fb_image *image)
 {
-	unsigned int base,pitch,Bpp;
-	unsigned int fgcol,bgcol;
-	struct lynxfb_par * par;
-	struct lynx_share * share;
+	unsigned int base, pitch, Bpp;
+	unsigned int fgcol, bgcol;
+	struct lynxfb_par *par;
+	struct lynx_share *share;
 
 	par = info->par;
 	share = par->share;
@@ -256,15 +272,12 @@ static void lynxfb_ops_imageblit(struct fb_info*info,const struct fb_image* imag
 	pitch = info->fix.line_length;
 	Bpp = info->var.bits_per_pixel >> 3;
 
-	if(image->depth = 1){
-		if(info->fix.visual = FB_VISUAL_TRUECOLOR ||
-			info->fix.visual = FB_VISUAL_DIRECTCOLOR)
-		{
-			fgcol = ((u32*)info->pseudo_palette)[image->fg_color];
-			bgcol = ((u32*)info->pseudo_palette)[image->bg_color];
-		}
-		else
-		{
+	if (image->depth = 1) {
+		if (info->fix.visual = FB_VISUAL_TRUECOLOR ||
+			info->fix.visual = FB_VISUAL_DIRECTCOLOR) {
+			fgcol = ((u32 *)info->pseudo_palette)[image->fg_color];
+			bgcol = ((u32 *)info->pseudo_palette)[image->bg_color];
+		} else {
 			fgcol = image->fg_color;
 			bgcol = image->bg_color;
 		}
@@ -274,45 +287,52 @@ static void lynxfb_ops_imageblit(struct fb_info*info,const struct fb_image* imag
 _do_work:
 	myspin_lock(&share->slock);
 	share->accel.de_imageblit(&share->accel,
-					image->data,image->width>>3,0,
-					base,pitch,Bpp,
-					image->dx,image->dy,
-					image->width,image->height,
-					fgcol,bgcol,HW_ROP2_COPY);
+				image->data,
+				image->width>>3,
+				0,
+				base,
+				pitch,
+				Bpp,
+				image->dx,
+				image->dy,
+				image->width,
+				image->height,
+				fgcol,
+				bgcol,
+				HW_ROP2_COPY);
 	myspin_unlock(&share->slock);
 }
 
 static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
-        struct fb_info *info)
+		struct fb_info *info)
 {
-    struct lynxfb_par * par;
-    struct lynxfb_crtc * crtc;
-    int ret;
-    
+	struct lynxfb_par *par;
+	struct lynxfb_crtc *crtc;
+	int ret;
 
-    if(!info)
-        return -EINVAL;
+	if (!info)
+		return -EINVAL;
 
-    ret = 0;
-    par = info->par;
-    crtc = &par->crtc;
-    ret = crtc->proc_panDisplay(crtc, var, info);
+	ret = 0;
+	par = info->par;
+	crtc = &par->crtc;
+	ret = crtc->proc_panDisplay(crtc, var, info);
 
-    return ret;
+	return ret;
 }
 
-static int lynxfb_ops_set_par(struct fb_info * info)
+static int lynxfb_ops_set_par(struct fb_info *info)
 {
-	struct lynxfb_par * par;
-	struct lynx_share * share;
-	struct lynxfb_crtc * crtc;
-	struct lynxfb_output * output;
-	struct fb_var_screeninfo * var;
-	struct fb_fix_screeninfo * fix;
+	struct lynxfb_par *par;
+	struct lynx_share *share;
+	struct lynxfb_crtc *crtc;
+	struct lynxfb_output *output;
+	struct fb_var_screeninfo *var;
+	struct fb_fix_screeninfo *fix;
 	int ret;
 	unsigned int line_length;
 
-	if(!info)
+	if (!info)
 		return -EINVAL;
 
 	ret = 0;
@@ -325,15 +345,15 @@ static int lynxfb_ops_set_par(struct fb_info * info)
 
 	/* fix structur is not so FIX ... */
 	line_length = var->xres_virtual * var->bits_per_pixel / 8;
-	line_length = PADDING(crtc->line_pad,line_length);
+	line_length = PADDING(crtc->line_pad, line_length);
 	fix->line_length = line_length;
-	pr_err("fix->line_length = %d\n",fix->line_length);
+	pr_err("fix->line_length = %d\n", fix->line_length);
 
 	/* var->red,green,blue,transp are need to be set by driver
 	 * and these data should be set before setcolreg routine
 	 * */
 
-	switch(var->bits_per_pixel){
+	switch (var->bits_per_pixel) {
 	case 8:
 		fix->visual = FB_VISUAL_PSEUDOCOLOR;
 		var->red.offset = 0;
@@ -362,7 +382,7 @@ static int lynxfb_ops_set_par(struct fb_info * info)
 		var->red.length = 8;
 		var->green.offset = 8;
 		var->green.length = 8;
-		var->blue.offset = 0 ;
+		var->blue.offset = 0;
 		var->blue.length = 8;
 		fix->visual = FB_VISUAL_TRUECOLOR;
 		break;
@@ -373,17 +393,18 @@ static int lynxfb_ops_set_par(struct fb_info * info)
 	var->height = var->width = -1;
 	var->accel_flags = 0;/*FB_ACCELF_TEXT;*/
 
-	if(ret){
+	if (ret) {
 		pr_err("pixel bpp format not satisfied\n.");
 		return ret;
 	}
-	ret = crtc->proc_setMode(crtc,var,fix);
-	if(!ret)
-		ret = output->proc_setMode(output,var,fix);
+	ret = crtc->proc_setMode(crtc, var, fix);
+	if (!ret)
+		ret = output->proc_setMode(output, var, fix);
 	return ret;
 }
 
-static inline unsigned int chan_to_field(unsigned int chan,struct fb_bitfield * bf)
+static inline unsigned int chan_to_field(unsigned int chan,
+			struct fb_bitfield *bf)
 {
 	chan &= 0xffff;
 	chan >>= 16 - bf->length;
@@ -443,63 +464,65 @@ static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg)
 	return ret;
 }
 
-static int lynxfb_resume(struct pci_dev* pdev)
+static int lynxfb_resume(struct pci_dev *pdev)
 {
-	struct fb_info * info;
-	struct lynx_share * share;
+	struct fb_info *info;
+	struct lynx_share *share;
 
-	struct lynxfb_par * par;
-	struct lynxfb_crtc * crtc;
-	struct lynx_cursor * cursor;
+	struct lynxfb_par *par;
+	struct lynxfb_crtc *crtc;
+	struct lynx_cursor *cursor;
 
 	int ret;
-	
+
 
 	ret = 0;
 	share = pci_get_drvdata(pdev);
 
 	console_lock();
 
-	if((ret = pci_set_power_state(pdev, PCI_D0)) != 0){
-		pr_err("error:%d occured in pci_set_power_state\n",ret);
+	ret = pci_set_power_state(pdev, PCI_D0);
+	if (ret) {
+		pr_err("error:%d occured in pci_set_power_state\n", ret);
 		return ret;
 	}
 
 
-	if(pdev->dev.power.power_state.event != PM_EVENT_FREEZE){
+	if (pdev->dev.power.power_state.event != PM_EVENT_FREEZE) {
 		pci_restore_state(pdev);
-		if ((ret = pci_enable_device(pdev)) != 0){
-			pr_err("error:%d occured in pci_enable_device\n",ret);
+		ret = pci_enable_device(pdev);
+		if (ret) {
+			pr_err("error:%d occured in pci_enable_device\n", ret);
 			return ret;
 		}
 		pci_set_master(pdev);
 	}
-	if(share->resume)
+	if (share->resume)
 		(*share->resume)(share);
 
-	hw_sm750_inithw(share,pdev);
+	hw_sm750_inithw(share, pdev);
 
 
 	info = share->fbinfo[0];
 
-	if(info){
+	if (info) {
 		par = info->par;
 		crtc = &par->crtc;
 		cursor = &crtc->cursor;
 		memset(cursor->vstart, 0x0, cursor->size);
-		memset(crtc->vScreen,0x0,crtc->vidmem_size);
+		memset(crtc->vScreen, 0x0, crtc->vidmem_size);
 		lynxfb_ops_set_par(info);
 		fb_set_suspend(info, 0);
 	}
 
 	info = share->fbinfo[1];
 
-	if(info){
+	if (info) {
 		par = info->par;
 		crtc = &par->crtc;
 		cursor = &crtc->cursor;
 		memset(cursor->vstart, 0x0, cursor->size);
-		memset(crtc->vScreen,0x0,crtc->vidmem_size);
+		memset(crtc->vScreen, 0x0, crtc->vidmem_size);
 		lynxfb_ops_set_par(info);
 		fb_set_suspend(info, 0);
 	}
@@ -510,16 +533,16 @@ static int lynxfb_resume(struct pci_dev* pdev)
 }
 #endif
 
-static int lynxfb_ops_check_var(struct fb_var_screeninfo* var,struct fb_info* info)
+static int lynxfb_ops_check_var(struct fb_var_screeninfo *var,
+		struct fb_info *info)
 {
-	struct lynxfb_par * par;
-	struct lynxfb_crtc * crtc;
-	struct lynxfb_output * output;
-	struct lynx_share * share;
+	struct lynxfb_par *par;
+	struct lynxfb_crtc *crtc;
+	struct lynxfb_output *output;
+	struct lynx_share *share;
 	int ret;
 	resource_size_t request;
 
-	
 	par = info->par;
 	crtc = &par->crtc;
 	output = &par->output;
@@ -532,19 +555,19 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo* var,struct fb_info* in
 			var->bits_per_pixel);
 
 
-	switch(var->bits_per_pixel){
+	switch (var->bits_per_pixel) {
 	case 8:
 	case 16:
 	case 24: /* support 24 bpp for only lynx712/722/720 */
 	case 32:
 		break;
 	default:
-		pr_err("bpp %d not supported\n",var->bits_per_pixel);
+		pr_err("bpp %d not supported\n", var->bits_per_pixel);
 		ret = -EINVAL;
 		goto exit;
 	}
 
-	switch(var->bits_per_pixel){
+	switch (var->bits_per_pixel) {
 	case 8:
 		info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
 		var->red.offset = 0;
@@ -573,7 +596,7 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo* var,struct fb_info* in
 		var->red.length = 8;
 		var->green.offset = 8;
 		var->green.length = 8;
-		var->blue.offset = 0 ;
+		var->blue.offset = 0;
 		var->blue.length = 8;
 		info->fix.visual = FB_VISUAL_TRUECOLOR;
 		break;
@@ -584,178 +607,183 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo* var,struct fb_info* in
 	var->height = var->width = -1;
 	var->accel_flags = 0;/*FB_ACCELF_TEXT;*/
 
-	/* check if current fb's video memory big enought to hold the onscreen */
+	/*
+	 * check if current fb's video memory big enought to hold the onscreen
+	*/
 	request = var->xres_virtual * (var->bits_per_pixel >> 3);
 	/* defaulty crtc->channel go with par->index */
 
-	request = PADDING(crtc->line_pad,request);
+	request = PADDING(crtc->line_pad, request);
 	request = request * var->yres_virtual;
-	if(crtc->vidmem_size < request){
+	if (crtc->vidmem_size < request) {
 		pr_err("not enough video memory for mode\n");
 		return -ENOMEM;
 	}
 
-	ret = output->proc_checkMode(output,var);
-	if(!ret)
-		ret = crtc->proc_checkMode(crtc,var);
+	ret = output->proc_checkMode(output, var);
+	if (!ret)
+		ret = crtc->proc_checkMode(crtc, var);
 exit:
 	return ret;
 }
 
 
-static int lynxfb_ops_setcolreg(unsigned regno,unsigned red,
-									unsigned green,unsigned blue,
-									unsigned transp,struct fb_info * info)
+static int lynxfb_ops_setcolreg(unsigned regno,
+		unsigned red,
+		unsigned green,
+		unsigned blue,
+		unsigned transp,
+		struct fb_info *info)
 {
-    struct lynxfb_par * par;
-    struct lynxfb_crtc * crtc;
-    struct fb_var_screeninfo * var;
-    int ret;
-
-    par = info->par;
-    crtc = &par->crtc;
-    var = &info->var;
-    ret = 0;
-
-    //pr_debug("regno=%d,red=%d,green=%d,blue=%d\n",regno,red,green,blue);
-    if(regno > 256){
-        pr_err("regno = %d\n",regno);
-        return -EINVAL;
-    }
-
-    if(info->var.grayscale)
-        red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
-
-    if(var->bits_per_pixel = 8 && info->fix.visual = FB_VISUAL_PSEUDOCOLOR)
-    {
-        red >>= 8;
-        green >>= 8;
-        blue >>= 8;
-        ret = crtc->proc_setColReg(crtc,regno,red,green,blue);
-        goto exit;
-    }
-
-
-    if(info->fix.visual = FB_VISUAL_TRUECOLOR && regno < 256 )
-    {
-        u32 val;
-        if(var->bits_per_pixel = 16 ||
-                var->bits_per_pixel = 32 ||
-                var->bits_per_pixel = 24)
-        {
-            val = chan_to_field(red,&var->red);
-            val |= chan_to_field(green,&var->green);
-            val |= chan_to_field(blue,&var->blue);
-            par->pseudo_palette[regno] = val;
-            goto exit;
-        }
-    }
-
-    ret = -EINVAL;
+	struct lynxfb_par *par;
+	struct lynxfb_crtc *crtc;
+	struct fb_var_screeninfo *var;
+	int ret;
+
+	par = info->par;
+	crtc = &par->crtc;
+	var = &info->var;
+	ret = 0;
+
+	/*
+	 * pr_debug("regno=%d,red=%d,green=%d,blue=%d\n",regno,red,green,blue);
+	 */
+	if (regno > 256) {
+		pr_err("regno = %d\n", regno);
+		return -EINVAL;
+	}
+
+	if (info->var.grayscale)
+		red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
+
+	if (var->bits_per_pixel = 8 &&
+			info->fix.visual = FB_VISUAL_PSEUDOCOLOR) {
+		red >>= 8;
+		green >>= 8;
+		blue >>= 8;
+		ret = crtc->proc_setColReg(crtc, regno, red, green, blue);
+		goto exit;
+	}
+
+
+	if (info->fix.visual = FB_VISUAL_TRUECOLOR && regno < 256) {
+		u32 val;
+
+		if (var->bits_per_pixel = 16 ||
+				var->bits_per_pixel = 32 ||
+				var->bits_per_pixel = 24) {
+			val = chan_to_field(red, &var->red);
+			val |= chan_to_field(green, &var->green);
+			val |= chan_to_field(blue, &var->blue);
+			par->pseudo_palette[regno] = val;
+			goto exit;
+		}
+	}
+
+	ret = -EINVAL;
 
 exit:
-    return ret;
+	return ret;
 }
 
-static int lynxfb_ops_blank(int blank,struct fb_info* info)
+static int lynxfb_ops_blank(int blank, struct fb_info *info)
 {
-	struct lynxfb_par * par;
-	struct lynxfb_output * output;
-	
-	pr_debug("blank = %d.\n",blank);
+	struct lynxfb_par *par;
+	struct lynxfb_output *output;
+
+	pr_debug("blank = %d.\n", blank);
 	par = info->par;
 	output = &par->output;
-	return output->proc_setBLANK(output,blank);
+	return output->proc_setBLANK(output, blank);
 }
 
-static int sm750fb_set_drv(struct lynxfb_par * par)
+static int sm750fb_set_drv(struct lynxfb_par *par)
 {
-    int ret;
-    struct lynx_share * share;
-    struct sm750_share * spec_share;
-    struct lynxfb_output * output;
-    struct lynxfb_crtc * crtc;
-    
-    ret = 0;
-
-    share = par->share;
-    spec_share = container_of(share,struct sm750_share,share);
-    output = &par->output;
-    crtc = &par->crtc;
-
-    crtc->vidmem_size = (share->dual)?share->vidmem_size>>1:share->vidmem_size;
-    /* setup crtc and output member */
-    spec_share->hwCursor = g_hwcursor;
-
-    crtc->proc_setMode = hw_sm750_crtc_setMode;
-    crtc->proc_checkMode = hw_sm750_crtc_checkMode;
-    crtc->proc_setColReg = hw_sm750_setColReg;
-    crtc->proc_panDisplay = hw_sm750_pan_display;
-    crtc->clear = hw_sm750_crtc_clear;
-    crtc->line_pad = 16;
-    //crtc->xpanstep = crtc->ypanstep = crtc->ywrapstep = 0;
-    crtc->xpanstep = 8;
-    crtc->ypanstep = 1;
-    crtc->ywrapstep = 0;
-
-    output->proc_setMode = hw_sm750_output_setMode;
-    output->proc_checkMode = hw_sm750_output_checkMode;
-
-    output->proc_setBLANK = (share->revid = SM750LE_REVISION_ID)?hw_sm750le_setBLANK:hw_sm750_setBLANK;
-    output->clear = hw_sm750_output_clear;
-    /* chip specific phase */
-    share->accel.de_wait = (share->revid = SM750LE_REVISION_ID)?hw_sm750le_deWait: hw_sm750_deWait;
-    switch (spec_share->state.dataflow)
-    {
-        case sm750_simul_pri:
-            output->paths = sm750_pnc;
-            crtc->channel = sm750_primary;
-            crtc->oScreen = 0;
-            crtc->vScreen = share->pvMem;
-            pr_info("use simul primary mode\n");
-            break;
-        case sm750_simul_sec:
-            output->paths = sm750_pnc;
-            crtc->channel = sm750_secondary;
-            crtc->oScreen = 0;
-            crtc->vScreen = share->pvMem;
-            break;
-        case sm750_dual_normal:
-            if(par->index = 0){
-                output->paths = sm750_panel;
-                crtc->channel = sm750_primary;
-                crtc->oScreen = 0;
-                crtc->vScreen = share->pvMem;
-            }else{
-                output->paths = sm750_crt;
-                crtc->channel = sm750_secondary;
-                /* not consider of padding stuffs for oScreen,need fix*/
-                crtc->oScreen = (share->vidmem_size >> 1);
-                crtc->vScreen = share->pvMem + crtc->oScreen;
-            }
-            break;
-        case sm750_dual_swap:
-            if(par->index = 0){
-                output->paths = sm750_panel;
-                crtc->channel = sm750_secondary;
-                crtc->oScreen = 0;
-                crtc->vScreen = share->pvMem;
-            }else{
-                output->paths = sm750_crt;
-                crtc->channel = sm750_primary;
-                /* not consider of padding stuffs for oScreen,need fix*/
-                crtc->oScreen = (share->vidmem_size >> 1);
-                crtc->vScreen = share->pvMem + crtc->oScreen;
-            }
-            break;
-        default:
-            ret = -EINVAL;
-    }
-
-    return ret;
+	int ret;
+	struct lynx_share *share;
+	struct sm750_share *spec_share;
+	struct lynxfb_output *output;
+	struct lynxfb_crtc *crtc;
+
+	ret = 0;
+
+	share = par->share;
+	spec_share = container_of(share, struct sm750_share, share);
+	output = &par->output;
+	crtc = &par->crtc;
+
+	crtc->vidmem_size = (share->dual)?share->vidmem_size>>1:share->vidmem_size;
+	/* setup crtc and output member */
+	spec_share->hwCursor = g_hwcursor;
+
+	crtc->proc_setMode = hw_sm750_crtc_setMode;
+	crtc->proc_checkMode = hw_sm750_crtc_checkMode;
+	crtc->proc_setColReg = hw_sm750_setColReg;
+	crtc->proc_panDisplay = hw_sm750_pan_display;
+	crtc->clear = hw_sm750_crtc_clear;
+	crtc->line_pad = 16;
+	/*crtc->xpanstep = crtc->ypanstep = crtc->ywrapstep = 0;*/
+	crtc->xpanstep = 8;
+	crtc->ypanstep = 1;
+	crtc->ywrapstep = 0;
+
+	output->proc_setMode = hw_sm750_output_setMode;
+	output->proc_checkMode = hw_sm750_output_checkMode;
+
+	output->proc_setBLANK = (share->revid = SM750LE_REVISION_ID)?hw_sm750le_setBLANK : hw_sm750_setBLANK;
+	output->clear = hw_sm750_output_clear;
+	/* chip specific phase */
+	share->accel.de_wait = (share->revid = SM750LE_REVISION_ID)?hw_sm750le_deWait : hw_sm750_deWait;
+	switch (spec_share->state.dataflow) {
+	case sm750_simul_pri:
+		output->paths = sm750_pnc;
+		crtc->channel = sm750_primary;
+		crtc->oScreen = 0;
+		crtc->vScreen = share->pvMem;
+		pr_info("use simul primary mode\n");
+		break;
+	case sm750_simul_sec:
+		output->paths = sm750_pnc;
+		crtc->channel = sm750_secondary;
+		crtc->oScreen = 0;
+		crtc->vScreen = share->pvMem;
+		break;
+	case sm750_dual_normal:
+		if (par->index = 0) {
+			output->paths = sm750_panel;
+			crtc->channel = sm750_primary;
+			crtc->oScreen = 0;
+			crtc->vScreen = share->pvMem;
+		} else {
+			output->paths = sm750_crt;
+			crtc->channel = sm750_secondary;
+			/* not consider of padding stuffs for oScreen,need fix*/
+			crtc->oScreen = (share->vidmem_size >> 1);
+			crtc->vScreen = share->pvMem + crtc->oScreen;
+		}
+		break;
+	case sm750_dual_swap:
+		if (par->index = 0) {
+			output->paths = sm750_panel;
+			crtc->channel = sm750_secondary;
+			crtc->oScreen = 0;
+			crtc->vScreen = share->pvMem;
+		} else {
+			output->paths = sm750_crt;
+			crtc->channel = sm750_primary;
+			/* not consider of padding stuffs for oScreen,need fix*/
+			crtc->oScreen = (share->vidmem_size >> 1);
+			crtc->vScreen = share->pvMem + crtc->oScreen;
+		}
+		break;
+	default:
+		ret = -EINVAL;
+	}
+
+	return ret;
 }
 
-static struct fb_ops lynxfb_ops={
+static struct fb_ops lynxfb_ops = {
 	.owner = THIS_MODULE,
 	.fb_check_var =  lynxfb_ops_check_var,
 	.fb_set_par = lynxfb_ops_set_par,
@@ -769,338 +797,353 @@ static struct fb_ops lynxfb_ops={
 };
 
 
-static int lynxfb_set_fbinfo(struct fb_info* info,int index)
+static int lynxfb_set_fbinfo(struct fb_info *info, int index)
 {
-    int i;
-    struct lynxfb_par * par;
-    struct lynx_share * share;
-    struct lynxfb_crtc * crtc;
-    struct lynxfb_output * output;
-    struct fb_var_screeninfo * var;
-    struct fb_fix_screeninfo * fix;
-
-    const struct fb_videomode * pdb[] = {
-        lynx750_ext, NULL,vesa_modes,
-    };
-    int cdb[] = {ARRAY_SIZE(lynx750_ext),0,VESA_MODEDB_SIZE};
-    static const char * mdb_desc[] ={
-        "driver prepared modes",
-        "kernel prepared default modedb",
-        "kernel HELPERS prepared vesa_modes",
-    };
-
-
-    static const char * fixId[2]-    {
-        "sm750_fb1","sm750_fb2",
-    };
-
-    int ret,line_length;
-    
-    ret = 0;
-    par = (struct lynxfb_par *)info->par;
-    share = par->share;
-    crtc = &par->crtc;
-    output = &par->output;
-    var = &info->var;
-    fix = &info->fix;
-
-    /* set index */
-    par->index = index;
-    output->channel = &crtc->channel;
-	sm750fb_set_drv(par);
-        lynxfb_ops.fb_pan_display = lynxfb_ops_pan_display;
+	int i;
+	struct lynxfb_par *par;
+	struct lynx_share *share;
+	struct lynxfb_crtc *crtc;
+	struct lynxfb_output *output;
+	struct fb_var_screeninfo *var;
+	struct fb_fix_screeninfo *fix;
 
+	const struct fb_videomode *pdb[] = {
+		lynx750_ext, NULL, vesa_modes,
+	};
+	int cdb[] = {ARRAY_SIZE(lynx750_ext), 0, VESA_MODEDB_SIZE};
+	static const char *mdb_desc[] = {
+		"driver prepared modes",
+		"kernel prepared default modedb",
+		"kernel HELPERS prepared vesa_modes",
+	};
 
-    /* set current cursor variable and proc pointer,
-     * must be set after crtc member initialized */
-       crtc->cursor.offset = crtc->oScreen + crtc->vidmem_size - 1024;
-        crtc->cursor.mmio = share->pvReg + 0x800f0 + (int)crtc->channel * 0x140;
 
-        pr_info("crtc->cursor.mmio = %p\n",crtc->cursor.mmio);
-        crtc->cursor.maxH = crtc->cursor.maxW = 64;
-        crtc->cursor.size = crtc->cursor.maxH*crtc->cursor.maxW*2/8;
-        crtc->cursor.disable = hw_cursor_disable;
-        crtc->cursor.enable = hw_cursor_enable;
-        crtc->cursor.setColor = hw_cursor_setColor;
-        crtc->cursor.setPos = hw_cursor_setPos;
-        crtc->cursor.setSize = hw_cursor_setSize;
-        crtc->cursor.setData = hw_cursor_setData;
-        crtc->cursor.vstart = share->pvMem + crtc->cursor.offset;
+	static const char *fixId[2] = {
+		"sm750_fb1", "sm750_fb2",
+	};
 
+	int ret, line_length;
 
-    crtc->cursor.share = share;
-    memset(crtc->cursor.vstart, 0, crtc->cursor.size);
-    if(!g_hwcursor){
-        lynxfb_ops.fb_cursor = NULL;
-        crtc->cursor.disable(&crtc->cursor);
-    }
+	ret = 0;
+	par = (struct lynxfb_par *)info->par;
+	share = par->share;
+	crtc = &par->crtc;
+	output = &par->output;
+	var = &info->var;
+	fix = &info->fix;
 
+	/* set index */
+	par->index = index;
+	output->channel = &crtc->channel;
+	sm750fb_set_drv(par);
+	lynxfb_ops.fb_pan_display = lynxfb_ops_pan_display;
+
+
+	/* set current cursor variable and proc pointer,
+	* must be set after crtc member initialized */
+	crtc->cursor.offset = crtc->oScreen + crtc->vidmem_size - 1024;
+	crtc->cursor.mmio = share->pvReg + 0x800f0 + (int)crtc->channel * 0x140;
+
+	pr_info("crtc->cursor.mmio = %p\n", crtc->cursor.mmio);
+	crtc->cursor.maxH = crtc->cursor.maxW = 64;
+	crtc->cursor.size = crtc->cursor.maxH*crtc->cursor.maxW*2/8;
+	crtc->cursor.disable = hw_cursor_disable;
+	crtc->cursor.enable = hw_cursor_enable;
+	crtc->cursor.setColor = hw_cursor_setColor;
+	crtc->cursor.setPos = hw_cursor_setPos;
+	crtc->cursor.setSize = hw_cursor_setSize;
+	crtc->cursor.setData = hw_cursor_setData;
+	crtc->cursor.vstart = share->pvMem + crtc->cursor.offset;
+
+
+	crtc->cursor.share = share;
+	memset(crtc->cursor.vstart, 0, crtc->cursor.size);
+	if (!g_hwcursor) {
+		lynxfb_ops.fb_cursor = NULL;
+		crtc->cursor.disable(&crtc->cursor);
+	}
 
-    /* set info->fbops, must be set before fb_find_mode */
-    if(!share->accel_off){
-        /* use 2d acceleration */
-        lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect;
-        lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea;
-        lynxfb_ops.fb_imageblit = lynxfb_ops_imageblit;
-    }
-    info->fbops = &lynxfb_ops;
 
-    if(!g_fbmode[index]){
-        g_fbmode[index] = g_def_fbmode;
-        if(index)
-            g_fbmode[index] = g_fbmode[0];
-    }
+	/* set info->fbops, must be set before fb_find_mode */
+	if (!share->accel_off) {
+		/* use 2d acceleration */
+		lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect;
+		lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea;
+		lynxfb_ops.fb_imageblit = lynxfb_ops_imageblit;
+	}
+	info->fbops = &lynxfb_ops;
 
+	if (!g_fbmode[index]) {
+		g_fbmode[index] = g_def_fbmode;
+		if (index)
+			g_fbmode[index] = g_fbmode[0];
+	}
 
-	for(i=0;i<3;i++){
 
-		ret = fb_find_mode(var,info,g_fbmode[index],
-				pdb[i],cdb[i],NULL,8);
+	for (i = 0; i < 3; i++) {
 
-		if(ret = 1){
+		ret = fb_find_mode(
+				var,
+				info,
+				g_fbmode[index],
+				pdb[i],
+				cdb[i],
+				NULL,
+				8);
+
+		if (ret = 1) {
 			pr_info("success! use specified mode:%s in %s\n",
 					g_fbmode[index],
 					mdb_desc[i]);
 			break;
-		}else if(ret = 2){
+		} else if (ret = 2) {
 			pr_warn("use specified mode:%s in %s,with an ignored refresh rate\n",
 					g_fbmode[index],
 					mdb_desc[i]);
 			break;
-		}else if(ret = 3){
+		} else if (ret = 3) {
 			pr_warn("wanna use default mode\n");
-//			break;
-		}else if(ret = 4){
+/*			break;*/
+		} else if (ret = 4) {
 			pr_warn("fall back to any valid mode\n");
-		}else{
-			pr_warn("ret = %d,fb_find_mode failed,with %s\n",ret,mdb_desc[i]);
+		} else {
+			pr_warn("ret = %d,fb_find_mode failed,with %s\n",
+					ret,
+					mdb_desc[i]);
 		}
 	}
 
-    /* some member of info->var had been set by fb_find_mode */
-
-    pr_info("Member of info->var is :\n\
-            xres=%d\n\
-            yres=%d\n\
-            xres_virtual=%d\n\
-            yres_virtual=%d\n\
-            xoffset=%d\n\
-            yoffset=%d\n\
-            bits_per_pixel=%d\n \
-            ...\n",var->xres,var->yres,var->xres_virtual,var->yres_virtual,
-            var->xoffset,var->yoffset,var->bits_per_pixel);
-
-    /* set par */
-    par->info = info;
-
-    /* set info */
-    line_length = PADDING(crtc->line_pad,
-            (var->xres_virtual * var->bits_per_pixel/8));
-
-    info->pseudo_palette = &par->pseudo_palette[0];
-    info->screen_base = crtc->vScreen;
-    pr_debug("screen_base vaddr = %p\n",info->screen_base);
+	/* some member of info->var had been set by fb_find_mode */
+
+	pr_info("Member of info->var is :\n\
+		xres=%d\n\
+		yres=%d\n\
+		xres_virtual=%d\n\
+		yres_virtual=%d\n\
+		xoffset=%d\n\
+		yoffset=%d\n\
+		bits_per_pixel=%d\n \
+		...\n",
+		var->xres,
+		var->yres,
+		var->xres_virtual,
+		var->yres_virtual,
+		var->xoffset,
+		var->yoffset,
+		var->bits_per_pixel);
+
+	/* set par */
+	par->info = info;
+
+	/* set info */
+	line_length = PADDING(crtc->line_pad,
+			(var->xres_virtual * var->bits_per_pixel / 8));
+
+	info->pseudo_palette = &par->pseudo_palette[0];
+	info->screen_base = crtc->vScreen;
+	pr_debug("screen_base vaddr = %p\n", info->screen_base);
 	info->screen_size = line_length * var->yres_virtual;
 	info->flags = FBINFO_FLAG_DEFAULT|0;
 
-    /* set info->fix */
-    fix->type = FB_TYPE_PACKED_PIXELS;
-    fix->type_aux = 0;
-    fix->xpanstep = crtc->xpanstep;
-    fix->ypanstep = crtc->ypanstep;
-    fix->ywrapstep = crtc->ywrapstep;
-    fix->accel = FB_ACCEL_SMI;
+	/* set info->fix */
+	fix->type = FB_TYPE_PACKED_PIXELS;
+	fix->type_aux = 0;
+	fix->xpanstep = crtc->xpanstep;
+	fix->ypanstep = crtc->ypanstep;
+	fix->ywrapstep = crtc->ywrapstep;
+	fix->accel = FB_ACCEL_SMI;
 
-    strlcpy(fix->id,fixId[index],sizeof(fix->id));
+	strlcpy(fix->id, fixId[index], sizeof(fix->id));
 
 
 	fix->smem_start = crtc->oScreen + share->vidmem_start;
-	pr_info("fix->smem_start = %lx\n",fix->smem_start);
-    /* according to mmap experiment from user space application,
-     * fix->mmio_len should not larger than virtual size
-     * (xres_virtual x yres_virtual x ByPP)
-     * Below line maybe buggy when user mmap fb dev node and write
-     * data into the bound over virtual size
-     * */
-    fix->smem_len = crtc->vidmem_size;
-    pr_info("fix->smem_len = %x\n",fix->smem_len);
-    info->screen_size = fix->smem_len;
-    fix->line_length = line_length;
-    fix->mmio_start = share->vidreg_start;
-    pr_info("fix->mmio_start = %lx\n",fix->mmio_start);
-    fix->mmio_len = share->vidreg_size;
-    pr_info("fix->mmio_len = %x\n",fix->mmio_len);
-    switch(var->bits_per_pixel)
-    {
-        case 8:
-            fix->visual = FB_VISUAL_PSEUDOCOLOR;
-            break;
-        case 16:
-        case 32:
-            fix->visual = FB_VISUAL_TRUECOLOR;
-            break;
-    }
-
-    /* set var */
-    var->activate = FB_ACTIVATE_NOW;
-    var->accel_flags = 0;
-    var->vmode = FB_VMODE_NONINTERLACED;
-
-    pr_debug("#1 show info->cmap : \nstart=%d,len=%d,red=%p,green=%p,blue=%p,transp=%p\n",
-            info->cmap.start,info->cmap.len,
-            info->cmap.red,info->cmap.green,info->cmap.blue,
-            info->cmap.transp);
-
-    if((ret = fb_alloc_cmap(&info->cmap,256,0)) < 0){
-        pr_err("Could not allcate memory for cmap.\n");
-        goto exit;
-    }
-
-    pr_debug("#2 show info->cmap : \nstart=%d,len=%d,red=%p,green=%p,blue=%p,transp=%p\n",
-            info->cmap.start,info->cmap.len,
-            info->cmap.red,info->cmap.green,info->cmap.blue,
-            info->cmap.transp);
+	pr_info("fix->smem_start = %lx\n", fix->smem_start);
+	/* according to mmap experiment from user space application,
+	* fix->mmio_len should not larger than virtual size
+	* (xres_virtual x yres_virtual x ByPP)
+	* Below line maybe buggy when user mmap fb dev node and write
+	* data into the bound over virtual size
+	* */
+	fix->smem_len = crtc->vidmem_size;
+	pr_info("fix->smem_len = %x\n", fix->smem_len);
+	info->screen_size = fix->smem_len;
+	fix->line_length = line_length;
+	fix->mmio_start = share->vidreg_start;
+	pr_info("fix->mmio_start = %lx\n", fix->mmio_start);
+	fix->mmio_len = share->vidreg_size;
+	pr_info("fix->mmio_len = %x\n", fix->mmio_len);
+	switch (var->bits_per_pixel) {
+	case 8:
+		fix->visual = FB_VISUAL_PSEUDOCOLOR;
+		break;
+	case 16:
+	case 32:
+		fix->visual = FB_VISUAL_TRUECOLOR;
+		break;
+	}
+
+	/* set var */
+	var->activate = FB_ACTIVATE_NOW;
+	var->accel_flags = 0;
+	var->vmode = FB_VMODE_NONINTERLACED;
+
+	pr_debug("#1 show info->cmap :\nstart=%d,len=%d,red=%p,green=%p,blue=%p,transp=%p\n",
+		info->cmap.start,
+		info->cmap.len,
+		info->cmap.red,
+		info->cmap.green,
+		info->cmap.blue,
+		info->cmap.transp);
+	ret = fb_alloc_cmap(&info->cmap, 256, 0);
+	if (ret < 0) {
+		pr_err("Could not allcate memory for cmap.\n");
+		goto exit;
+	}
+
+	pr_debug("#2 show info->cmap :\nstart=%d,len=%d,red=%p,green=%p,blue=%p,transp=%p\n",
+		info->cmap.start,
+		info->cmap.len,
+		info->cmap.red,
+		info->cmap.green,
+		info->cmap.blue,
+		info->cmap.transp);
 
 exit:
-	lynxfb_ops_check_var(var,info);
-//    lynxfb_ops_set_par(info);
-    return ret;
+	lynxfb_ops_check_var(var, info);
+/*	lynxfb_ops_set_par(info);*/
+	return ret;
 }
 
-/* 	chip specific g_option configuration routine */
-static void sm750fb_setup(struct lynx_share * share,char * src)
+/*	chip specific g_option configuration routine */
+static void sm750fb_setup(struct lynx_share *share, char *src)
 {
-	struct sm750_share * spec_share;
-	char * opt;
+	struct sm750_share *spec_share;
+	char *opt;
 #ifdef CAP_EXPENSION
-	char * exp_res;
+	char *exp_res;
 #endif
 	int swap;
-	
 
-	spec_share = container_of(share,struct sm750_share,share);
+
+	spec_share = container_of(share, struct sm750_share, share);
 #ifdef CAP_EXPENSIION
-        exp_res = NULL;
+	exp_res = NULL;
 #endif
-        swap = 0;
-
-        spec_share->state.initParm.chip_clk = 0;
-        spec_share->state.initParm.mem_clk = 0;
-        spec_share->state.initParm.master_clk = 0;
-        spec_share->state.initParm.powerMode = 0;
-        spec_share->state.initParm.setAllEngOff = 0;
-        spec_share->state.initParm.resetMemory = 1;
-
-        /*defaultly turn g_hwcursor on for both view */
-        g_hwcursor = 3;
-
-        if(!src || !*src){
-            pr_warn("no specific g_option.\n");
-            goto NO_PARAM;
-        }
-
-        while((opt = strsep(&src,":")) != NULL && *opt != 0){
-			pr_err("opt=%s\n",opt);
-			pr_err("src=%s\n",src);
-
-            if(!strncmp(opt,"swap",strlen("swap")))
-                swap = 1;
-            else if(!strncmp(opt,"nocrt",strlen("nocrt")))
-                spec_share->state.nocrt = 1;
-            else if(!strncmp(opt,"36bit",strlen("36bit")))
-                spec_share->state.pnltype = sm750_doubleTFT;
-            else if(!strncmp(opt,"18bit",strlen("18bit")))
-                spec_share->state.pnltype = sm750_dualTFT;
-            else if(!strncmp(opt,"24bit",strlen("24bit")))
-                spec_share->state.pnltype = sm750_24TFT;
+	swap = 0;
+
+	spec_share->state.initParm.chip_clk = 0;
+	spec_share->state.initParm.mem_clk = 0;
+	spec_share->state.initParm.master_clk = 0;
+	spec_share->state.initParm.powerMode = 0;
+	spec_share->state.initParm.setAllEngOff = 0;
+	spec_share->state.initParm.resetMemory = 1;
+
+	/*defaultly turn g_hwcursor on for both view */
+	g_hwcursor = 3;
+
+	if (!src || !*src) {
+		pr_warn("no specific g_option.\n");
+		goto NO_PARAM;
+	}
+
+	while ((opt = strsep(&src, ":")) != NULL && *opt != 0) {
+		pr_err("opt=%s\n", opt);
+		pr_err("src=%s\n", src);
+
+		if (!strncmp(opt, "swap", strlen("swap")))
+			swap = 1;
+		else if (!strncmp(opt, "nocrt", strlen("nocrt")))
+			spec_share->state.nocrt = 1;
+		else if (!strncmp(opt, "36bit", strlen("36bit")))
+			spec_share->state.pnltype = sm750_doubleTFT;
+		else if (!strncmp(opt, "18bit", strlen("18bit")))
+			spec_share->state.pnltype = sm750_dualTFT;
+		else if (!strncmp(opt, "24bit", strlen("24bit")))
+			spec_share->state.pnltype = sm750_24TFT;
 #ifdef CAP_EXPANSION
-            else if(!strncmp(opt,"exp:",strlen("exp:")))
-                exp_res = opt + strlen("exp:");
+		else if (!strncmp(opt, "exp:", strlen("exp:")))
+			exp_res = opt + strlen("exp:");
 #endif
-            else if(!strncmp(opt,"nohwc0",strlen("nohwc0")))
-                g_hwcursor &= ~0x1;
-            else if(!strncmp(opt,"nohwc1",strlen("nohwc1")))
-                g_hwcursor &= ~0x2;
-            else if(!strncmp(opt,"nohwc",strlen("nohwc")))
-                g_hwcursor = 0;
-            else
-            {
-                if(!g_fbmode[0]){
-                    g_fbmode[0] = opt;
-                    pr_info("find fbmode0 : %s\n",g_fbmode[0]);
-                }else if(!g_fbmode[1]){
-                    g_fbmode[1] = opt;
-                    pr_info("find fbmode1 : %s\n",g_fbmode[1]);
-                }else{
-                    pr_warn("How many view you wann set?\n");
-                }
-            }
-        }
+		else if (!strncmp(opt, "nohwc0", strlen("nohwc0")))
+			g_hwcursor &= ~0x1;
+		else if (!strncmp(opt, "nohwc1", strlen("nohwc1")))
+			g_hwcursor &= ~0x2;
+		else if (!strncmp(opt, "nohwc", strlen("nohwc")))
+			g_hwcursor = 0;
+		else {
+			if (!g_fbmode[0]) {
+				g_fbmode[0] = opt;
+				pr_info("find fbmode0 : %s\n", g_fbmode[0]);
+			} else if (!g_fbmode[1]) {
+				g_fbmode[1] = opt;
+				pr_info("find fbmode1 : %s\n", g_fbmode[1]);
+			} else {
+				pr_warn("How many view you wann set?\n");
+			}
+		}
+	}
 #ifdef CAP_EXPANSION
-        if(getExpRes(exp_res,&spec_share->state.xLCD,&spec_share->state.yLCD))
-        {
-            /* seems exp_res is not valid*/
-            spec_share->state.xLCD = spec_share->state.yLCD = 0;
-        }
+	if (getExpRes(exp_res, &spec_share->state.xLCD, &spec_share->state.yLCD)) {
+		/* seems exp_res is not valid*/
+		spec_share->state.xLCD = spec_share->state.yLCD = 0;
+	}
 #endif
 
 NO_PARAM:
-        if(share->revid != SM750LE_REVISION_ID){
-            if(share->dual)
-            {
-                if(swap)
-                    spec_share->state.dataflow = sm750_dual_swap;
-                else
-                    spec_share->state.dataflow = sm750_dual_normal;
-            }else{
-                if(swap)
-                    spec_share->state.dataflow = sm750_simul_sec;
-                else
-                    spec_share->state.dataflow = sm750_simul_pri;
-            }
-        }else{
-            /* SM750LE only have one crt channel */
-            spec_share->state.dataflow = sm750_simul_sec;
-            /* sm750le do not have complex attributes*/
-            spec_share->state.nocrt = 0;
-        }
+	if (share->revid != SM750LE_REVISION_ID) {
+		if (share->dual) {
+			if (swap)
+				spec_share->state.dataflow = sm750_dual_swap;
+			else
+				spec_share->state.dataflow = sm750_dual_normal;
+		} else {
+			if (swap)
+				spec_share->state.dataflow = sm750_simul_sec;
+			else
+				spec_share->state.dataflow = sm750_simul_pri;
+		}
+	} else {
+		/* SM750LE only have one crt channel */
+		spec_share->state.dataflow = sm750_simul_sec;
+		/* sm750le do not have complex attributes*/
+		spec_share->state.nocrt = 0;
+	}
 }
 
-static int lynxfb_pci_probe(struct pci_dev * pdev,
-		const struct pci_device_id * ent)
+static int lynxfb_pci_probe(struct pci_dev *pdev,
+		const struct pci_device_id *ent)
 {
-	struct fb_info * info[] = {NULL,NULL};
-	struct lynx_share * share = NULL;
+	struct fb_info *info[] = {NULL, NULL};
+	struct lynx_share *share = NULL;
 
 	struct sm750_share *spec_share = NULL;
 	size_t spec_offset = 0;
 	int fbidx;
-	
+
 
 	/* enable device */
-	if(pci_enable_device(pdev)){
+	if (pci_enable_device(pdev)) {
 		pr_err("can not enable device.\n");
 		goto err_enable;
 	}
 
 	/* though offset of share in sm750_share is 0,
 	 * we use this marcro as the same */
-	spec_offset = offsetof(struct sm750_share,share);
+	spec_offset = offsetof(struct sm750_share, share);
 
-	spec_share = kzalloc(sizeof(*spec_share),GFP_KERNEL);
-	if(!spec_share){
+	spec_share = kzalloc(sizeof(*spec_share), GFP_KERNEL);
+	if (!spec_share) {
 		pr_err("Could not allocate memory for share.\n");
 		goto err_share;
 	}
 
 	/* setting share structure */
-	share = (struct lynx_share * )(&(spec_share->share));
+	share = (struct lynx_share *)(&(spec_share->share));
 	share->fbinfo[0] = share->fbinfo[1] = NULL;
 	share->devid = pdev->device;
 	share->revid = pdev->revision;
 
-	pr_info("share->revid = %02x\n",share->revid);
+	pr_info("share->revid = %02x\n", share->revid);
 	share->pdev = pdev;
 #ifdef CONFIG_MTRR
 	share->mtrr_off = g_nomtrr;
@@ -1111,7 +1154,7 @@ static int lynxfb_pci_probe(struct pci_dev * pdev,
 	share->dual = g_dualview;
 	spin_lock_init(&share->slock);
 
-	if(!share->accel_off){
+	if (!share->accel_off) {
 		/* hook deInit and 2d routines, notes that below hw_xxx
 		 * routine can work on most of lynx chips
 		 * if some chip need specific function,please hook it in smXXX_set_drv
@@ -1121,91 +1164,90 @@ static int lynxfb_pci_probe(struct pci_dev * pdev,
 		share->accel.de_copyarea = hw_copyarea;
 		share->accel.de_imageblit = hw_imageblit;
 		pr_info("enable 2d acceleration\n");
-	}else{
+	} else {
 		pr_info("disable 2d acceleration\n");
 	}
 
 	/* call chip specific setup routine  */
-	sm750fb_setup(share,g_settings);
+	sm750fb_setup(share, g_settings);
 
 	/* call chip specific mmap routine */
-	if(hw_sm750_map(share,pdev)){
+	if (hw_sm750_map(share, pdev)) {
 		pr_err("Memory map failed\n");
 		goto err_map;
 	}
 
 #ifdef CONFIG_MTRR
-	if(!share->mtrr_off){
+	if (!share->mtrr_off) {
 		pr_info("enable mtrr\n");
 		share->mtrr.vram = mtrr_add(share->vidmem_start,
 				share->vidmem_size,
-				MTRR_TYPE_WRCOMB,1);
+				MTRR_TYPE_WRCOMB,
+				1);
 
-		if(share->mtrr.vram < 0){
+		if (share->mtrr.vram < 0) {
 			/* don't block driver with the failure of MTRR */
 			pr_err("Unable to setup MTRR.\n");
-		}else{
+		} else {
 			share->mtrr.vram_added = 1;
 			pr_info("MTRR added succesfully\n");
 		}
 	}
 #endif
 
-	memset(share->pvMem,0,share->vidmem_size);
+	memset(share->pvMem, 0, share->vidmem_size);
 
-	pr_info("sm%3x mmio address = %p\n",share->devid,share->pvReg);
+	pr_info("sm%3x mmio address = %p\n", share->devid, share->pvReg);
 
-	pci_set_drvdata(pdev,share);
+	pci_set_drvdata(pdev, share);
 
 	/* call chipInit routine */
-	hw_sm750_inithw(share,pdev);
+	hw_sm750_inithw(share, pdev);
 
 	/* allocate frame buffer info structor according to g_dualview */
-		fbidx = 0;
+	fbidx = 0;
 ALLOC_FB:
-		info[fbidx] = framebuffer_alloc(sizeof(struct lynxfb_par),&pdev->dev);
-		if(!info[fbidx])
-		{
-			pr_err("Could not allocate framebuffer #%d.\n",fbidx);
-			if(fbidx = 0)
-				goto err_info0_alloc;
-			else
-				goto err_info1_alloc;
-		}
+	info[fbidx] = framebuffer_alloc(sizeof(struct lynxfb_par), &pdev->dev);
+	if (!info[fbidx]) {
+		pr_err("Could not allocate framebuffer #%d.\n", fbidx);
+		if (fbidx = 0)
+			goto err_info0_alloc;
 		else
-		{
-			struct lynxfb_par * par;
+			goto err_info1_alloc;
+		} else {
+			struct lynxfb_par *par;
 			int errno;
-			pr_info("framebuffer #%d alloc okay\n",fbidx);
+
+			pr_info("framebuffer #%d alloc okay\n", fbidx);
 			share->fbinfo[fbidx] = info[fbidx];
 			par = info[fbidx]->par;
 			par->share = share;
 
 			/* set fb_info structure */
-			if(lynxfb_set_fbinfo(info[fbidx],fbidx)){
-				pr_err("Failed to initial fb_info #%d.\n",fbidx);
-				if(fbidx = 0)
+			if (lynxfb_set_fbinfo(info[fbidx], fbidx)) {
+				pr_err("Failed to initial fb_info #%d.\n", fbidx);
+				if (fbidx = 0)
 					goto err_info0_set;
 				else
 					goto err_info1_set;
 			}
 
 			/* register frame buffer*/
-			pr_info("Ready to register framebuffer #%d.\n",fbidx);
+			pr_info("Ready to register framebuffer #%d.\n", fbidx);
 			errno = register_framebuffer(info[fbidx]);
 			if (errno < 0) {
-				pr_err("Failed to register fb_info #%d. err %d\n",fbidx, errno);
-				if(fbidx = 0)
+				pr_err("Failed to register fb_info #%d. err %d\n", fbidx, errno);
+				if (fbidx = 0)
 					goto err_register0;
 				else
 					goto err_register1;
 			}
-			pr_info("Accomplished register framebuffer #%d.\n",fbidx);
+			pr_info("Accomplished register framebuffer #%d.\n", fbidx);
 		}
 
 		/* no dual view by far */
 		fbidx++;
-		if(share->dual && fbidx < 2)
+		if (share->dual && fbidx < 2)
 			goto ALLOC_FB;
 
 	return 0;
@@ -1226,20 +1268,20 @@ err_enable:
 	return -ENODEV;
 }
 
-static void __exit lynxfb_pci_remove(struct pci_dev * pdev)
+static void __exit lynxfb_pci_remove(struct pci_dev *pdev)
 {
-	struct fb_info * info;
-	struct lynx_share * share;
-	void * spec_share;
-	struct lynxfb_par * par;
+	struct fb_info *info;
+	struct lynx_share *share;
+	void *spec_share;
+	struct lynxfb_par *par;
 	int cnt;
 
 	cnt = 2;
 	share = pci_get_drvdata(pdev);
 
-	while(cnt-- > 0){
+	while (cnt-- > 0) {
 		info = share->fbinfo[cnt];
-		if(!info)
+		if (!info)
 			continue;
 		par = info->par;
 
@@ -1251,40 +1293,42 @@ static void __exit lynxfb_pci_remove(struct pci_dev * pdev)
 		framebuffer_release(info);
 	}
 #ifdef CONFIG_MTRR
-	if(share->mtrr.vram_added)
-		mtrr_del(share->mtrr.vram,share->vidmem_start,share->vidmem_size);
+	if (share->mtrr.vram_added)
+		mtrr_del(share->mtrr.vram,
+				share->vidmem_start,
+				share->vidmem_size);
 #endif
-	//	pci_release_regions(pdev);
+	/*	pci_release_regions(pdev);*/
 
 	iounmap(share->pvReg);
 	iounmap(share->pvMem);
-	spec_share = container_of(share,struct sm750_share,share);
+	spec_share = container_of(share, struct sm750_share, share);
 	kfree(g_settings);
 	kfree(spec_share);
-	pci_set_drvdata(pdev,NULL);
+	pci_set_drvdata(pdev, NULL);
 }
 
-static int __init lynxfb_setup(char * options)
+static int __init lynxfb_setup(char *options)
 {
 	int len;
-	char * opt,*tmp;
-	
+	char *opt, *tmp;
+
 
-	if(!options || !*options){
+	if (!options || !*options) {
 		pr_warn("no options.\n");
 		return 0;
 	}
 
-	pr_info("options:%s\n",options);
+	pr_info("options:%s\n", options);
 
 	len = strlen(options) + 1;
 	g_settings = kzalloc(len, GFP_KERNEL);
-	if(!g_settings)
+	if (!g_settings)
 		return -ENOMEM;
 
 	tmp = g_settings;
 
-	/* 	Notes:
+	/*	Notes:
 		char * strsep(char **s,const char * ct);
 		@s: the string to be searched
 		@ct :the characters to search for
@@ -1292,22 +1336,20 @@ static int __init lynxfb_setup(char * options)
 		strsep() updates @options to pointer after the first found token
 		it also returns the pointer ahead the token.
 		*/
-	while((opt = strsep(&options,":"))!=NULL)
-	{
+	while ((opt = strsep(&options, ":")) != NULL) {
 		/* options that mean for any lynx chips are configured here */
-		if(!strncmp(opt,"noaccel",strlen("noaccel")))
+		if (!strncmp(opt, "noaccel", strlen("noaccel")))
 			g_noaccel = 1;
 #ifdef CONFIG_MTRR
-		else if(!strncmp(opt,"nomtrr",strlen("nomtrr")))
+		else if (!strncmp(opt, "nomtrr", strlen("nomtrr")))
 			g_nomtrr = 1;
 #endif
-		else if(!strncmp(opt,"dual",strlen("dual")))
+		else if (!strncmp(opt, "dual", strlen("dual")))
 			g_dualview = 1;
-		else
-		{
-			strcat(tmp,opt);
+		else {
+			strcat(tmp, opt);
 			tmp += strlen(opt);
-			if(options != NULL)
+			if (options != NULL)
 				*tmp++ = ':';
 			else
 				*tmp++ = 0;
@@ -1315,7 +1357,7 @@ static int __init lynxfb_setup(char * options)
 	}
 
 	/* misc g_settings are transport to chip specific routines */
-	pr_info("parameter left for chip specific analysis:%s\n",g_settings);
+	pr_info("parameter left for chip specific analysis:%s\n", g_settings);
 	return 0;
 }
 
@@ -1324,7 +1366,7 @@ static struct pci_device_id smi_pci_table[] = {
 	{0,}
 };
 
-MODULE_DEVICE_TABLE(pci,smi_pci_table);
+MODULE_DEVICE_TABLE(pci, smi_pci_table);
 
 static struct pci_driver lynxfb_driver = {
 	.name =		"sm750fb",
@@ -1340,13 +1382,13 @@ static struct pci_driver lynxfb_driver = {
 
 static int __init lynxfb_init(void)
 {
-	char *option ;
+	char *option;
 	int ret;
 
 #ifdef MODULE
 	option = g_option;
 #else
-	if(fb_get_options("sm750fb",&option))
+	if (fb_get_options("sm750fb", &option))
 		return -ENODEV;
 #endif
 
@@ -1362,7 +1404,7 @@ static void __exit lynxfb_exit(void)
 }
 module_exit(lynxfb_exit);
 
-module_param(g_option,charp,S_IRUGO);
+module_param(g_option, charp, S_IRUGO);
 
 MODULE_PARM_DESC(g_option,
 		"\n\t\tCommon options:\n"
-- 
2.3.3


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox