Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* Re: [PATCH v4 2/3] v4l: Add V4L2_PIX_FMT_NV24 and V4L2_PIX_FMT_NV42
From: Sylwester Nawrocki @ 2011-11-29 17:19 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-fbdev, linux-media
In-Reply-To: <1322562419-9934-3-git-send-email-laurent.pinchart@ideasonboard.com>

Hi Laurent,

On 11/29/2011 11:26 AM, Laurent Pinchart wrote:
> NV24 and NV42 are planar YCbCr 4:4:4 and YCrCb 4:4:4 formats with a
> luma plane followed by an interleaved chroma plane.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
...
> +	</example>
> +      </refsect1>
> +    </refentry>
> +

> +  <!--
> +Local Variables:
> +mode: sgml
> +sgml-parent-document: "pixfmt.sgml"
> +indent-tabs-mode: nil
> +End:
> +  -->

I think this comment chunk is redundant, it's just for emacs configuration.
Every time I open the file containing litter like this I get a not-so-useful
message, asking if I want to load the variables defined there or not.

I'm considering a patch cleaning up the Docbook from this emacs stuff, as I
also made a mistake copying this comment when adding NV12M, NV12MT formats.

Looks like most of people are doing that, e.g. see

http://www.mail-archive.com/linux-media@vger.kernel.org/msg38637.html

;)

--

Regards,
Sylwester

^ permalink raw reply

* Re: [PATCH v4 2/3] v4l: Add V4L2_PIX_FMT_NV24 and V4L2_PIX_FMT_NV42 formats
From: Laurent Pinchart @ 2011-11-29 18:11 UTC (permalink / raw)
  To: Sylwester Nawrocki; +Cc: linux-fbdev, linux-media
In-Reply-To: <4ED5140D.4080200@samsung.com>

Hi Sylwester,

On Tuesday 29 November 2011 18:19:09 Sylwester Nawrocki wrote:
> On 11/29/2011 11:26 AM, Laurent Pinchart wrote:
> > NV24 and NV42 are planar YCbCr 4:4:4 and YCrCb 4:4:4 formats with a
> > luma plane followed by an interleaved chroma plane.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> 
> ...
> 
> > +	</example>
> > +      </refsect1>
> > +    </refentry>
> > +
> > 
> > +  <!--
> > +Local Variables:
> > +mode: sgml
> > +sgml-parent-document: "pixfmt.sgml"
> > +indent-tabs-mode: nil
> > +End:
> > +  -->
> 
> I think this comment chunk is redundant, it's just for emacs configuration.
> Every time I open the file containing litter like this I get a
> not-so-useful message, asking if I want to load the variables defined
> there or not.

I agree. I'll remove it. Thanks for pointing it out.

> I'm considering a patch cleaning up the Docbook from this emacs stuff, as I
> also made a mistake copying this comment when adding NV12M, NV12MT formats.
> 
> Looks like most of people are doing that, e.g. see
> 
> http://www.mail-archive.com/linux-media@vger.kernel.org/msg38637.html
> 
> ;)

-- 
Regards,

Laurent Pinchart

^ permalink raw reply

* Re: backlight/ld9040.c: regulator control in the lcd driver
From: Linus Walleij @ 2011-12-02  8:49 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <000c01ccb0c6$697c2aa0$3c747fe0$%lee@samsung.com>

On Fri, Dec 2, 2011 at 8:45 AM, leedonghwa <dh09.lee@samsung.com> wrote:

[From your mail headers]
> X-Mailer: Microsoft Office Outlook 12.0

No please. That mailer does not work, all your whitespace is screwed up.
Consult: Documentation/email-clients.txt

> This patch supports regulator power control in the driver.

Always CC the regulator maintainers on patches like this please.

> +         lcd->reg_vdd3 = regulator_get(lcd->dev, "vdd");
> +         if (IS_ERR(lcd->reg_vdd3)) {
> +                   dev_info(lcd->dev, "no %s regulator found\n", "vdd");
> +                   lcd->reg_vdd3 = NULL;
> +         }
> +
> +         lcd->reg_vci = regulator_get(lcd->dev, "vci");
> +         if (IS_ERR(lcd->reg_vci)) {
> +                   dev_info(lcd->dev, "no %s regulator found\n", "vci");
> +                   lcd->reg_vci = NULL;
> +         }

As explained in earlier discussion with Mark regarding the SMSC911x
driver regulator, treat these as errors and do not fail
"gracefully" like this.

Reference:
http://marc.info/?l=linux-netdev&m\x131914562120725&w=2

Yours,
Linus Walleij

^ permalink raw reply

* Re: backlight/ld9040.c: regulator control in the lcd driver
From: Kyungmin Park @ 2011-12-02  8:57 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <CACRpkdbRdtsw-3FXtevuJL7G=tcE+1s11iRw=zou1G25hufBSA@mail.gmail.com>

On 12/2/11, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Fri, Dec 2, 2011 at 8:45 AM, leedonghwa <dh09.lee@samsung.com> wrote:
>
> [From your mail headers]
>> X-Mailer: Microsoft Office Outlook 12.0
>
> No please. That mailer does not work, all your whitespace is screwed up.
> Consult: Documentation/email-clients.txt
>
>> This patch supports regulator power control in the driver.
>
> Always CC the regulator maintainers on patches like this please.
>
>> +         lcd->reg_vdd3 = regulator_get(lcd->dev, "vdd");
>> +         if (IS_ERR(lcd->reg_vdd3)) {
>> +                   dev_info(lcd->dev, "no %s regulator found\n", "vdd");
>> +                   lcd->reg_vdd3 = NULL;
>> +         }
>> +
>> +         lcd->reg_vci = regulator_get(lcd->dev, "vci");
>> +         if (IS_ERR(lcd->reg_vci)) {
>> +                   dev_info(lcd->dev, "no %s regulator found\n", "vci");
>> +                   lcd->reg_vci = NULL;
>> +         }
>
> As explained in earlier discussion with Mark regarding the SMSC911x
> driver regulator, treat these as errors and do not fail
> "gracefully" like this.
>
> Reference:
> http://marc.info/?l=linux-netdev&m\x131914562120725&w=2

As mentioned at commit message, the lcd regulator is optional part and
refer the mmc codes

        host->vmmc = regulator_get(mmc_dev(mmc), "vmmc");
        if (IS_ERR(host->vmmc)) {
                pr_info("%s: no vmmc regulator found\n", mmc_hostname(mmc));
                host->vmmc = NULL;
        } else {
                regulator_enable(host->vmmc);
        }

Previous time, these codes are located at board file, but more boards
are used, it has same codes for all boards. so move it to drivers.

In our case, it has the regulator but some boards don't.

Umm then how to handle the regulator gracefully?

Thank you,
Kyungmin Park

>
> Yours,
> Linus Walleij
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

^ permalink raw reply

* Re: backlight/ld9040.c: regulator control in the lcd driver
From: Linus Walleij @ 2011-12-02 10:05 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <CAH9JG2XdDn26ziceug6-Dc8g3+z3AUuzL34-oHRy10qL2RjF2w@mail.gmail.com>

On Fri, Dec 2, 2011 at 9:57 AM, Kyungmin Park <kyungmin.park@samsung.com> wrote:
>>[leedonghwa]
> [Me]
>>> +         lcd->reg_vdd3 = regulator_get(lcd->dev, "vdd");
>>> +         if (IS_ERR(lcd->reg_vdd3)) {
>>> +                   dev_info(lcd->dev, "no %s regulator found\n", "vdd");
>>> +                   lcd->reg_vdd3 = NULL;
>>> +         }
>>> +
>>> +         lcd->reg_vci = regulator_get(lcd->dev, "vci");
>>> +         if (IS_ERR(lcd->reg_vci)) {
>>> +                   dev_info(lcd->dev, "no %s regulator found\n", "vci");
>>> +                   lcd->reg_vci = NULL;
>>> +         }
>>
>> As explained in earlier discussion with Mark regarding the SMSC911x
>> driver regulator, treat these as errors and do not fail
>> "gracefully" like this.
>>
>> Reference:
>> http://marc.info/?l=linux-netdev&m\x131914562120725&w=2
>
> As mentioned at commit message, the lcd regulator is optional part and
> refer the mmc codes
>
>        host->vmmc = regulator_get(mmc_dev(mmc), "vmmc");
>        if (IS_ERR(host->vmmc)) {
>                pr_info("%s: no vmmc regulator found\n", mmc_hostname(mmc));
>                host->vmmc = NULL;
>        } else {
>                regulator_enable(host->vmmc);
>        }
>
> Previous time, these codes are located at board file, but more boards
> are used, it has same codes for all boards. so move it to drivers.

I know. This was brought up in the aforementioned discussion,
but the above is also wrong, simply. See:
http://marc.info/?l=linux-netdev&m\x131914562120667&w=2
http://marc.info/?l=linux-netdev&m\x131914562120690&w=2
http://marc.info/?l=linux-netdev&m\x131914562120725&w=2
http://marc.info/?l=linux-netdev&m\x131963332527416&w=2

> In our case, it has the regulator but some boards don't.
>
> Umm then how to handle the regulator gracefully?

Mark suggest using a fixed-voltage regulator for boards
where the power is always on. The voltage level itself
is optional. See:
http://marc.info/?l=linux-netdev&m\x131963332527416&w=2

Other approaches is to use dummy regulators, or not
call regulator_has_full_constraints(), which means the
regulator core will provide dummy regulators anyways.
See:
http://marc.info/?l=linux-netdev&m\x131973043527112&w=2
http://marc.info/?l=linux-netdev&m\x131975178703166&w=2

Whole thread of discussion:
http://marc.info/?l=linux-netdev&w=2&r=1&s=smsc911x&q=b

Yours,
Linus Walleij

^ permalink raw reply

* [PATCH] video: s3c-fb: set missing bitmask of enabled hardware window
From: Jingoo Han @ 2011-12-02 10:07 UTC (permalink / raw)
  To: linux-fbdev

This patch set missing bitmask of enabled hardware window which
should be checked whenever the hardware window is enabled.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/video/s3c-fb.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c
index 12eaee0..fc3df1d 100644
--- a/drivers/video/s3c-fb.c
+++ b/drivers/video/s3c-fb.c
@@ -574,6 +574,7 @@ static int s3c_fb_set_par(struct fb_info *info)
 	}
 
 	data = WINCONx_ENWIN;
+	sfb->enabled |= (1 << win->index);
 
 	/* note, since we have to round up the bits-per-pixel, we end up
 	 * relying on the bitfield information for r/g/b/a to work out
-- 
1.7.1


^ permalink raw reply related

* Re: backlight/ld9040.c: regulator control in the lcd driver
From: Kyungmin Park @ 2011-12-02 10:14 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <CACRpkdan-zKk6TN15MkbEuNk5C949SL-jniK98vReFTzfvGC4w@mail.gmail.com>

On 12/2/11, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Fri, Dec 2, 2011 at 9:57 AM, Kyungmin Park <kyungmin.park@samsung.com>
> wrote:
>>>[leedonghwa]
>> [Me]
>>>> +         lcd->reg_vdd3 = regulator_get(lcd->dev, "vdd");
>>>> +         if (IS_ERR(lcd->reg_vdd3)) {
>>>> +                   dev_info(lcd->dev, "no %s regulator found\n",
>>>> "vdd");
>>>> +                   lcd->reg_vdd3 = NULL;
>>>> +         }
>>>> +
>>>> +         lcd->reg_vci = regulator_get(lcd->dev, "vci");
>>>> +         if (IS_ERR(lcd->reg_vci)) {
>>>> +                   dev_info(lcd->dev, "no %s regulator found\n",
>>>> "vci");
>>>> +                   lcd->reg_vci = NULL;
>>>> +         }
>>>
>>> As explained in earlier discussion with Mark regarding the SMSC911x
>>> driver regulator, treat these as errors and do not fail
>>> "gracefully" like this.
>>>
>>> Reference:
>>> http://marc.info/?l=linux-netdev&m\x131914562120725&w=2
>>
>> As mentioned at commit message, the lcd regulator is optional part and
>> refer the mmc codes
>>
>>        host->vmmc = regulator_get(mmc_dev(mmc), "vmmc");
>>        if (IS_ERR(host->vmmc)) {
>>                pr_info("%s: no vmmc regulator found\n",
>> mmc_hostname(mmc));
>>                host->vmmc = NULL;
>>        } else {
>>                regulator_enable(host->vmmc);
>>        }
>>
>> Previous time, these codes are located at board file, but more boards
>> are used, it has same codes for all boards. so move it to drivers.
>
> I know. This was brought up in the aforementioned discussion,
> but the above is also wrong, simply. See:
> http://marc.info/?l=linux-netdev&m\x131914562120667&w=2
> http://marc.info/?l=linux-netdev&m\x131914562120690&w=2
> http://marc.info/?l=linux-netdev&m\x131914562120725&w=2
> http://marc.info/?l=linux-netdev&m\x131963332527416&w=2
>
>> In our case, it has the regulator but some boards don't.
>>
>> Umm then how to handle the regulator gracefully?
>
> Mark suggest using a fixed-voltage regulator for boards
> where the power is always on. The voltage level itself
> is optional. See:
> http://marc.info/?l=linux-netdev&m\x131963332527416&w=2

Make sense, okay send the updated patch
>
> Other approaches is to use dummy regulators, or not
> call regulator_has_full_constraints(), which means the
> regulator core will provide dummy regulators anyways.
> See:
> http://marc.info/?l=linux-netdev&m\x131973043527112&w=2
> http://marc.info/?l=linux-netdev&m\x131975178703166&w=2
>
> Whole thread of discussion:
> http://marc.info/?l=linux-netdev&w=2&r=1&s=smsc911x&q=b
>
> Yours,
> Linus Walleij
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

^ permalink raw reply

* Re: backlight/ld9040.c: regulator control in the lcd driver
From: Mark Brown @ 2011-12-02 10:31 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <CAH9JG2XdDn26ziceug6-Dc8g3+z3AUuzL34-oHRy10qL2RjF2w@mail.gmail.com>

On Fri, Dec 02, 2011 at 05:57:35PM +0900, Kyungmin Park wrote:

> As mentioned at commit message, the lcd regulator is optional part and
> refer the mmc codes

>         host->vmmc = regulator_get(mmc_dev(mmc), "vmmc");
>         if (IS_ERR(host->vmmc)) {
>                 pr_info("%s: no vmmc regulator found\n", mmc_hostname(mmc));
>                 host->vmmc = NULL;
>         } else {
>                 regulator_enable(host->vmmc);
>         }

> Previous time, these codes are located at board file, but more boards
> are used, it has same codes for all boards. so move it to drivers.

In the case of MMC the MMC guys told us that this supply was entirely
optional for MMC operation, it wasn't an essential supply for the MMC
device to run it just enabled more features.  For supplies like that
it's OK for the regulator to fail, the driver should just not do
whatever things are enabled by having that supply.

^ permalink raw reply

* Re: backlight/ld9040.c: regulator control in the lcd driver
From: Linus Walleij @ 2011-12-02 10:36 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111202103139.GA8245@opensource.wolfsonmicro.com>

On Fri, Dec 2, 2011 at 11:31 AM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Fri, Dec 02, 2011 at 05:57:35PM +0900, Kyungmin Park wrote:
>
>> As mentioned at commit message, the lcd regulator is optional part and
>> refer the mmc codes
>
>>         host->vmmc = regulator_get(mmc_dev(mmc), "vmmc");
>>         if (IS_ERR(host->vmmc)) {
>>                 pr_info("%s: no vmmc regulator found\n", mmc_hostname(mmc));
>>                 host->vmmc = NULL;
>>         } else {
>>                 regulator_enable(host->vmmc);
>>         }
>
>> Previous time, these codes are located at board file, but more boards
>> are used, it has same codes for all boards. so move it to drivers.
>
> In the case of MMC the MMC guys told us that this supply was entirely
> optional for MMC operation, it wasn't an essential supply for the MMC
> device to run it just enabled more features.  For supplies like that
> it's OK for the regulator to fail, the driver should just not do
> whatever things are enabled by having that supply.

I don't think that's true. You *must* have some voltage on VMMC
to power the card, the optional part is regulating that voltage to
different levels as requested by the card internal machinery when
talking to it. All MMC/SD cards can run on a fixed voltage, something
like 3.8V I think.

In line with our previous discussions I think this should actually be
defined as a fixed voltage regulator in case it cannot be controlled,
because there sure as hell is a voltage there on all systems.

Yours,
Linus Walleij

^ permalink raw reply

* Re: backlight/ld9040.c: regulator control in the lcd driver
From: Mark Brown @ 2011-12-02 10:52 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <CACRpkdYrNcuch-H9ttHE3saceCM-WsB-Wx0-tih8LHxu6ftaYA@mail.gmail.com>

On Fri, Dec 02, 2011 at 11:36:13AM +0100, Linus Walleij wrote:

> I don't think that's true. You *must* have some voltage on VMMC
> to power the card, the optional part is regulating that voltage to
> different levels as requested by the card internal machinery when
> talking to it. All MMC/SD cards can run on a fixed voltage, something
> like 3.8V I think.

> In line with our previous discussions I think this should actually be
> defined as a fixed voltage regulator in case it cannot be controlled,
> because there sure as hell is a voltage there on all systems.

I have to say that I was very suspicious of this claim at the time but
there was so much pain associated with the MMC stuff that it just got
left to slide.  Similarly with the use of regulator_get_exclusive() to
vary the voltage, I'd *really* expect that the code would be able to
cope with shared supplies.

^ permalink raw reply

* Re: QVGA on a hardware which supports only >= VGA
From: James Simmons @ 2011-12-02 17:57 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <CAH9NwWdUZHfhqpNwcfxK_EnsMLeEazB50rQ=m65U3+tjhpwGJQ@mail.gmail.com>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2928 bytes --]

> 2011/11/18 Christian Gmeiner <christian.gmeiner@gmail.com>:
> > Hi all,
> >
> > I am currently in the process to get some local patches into mainline
> > and/or fix my
> > problems the right way. At the moment I am stuck with this problem:
> >
> > I am on a device (x86), which is Geode lx800 based and there is a
> > panel connected to
> > it. The problem is that two different screen resolutions are used. QVGA and VGA.
> > Should not sound like a problem, but the lx800 can only do VGA. So get
> > it working,
> > I need to pass the correct resolution via kernel cmd to the lxfb
> > driver and I am using
> > this patch (based on 2.6.36.4 kernel):
> >
> > --- a/drivers/video/fbmem.c
> > +++ b/drivers/video/fbmem.c
> > @@ -1050,6 +1050,7 @@ static long do_fb_ioctl(struct fb_info *info,
> > unsigned int cmd,
> >                ret = copy_to_user(argp, &var, sizeof(var)) ? -EFAULT : 0;
> >                break;
> >        case FBIOPUT_VSCREENINFO:
> > +#if 0
> >                if (copy_from_user(&var, argp, sizeof(var)))
> >                        return -EFAULT;
> >                if (!lock_fb_info(info))
> > @@ -1062,6 +1063,8 @@ static long do_fb_ioctl(struct fb_info *info,
> > unsigned int cmd,
> >                unlock_fb_info(info);
> >                if (!ret && copy_to_user(argp, &var, sizeof(var)))
> >                        ret = -EFAULT;
> > +#endif
> > +               ret = 0;
> >                break;
> >        case FBIOGET_FSCREENINFO:
> >                if (!lock_fb_info(info))
> > @@ -1086,6 +1089,7 @@ static long do_fb_ioctl(struct fb_info *info,
> > unsigned int cmd,
> >                ret = fb_cmap_to_user(&cmap_from, &cmap);
> >                break;
> >        case FBIOPAN_DISPLAY:
> > +#if 0
> >                if (copy_from_user(&var, argp, sizeof(var)))
> >                        return -EFAULT;
> >                if (!lock_fb_info(info))
> > @@ -1096,6 +1100,8 @@ static long do_fb_ioctl(struct fb_info *info,
> > unsigned int cmd,
> >                unlock_fb_info(info);
> >                if (ret == 0 && copy_to_user(argp, &var, sizeof(var)))
> >                        return -EFAULT;
> > +#endif
> > +               ret = 0;
> >                break;
> >        case FBIO_CURSOR:
> >                ret = -EINVAL;
> >
> > I need to mention that I am using a custom BIOS and Linux based
> > bootloader (kexec) in the
> > boot process. At the moment I am looking into coreboot, but I wanted
> > to know how to
> > solve this "problem" the correct way.
> >
> > To sum it up: I want to use a QVGA panel with a hardware that only
> > supports >= VGA.

That breaks the userland interface. What exactly is breaking? It looks 
like a userland app is causing the headaches.

^ permalink raw reply

* [PATCH] drivers/video: fsl-diu-fb: merge all allocated data into one block
From: Timur Tabi @ 2011-12-02 23:03 UTC (permalink / raw)
  To: linux-fbdev

The Freescale DIU driver allocates multiple blocks of memory, including
multiple DMA buffers.  Merge all of these blocks into one data structure.

Specifically:

1) struct fsl_diu_data now contains everything that needs to be allocated,
except for the framebuffers themselves.  DMA'able objects are aligned correctly
within the structure.

2) struct diu_addr is no longer needed, because we don't have to manage
multiple blocks of DMA memory.

3) Since there's no diu_addr any more, macro DMA_ADDR is used to calculate
the DMA address of any field in fsl_diu_data.

4) Functions allocate_buf() and free_buf() are no longer needed, because we
now assume that dma_alloc_coherent() will allocate a page-aligned block,
and everything is properly aligned with fsl_diu_data already, so we no longer
need to align any memory blocks ourselves.

5) The "dummy" area descriptor is now defined separately from the other
five ADs, so NUM_AOIS (previously called FSL_AOI_NUM) is now set to five
instead of six.  Previously, all six were combined together to avoid a
separate call to allocate_buf() just for the dummy AD.

6) framebuffer_alloc() and framebuffer_release() are no longer used.  The
framebuffer is initialized manually.

7) Error handling is simplified since there's only one memory buffer
allocated.

Signed-off-by: Timur Tabi <timur@freescale.com>
---
 drivers/video/fsl-diu-fb.c |  326 +++++++++++++++++++-------------------------
 1 files changed, 139 insertions(+), 187 deletions(-)

diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c
index a16beeb..4d54188 100644
--- a/drivers/video/fsl-diu-fb.c
+++ b/drivers/video/fsl-diu-fb.c
@@ -36,8 +36,7 @@
 #include <linux/fsl-diu-fb.h>
 #include "edid.h"
 
-#define FSL_AOI_NUM	6	/* 5 AOIs and one dummy AOI */
-				/* 1 for plane 0, 2 for plane 1&2 each */
+#define NUM_AOIS	5	/* 1 for plane 0, 2 for planes 1 & 2 each */
 
 /* HW cursor parameters */
 #define MAX_CURS		32
@@ -49,12 +48,6 @@
 #define INT_PARERR	0x08	/* Display parameters error interrupt */
 #define INT_LS_BF_VS	0x10	/* Lines before vsync. interrupt */
 
-struct diu_addr {
-	void *vaddr;		/* Virtual address */
-	dma_addr_t paddr;	/* Physical address */
-	__u32 offset;
-};
-
 /*
  * List of supported video modes
  *
@@ -330,23 +323,6 @@ static unsigned int d_cache_line_size;
 
 static DEFINE_SPINLOCK(diu_lock);
 
-struct fsl_diu_data {
-	struct fb_info *fsl_diu_info[FSL_AOI_NUM - 1];
-				/*FSL_AOI_NUM has one dummy AOI */
-	struct device_attribute dev_attr;
-	struct diu_ad *dummy_ad;
-	void *dummy_aoi_virt;
-	unsigned int irq;
-	int fb_enabled;
-	enum fsl_diu_monitor_port monitor_port;
-	struct diu __iomem *diu_reg;
-	spinlock_t reg_lock;
-	struct diu_addr ad;
-	struct diu_addr gamma;
-	struct diu_addr pallete;
-	struct diu_addr cursor;
-};
-
 enum mfb_index {
 	PLANE0 = 0,	/* Plane 0, only one AOI that fills the screen */
 	PLANE1_AOI0,	/* Plane 1, first AOI */
@@ -370,6 +346,44 @@ struct mfb_info {
 	u8 *edid_data;
 };
 
+/**
+ * struct fsl_diu_data - per-DIU data structure
+ * @dma_addr: DMA address of this structure
+ * @fsl_diu_info: fb_info objects, one per AOI
+ * @dev_attr: sysfs structure
+ * @irq: IRQ
+ * @fb_enabled: TRUE if the DIU is enabled, FALSE if not
+ * @monitor_port: the monitor port this DIU is connected to
+ * @diu_reg: pointer to the DIU hardware registers
+ * @reg_lock: spinlock for register access
+ * @dummy_aoi: video buffer for the 4x4 32-bit dummy AOI
+ * dummy_ad: DIU Area Descriptor for the dummy AOI
+ * @ad[]: Area Descriptors for each real AOI
+ * @gamma: gamma color table
+ * @cursor: hardware cursor data
+ *
+ * This data structure must be allocated with 32-byte alignment, so that the
+ * internal fields can be aligned properly.
+ */
+struct fsl_diu_data {
+	dma_addr_t dma_addr;
+	struct fb_info fsl_diu_info[NUM_AOIS];
+	struct mfb_info mfb[NUM_AOIS];
+	struct device_attribute dev_attr;
+	unsigned int irq;
+	int fb_enabled;
+	enum fsl_diu_monitor_port monitor_port;
+	struct diu __iomem *diu_reg;
+	spinlock_t reg_lock;
+	u8 dummy_aoi[4 * 4 * 4];
+	struct diu_ad dummy_ad __aligned(8);
+	struct diu_ad ad[NUM_AOIS] __aligned(8);
+	u8 gamma[256 * 3] __aligned(32);
+	u8 cursor[MAX_CURS * MAX_CURS * 2] __aligned(32);
+} __aligned(32);
+
+/* Determine the DMA address of a member of the fsl_diu_data structure */
+#define DMA_ADDR(p, f) ((p)->dma_addr + offsetof(struct fsl_diu_data, f))
 
 static struct mfb_info mfb_template[] = {
 	{
@@ -504,7 +518,7 @@ static void fsl_diu_enable_panel(struct fb_info *info)
 			wr_reg_wa(&hw->desc[0], ad->paddr);
 		break;
 	case PLANE1_AOI0:
-		cmfbi = machine_data->fsl_diu_info[2]->par;
+		cmfbi = &machine_data->mfb[2];
 		if (hw->desc[1] != ad->paddr) {	/* AOI0 closed */
 			if (cmfbi->count > 0)	/* AOI1 open */
 				ad->next_ad @@ -515,7 +529,7 @@ static void fsl_diu_enable_panel(struct fb_info *info)
 		}
 		break;
 	case PLANE2_AOI0:
-		cmfbi = machine_data->fsl_diu_info[4]->par;
+		cmfbi = &machine_data->mfb[4];
 		if (hw->desc[2] != ad->paddr) {	/* AOI0 closed */
 			if (cmfbi->count > 0)	/* AOI1 open */
 				ad->next_ad @@ -526,17 +540,17 @@ static void fsl_diu_enable_panel(struct fb_info *info)
 		}
 		break;
 	case PLANE1_AOI1:
-		pmfbi = machine_data->fsl_diu_info[1]->par;
+		pmfbi = &machine_data->mfb[1];
 		ad->next_ad = 0;
-		if (hw->desc[1] = machine_data->dummy_ad->paddr)
+		if (hw->desc[1] = machine_data->dummy_ad.paddr)
 			wr_reg_wa(&hw->desc[1], ad->paddr);
 		else					/* AOI0 open */
 			pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
 		break;
 	case PLANE2_AOI1:
-		pmfbi = machine_data->fsl_diu_info[3]->par;
+		pmfbi = &machine_data->mfb[3];
 		ad->next_ad = 0;
-		if (hw->desc[2] = machine_data->dummy_ad->paddr)
+		if (hw->desc[2] = machine_data->dummy_ad.paddr)
 			wr_reg_wa(&hw->desc[2], ad->paddr);
 		else				/* AOI0 was open */
 			pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
@@ -553,47 +567,47 @@ static void fsl_diu_disable_panel(struct fb_info *info)
 
 	switch (mfbi->index) {
 	case PLANE0:
-		if (hw->desc[0] != machine_data->dummy_ad->paddr)
-			wr_reg_wa(&hw->desc[0], machine_data->dummy_ad->paddr);
+		if (hw->desc[0] != machine_data->dummy_ad.paddr)
+			wr_reg_wa(&hw->desc[0], machine_data->dummy_ad.paddr);
 		break;
 	case PLANE1_AOI0:
-		cmfbi = machine_data->fsl_diu_info[2]->par;
+		cmfbi = &machine_data->mfb[2];
 		if (cmfbi->count > 0)	/* AOI1 is open */
 			wr_reg_wa(&hw->desc[1], cmfbi->ad->paddr);
 					/* move AOI1 to the first */
 		else			/* AOI1 was closed */
-			wr_reg_wa(&hw->desc[1], machine_data->dummy_ad->paddr);
+			wr_reg_wa(&hw->desc[1], machine_data->dummy_ad.paddr);
 					/* close AOI 0 */
 		break;
 	case PLANE2_AOI0:
-		cmfbi = machine_data->fsl_diu_info[4]->par;
+		cmfbi = &machine_data->mfb[4];
 		if (cmfbi->count > 0)	/* AOI1 is open */
 			wr_reg_wa(&hw->desc[2], cmfbi->ad->paddr);
 					/* move AOI1 to the first */
 		else			/* AOI1 was closed */
-			wr_reg_wa(&hw->desc[2], machine_data->dummy_ad->paddr);
+			wr_reg_wa(&hw->desc[2], machine_data->dummy_ad.paddr);
 					/* close AOI 0 */
 		break;
 	case PLANE1_AOI1:
-		pmfbi = machine_data->fsl_diu_info[1]->par;
+		pmfbi = &machine_data->mfb[1];
 		if (hw->desc[1] != ad->paddr) {
 				/* AOI1 is not the first in the chain */
 			if (pmfbi->count > 0)
 					/* AOI0 is open, must be the first */
 				pmfbi->ad->next_ad = 0;
 		} else			/* AOI1 is the first in the chain */
-			wr_reg_wa(&hw->desc[1], machine_data->dummy_ad->paddr);
+			wr_reg_wa(&hw->desc[1], machine_data->dummy_ad.paddr);
 					/* close AOI 1 */
 		break;
 	case PLANE2_AOI1:
-		pmfbi = machine_data->fsl_diu_info[3]->par;
+		pmfbi = &machine_data->mfb[3];
 		if (hw->desc[2] != ad->paddr) {
 				/* AOI1 is not the first in the chain */
 			if (pmfbi->count > 0)
 				/* AOI0 is open, must be the first */
 				pmfbi->ad->next_ad = 0;
 		} else		/* AOI1 is the first in the chain */
-			wr_reg_wa(&hw->desc[2], machine_data->dummy_ad->paddr);
+			wr_reg_wa(&hw->desc[2], machine_data->dummy_ad.paddr);
 				/* close AOI 1 */
 		break;
 	}
@@ -633,8 +647,8 @@ static void adjust_aoi_size_position(struct fb_var_screeninfo *var,
 	int lower_aoi_is_open, upper_aoi_is_open;
 	__u32 base_plane_width, base_plane_height, upper_aoi_height;
 
-	base_plane_width = machine_data->fsl_diu_info[0]->var.xres;
-	base_plane_height = machine_data->fsl_diu_info[0]->var.yres;
+	base_plane_width = machine_data->fsl_diu_info[0].var.xres;
+	base_plane_height = machine_data->fsl_diu_info[0].var.yres;
 
 	if (mfbi->x_aoi_d < 0)
 		mfbi->x_aoi_d = 0;
@@ -649,7 +663,7 @@ static void adjust_aoi_size_position(struct fb_var_screeninfo *var,
 		break;
 	case PLANE1_AOI0:
 	case PLANE2_AOI0:
-		lower_aoi_mfbi = machine_data->fsl_diu_info[index+1]->par;
+		lower_aoi_mfbi = machine_data->fsl_diu_info[index+1].par;
 		lower_aoi_is_open = lower_aoi_mfbi->count > 0 ? 1 : 0;
 		if (var->xres > base_plane_width)
 			var->xres = base_plane_width;
@@ -667,9 +681,9 @@ static void adjust_aoi_size_position(struct fb_var_screeninfo *var,
 		break;
 	case PLANE1_AOI1:
 	case PLANE2_AOI1:
-		upper_aoi_mfbi = machine_data->fsl_diu_info[index-1]->par;
+		upper_aoi_mfbi = machine_data->fsl_diu_info[index-1].par;
 		upper_aoi_height -				machine_data->fsl_diu_info[index-1]->var.yres;
+				machine_data->fsl_diu_info[index-1].var.yres;
 		upper_aoi_bottom = upper_aoi_mfbi->y_aoi_d + upper_aoi_height;
 		upper_aoi_is_open = upper_aoi_mfbi->count > 0 ? 1 : 0;
 		if (var->xres > base_plane_width)
@@ -812,15 +826,15 @@ static void update_lcdc(struct fb_info *info)
 	struct fsl_diu_data *machine_data = mfbi->parent;
 	struct diu __iomem *hw;
 	int i, j;
-	char __iomem *cursor_base, *gamma_table_base;
+	u8 *gamma_table_base;
 
 	u32 temp;
 
 	hw = machine_data->diu_reg;
 
 	diu_ops.set_monitor_port(machine_data->monitor_port);
-	gamma_table_base = machine_data->gamma.vaddr;
-	cursor_base = machine_data->cursor.vaddr;
+	gamma_table_base = machine_data->gamma;
+
 	/* Prep for DIU init  - gamma table, cursor table */
 
 	for (i = 0; i <= 2; i++)
@@ -828,14 +842,14 @@ static void update_lcdc(struct fb_info *info)
 			*gamma_table_base++ = j;
 
 	diu_ops.set_gamma_table(machine_data->monitor_port,
-				machine_data->gamma.vaddr);
+		machine_data->gamma);
 
 	disable_lcdc(info);
 
 	/* Program DIU registers */
 
-	out_be32(&hw->gamma, machine_data->gamma.paddr);
-	out_be32(&hw->cursor, machine_data->cursor.paddr);
+	out_be32(&hw->gamma, DMA_ADDR(machine_data, gamma));
+	out_be32(&hw->cursor, DMA_ADDR(machine_data, cursor));
 
 	out_be32(&hw->bgnd, 0x007F7F7F); 	/* BGND */
 	out_be32(&hw->bgnd_wb, 0); 		/* BGND_WB */
@@ -1423,37 +1437,6 @@ static int fsl_diu_resume(struct platform_device *ofdev)
 #define fsl_diu_resume NULL
 #endif				/* CONFIG_PM */
 
-/* Align to 64-bit(8-byte), 32-byte, etc. */
-static int allocate_buf(struct device *dev, struct diu_addr *buf, u32 size,
-			u32 bytes_align)
-{
-	u32 offset;
-	dma_addr_t mask;
-
-	buf->vaddr -		dma_alloc_coherent(dev, size + bytes_align, &buf->paddr,
-				   GFP_DMA | __GFP_ZERO);
-	if (!buf->vaddr)
-		return -ENOMEM;
-
-	mask = bytes_align - 1;
-	offset = buf->paddr & mask;
-	if (offset) {
-		buf->offset = bytes_align - offset;
-		buf->paddr = buf->paddr + offset;
-	} else
-		buf->offset = 0;
-
-	return 0;
-}
-
-static void free_buf(struct device *dev, struct diu_addr *buf, u32 size,
-		     u32 bytes_align)
-{
-	dma_free_coherent(dev, size + bytes_align, buf->vaddr,
-			  buf->paddr - buf->offset);
-}
-
 static ssize_t store_monitor(struct device *device,
 	struct device_attribute *attr, const char *buf, size_t count)
 {
@@ -1468,11 +1451,10 @@ static ssize_t store_monitor(struct device *device,
 		/* All AOIs need adjust pixel format
 		 * fsl_diu_set_par only change the pixsel format here
 		 * unlikely to fail. */
-		fsl_diu_set_par(machine_data->fsl_diu_info[0]);
-		fsl_diu_set_par(machine_data->fsl_diu_info[1]);
-		fsl_diu_set_par(machine_data->fsl_diu_info[2]);
-		fsl_diu_set_par(machine_data->fsl_diu_info[3]);
-		fsl_diu_set_par(machine_data->fsl_diu_info[4]);
+		unsigned int i;
+
+		for (i=0; i < NUM_AOIS; i++)
+			fsl_diu_set_par(&machine_data->fsl_diu_info[i]);
 	}
 	return count;
 }
@@ -1499,28 +1481,52 @@ static int __devinit fsl_diu_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct mfb_info *mfbi;
-	phys_addr_t dummy_ad_addr = 0;
-	int ret, i, error = 0;
 	struct fsl_diu_data *machine_data;
 	int diu_mode;
+	dma_addr_t dma_addr; /* DMA addr of machine_data struct */
+	unsigned int i;
+	int ret;
 
-	machine_data = kzalloc(sizeof(struct fsl_diu_data), GFP_KERNEL);
+	machine_data = dma_alloc_coherent(&pdev->dev,
+		sizeof(struct fsl_diu_data), &dma_addr, GFP_DMA | __GFP_ZERO);
 	if (!machine_data)
 		return -ENOMEM;
+	machine_data->dma_addr = dma_addr;
+
+	/*
+	 * dma_alloc_coherent() uses a page allocator, so the address is
+	 * always page-aligned.  We need the memory to be 32-byte aligned,
+	 * so that's good.  However, if one day the allocator changes, we
+	 * need to catch that.  It's not worth the effort to handle unaligned
+	 * alloctions now because it's highly unlikely to ever be a problem.
+	 */
+	if ((unsigned long)machine_data & 31) {
+		dev_err(&pdev->dev, "misaligned allocation");
+		ret = -ENOMEM;
+		goto error;
+	}
 
 	spin_lock_init(&machine_data->reg_lock);
 
-	for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) {
-		machine_data->fsl_diu_info[i] -			framebuffer_alloc(sizeof(struct mfb_info), &pdev->dev);
-		if (!machine_data->fsl_diu_info[i]) {
-			dev_err(&pdev->dev, "cannot allocate memory\n");
-			ret = -ENOMEM;
-			goto error2;
-		}
-		mfbi = machine_data->fsl_diu_info[i]->par;
+	for (i = 0; i < NUM_AOIS; i++) {
+		struct fb_info *info = &machine_data->fsl_diu_info[i];
+
+		info->device = &pdev->dev;
+		info->par = &machine_data->mfb[i];
+
+		/*
+		 * We store the physical address of the AD in the reserved
+		 * 'paddr' field of the AD itself.
+		 */
+		machine_data->ad[i].paddr = DMA_ADDR(machine_data, ad[i]);
+
+		info->fix.smem_start = 0;
+
+		/* Initialize the AOI data structure */
+		mfbi = info->par;
 		memcpy(mfbi, &mfb_template[i], sizeof(struct mfb_info));
 		mfbi->parent = machine_data;
+		mfbi->ad = &machine_data->ad[i];
 
 		if (mfbi->index = PLANE0) {
 			const u8 *prop;
@@ -1538,7 +1544,7 @@ static int __devinit fsl_diu_probe(struct platform_device *pdev)
 	if (!machine_data->diu_reg) {
 		dev_err(&pdev->dev, "cannot map DIU registers\n");
 		ret = -EFAULT;
-		goto error2;
+		goto error;
 	}
 
 	diu_mode = in_be32(&machine_data->diu_reg->diu_mode);
@@ -1555,41 +1561,16 @@ static int __devinit fsl_diu_probe(struct platform_device *pdev)
 	}
 	machine_data->monitor_port = monitor_port;
 
-	/* Area descriptor memory pool aligns to 64-bit boundary */
-	if (allocate_buf(&pdev->dev, &machine_data->ad,
-			 sizeof(struct diu_ad) * FSL_AOI_NUM, 8))
-		return -ENOMEM;
-
-	/* Get memory for Gamma Table  - 32-byte aligned memory */
-	if (allocate_buf(&pdev->dev, &machine_data->gamma, 768, 32)) {
-		ret = -ENOMEM;
-		goto error;
-	}
-
-	/* For performance, cursor bitmap buffer aligns to 32-byte boundary */
-	if (allocate_buf(&pdev->dev, &machine_data->cursor,
-			 MAX_CURS * MAX_CURS * 2, 32)) {
-		ret = -ENOMEM;
-		goto error;
-	}
-
-	i = ARRAY_SIZE(machine_data->fsl_diu_info);
-	machine_data->dummy_ad = (struct diu_ad *)((u32)machine_data->ad.vaddr +
-			machine_data->ad.offset) + i;
-	machine_data->dummy_ad->paddr = machine_data->ad.paddr +
-			i * sizeof(struct diu_ad);
-	machine_data->dummy_aoi_virt = fsl_diu_alloc(64, &dummy_ad_addr);
-	if (!machine_data->dummy_aoi_virt) {
-		ret = -ENOMEM;
-		goto error;
-	}
-	machine_data->dummy_ad->addr = cpu_to_le32(dummy_ad_addr);
-	machine_data->dummy_ad->pix_fmt = 0x88882317;
-	machine_data->dummy_ad->src_size_g_alpha = cpu_to_le32((4 << 12) | 4);
-	machine_data->dummy_ad->aoi_size = cpu_to_le32((4 << 16) |  2);
-	machine_data->dummy_ad->offset_xyi = 0;
-	machine_data->dummy_ad->offset_xyd = 0;
-	machine_data->dummy_ad->next_ad = 0;
+	/* Initialize the dummy Area Descriptor */
+	machine_data->dummy_ad.addr +		cpu_to_le32(DMA_ADDR(machine_data, dummy_aoi));
+	machine_data->dummy_ad.pix_fmt = 0x88882317;
+	machine_data->dummy_ad.src_size_g_alpha = cpu_to_le32((4 << 12) | 4);
+	machine_data->dummy_ad.aoi_size = cpu_to_le32((4 << 16) |  2);
+	machine_data->dummy_ad.offset_xyi = 0;
+	machine_data->dummy_ad.offset_xyd = 0;
+	machine_data->dummy_ad.next_ad = 0;
+	machine_data->dummy_ad.paddr = DMA_ADDR(machine_data, dummy_ad);
 
 	/*
 	 * Let DIU display splash screen if it was pre-initialized
@@ -1597,19 +1578,13 @@ static int __devinit fsl_diu_probe(struct platform_device *pdev)
 	 */
 	if (diu_mode = MFB_MODE0)
 		out_be32(&machine_data->diu_reg->desc[0],
-			 machine_data->dummy_ad->paddr);
-
-	out_be32(&machine_data->diu_reg->desc[1], machine_data->dummy_ad->paddr);
-	out_be32(&machine_data->diu_reg->desc[2], machine_data->dummy_ad->paddr);
-
-	for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) {
-		machine_data->fsl_diu_info[i]->fix.smem_start = 0;
-		mfbi = machine_data->fsl_diu_info[i]->par;
-		mfbi->ad = (struct diu_ad *)((u32)machine_data->ad.vaddr
-					+ machine_data->ad.offset) + i;
-		mfbi->ad->paddr -			machine_data->ad.paddr + i * sizeof(struct diu_ad);
-		ret = install_fb(machine_data->fsl_diu_info[i]);
+			 machine_data->dummy_ad.paddr);
+
+	out_be32(&machine_data->diu_reg->desc[1], machine_data->dummy_ad.paddr);
+	out_be32(&machine_data->diu_reg->desc[2], machine_data->dummy_ad.paddr);
+
+	for (i = 0; i < NUM_AOIS; i++) {
+		ret = install_fb(&machine_data->fsl_diu_info[i]);
 		if (ret) {
 			dev_err(&pdev->dev, "could not register fb %d\n", i);
 			goto error;
@@ -1626,9 +1601,8 @@ static int __devinit fsl_diu_probe(struct platform_device *pdev)
 	machine_data->dev_attr.attr.mode = S_IRUGO|S_IWUSR;
 	machine_data->dev_attr.show = show_monitor;
 	machine_data->dev_attr.store = store_monitor;
-	error = device_create_file(machine_data->fsl_diu_info[0]->dev,
-				  &machine_data->dev_attr);
-	if (error) {
+	ret = device_create_file(&pdev->dev, &machine_data->dev_attr);
+	if (ret) {
 		dev_err(&pdev->dev, "could not create sysfs file %s\n",
 			machine_data->dev_attr.attr.name);
 	}
@@ -1637,26 +1611,13 @@ static int __devinit fsl_diu_probe(struct platform_device *pdev)
 	return 0;
 
 error:
-	for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++)
-		uninstall_fb(machine_data->fsl_diu_info[i]);
-
-	if (machine_data->ad.vaddr)
-		free_buf(&pdev->dev, &machine_data->ad,
-			 sizeof(struct diu_ad) * FSL_AOI_NUM, 8);
-	if (machine_data->gamma.vaddr)
-		free_buf(&pdev->dev, &machine_data->gamma, 768, 32);
-	if (machine_data->cursor.vaddr)
-		free_buf(&pdev->dev, &machine_data->cursor,
-			 MAX_CURS * MAX_CURS * 2, 32);
-	if (machine_data->dummy_aoi_virt)
-		fsl_diu_free(machine_data->dummy_aoi_virt, 64);
+	for (i = 0; i < NUM_AOIS; i++)
+		uninstall_fb(&machine_data->fsl_diu_info[i]);
+
 	iounmap(machine_data->diu_reg);
 
-error2:
-	for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++)
-		if (machine_data->fsl_diu_info[i])
-			framebuffer_release(machine_data->fsl_diu_info[i]);
-	kfree(machine_data);
+	dma_free_coherent(&pdev->dev, sizeof(struct fsl_diu_data),
+		machine_data, machine_data->dma_addr);
 
 	return ret;
 }
@@ -1667,25 +1628,16 @@ static int fsl_diu_remove(struct platform_device *pdev)
 	int i;
 
 	machine_data = dev_get_drvdata(&pdev->dev);
-	disable_lcdc(machine_data->fsl_diu_info[0]);
+	disable_lcdc(&machine_data->fsl_diu_info[0]);
 	free_irq_local(machine_data);
-	for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++)
-		uninstall_fb(machine_data->fsl_diu_info[i]);
-	if (machine_data->ad.vaddr)
-		free_buf(&pdev->dev, &machine_data->ad,
-			 sizeof(struct diu_ad) * FSL_AOI_NUM, 8);
-	if (machine_data->gamma.vaddr)
-		free_buf(&pdev->dev, &machine_data->gamma, 768, 32);
-	if (machine_data->cursor.vaddr)
-		free_buf(&pdev->dev, &machine_data->cursor,
-			 MAX_CURS * MAX_CURS * 2, 32);
-	if (machine_data->dummy_aoi_virt)
-		fsl_diu_free(machine_data->dummy_aoi_virt, 64);
+
+	for (i = 0; i < NUM_AOIS; i++)
+		uninstall_fb(&machine_data->fsl_diu_info[i]);
+
 	iounmap(machine_data->diu_reg);
-	for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++)
-		if (machine_data->fsl_diu_info[i])
-			framebuffer_release(machine_data->fsl_diu_info[i]);
-	kfree(machine_data);
+
+	dma_free_coherent(&pdev->dev, sizeof(struct fsl_diu_data),
+		machine_data, machine_data->dma_addr);
 
 	return 0;
 }
-- 
1.7.3.4



^ permalink raw reply related

* Re: [PATCH v3.1] [resend] Resurrect Intel740 driver: i740fb
From: Florian Tobias Schandinat @ 2011-12-03 21:45 UTC (permalink / raw)
  To: Ondrej Zary; +Cc: linux-fbdev, Paul Mundt, Kernel development list
In-Reply-To: <201111182154.45139.linux@rainbow-software.org>

Hi Ondrej,

On 11/18/2011 08:54 PM, Ondrej Zary wrote:
> Hello,
> this is an v3 attempt to resurrect an old (like 2.4.19) out-of-tree driver for
> Intel740 graphics cards and modify it for recent kernels. The old driver is
> located at: http://sourceforge.net/projects/i740fbdev/files/
> 
> It was easier to create a new driver based on skeletonfb, using most of the
> low level HW code from the old driver. The DDC code is completely new.
> 
> The driver was tested on two 8MB cards: Protac AG240D and Diamond Stealth II
> G460.
> 
> Changes in v3:
>  - added suspend/resume support
>  - fixed x panning

Could you write this text more like other commit messages you see when you do
"git log" rather than an email, please? It's mostly okay, but no greetings, no
history of your patch (that might be useful but please write it in a separate
section and not spread out trough the commit message).

> 
> Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
> 
> --- linux-2.6.39-rc2-orig/drivers/video/Makefile	2011-04-06 03:30:43.000000000 +0200
> +++ linux-2.6.39-rc2/drivers/video/Makefile	2011-07-30 11:34:10.000000000 +0200
> @@ -36,6 +36,7 @@ obj-$(CONFIG_FB_CYBER2000)        += cyb
>  obj-$(CONFIG_FB_PM2)              += pm2fb.o
>  obj-$(CONFIG_FB_PM3)		  += pm3fb.o
>  
> +obj-$(CONFIG_FB_I740)		  += i740fb.o
>  obj-$(CONFIG_FB_MATROX)		  += matrox/
>  obj-$(CONFIG_FB_RIVA)		  += riva/
>  obj-$(CONFIG_FB_NVIDIA)		  += nvidia/
> --- linux-2.6.39-rc2-orig/drivers/video/Kconfig	2011-04-06 03:30:43.000000000 +0200
> +++ linux-2.6.39-rc2/drivers/video/Kconfig	2011-10-24 23:29:42.000000000 +0200
> @@ -1117,6 +1117,17 @@ config FB_RIVA_BACKLIGHT
>  	help
>  	  Say Y here if you want to control the backlight of your display.
>  
> +config FB_I740
> +	tristate "Intel740 support (EXPERIMENTAL)"
> +	depends on EXPERIMENTAL && FB && PCI
> +	select FB_MODE_HELPERS
> +	select FB_CFB_FILLRECT
> +	select FB_CFB_COPYAREA
> +	select FB_CFB_IMAGEBLIT
> +	select VGASTATE
> +	help
> +	  This driver supports graphics cards based on Intel740 chip.
> +
>  config FB_I810
>  	tristate "Intel 810/815 support (EXPERIMENTAL)"
>  	depends on EXPERIMENTAL && FB && PCI && X86_32 && AGP_INTEL
> --- /dev/null	2011-10-28 20:05:27.615214131 +0200
> +++ linux-2.6.39-rc2/drivers/video/i740fb.c	2011-10-28 20:03:34.000000000 +0200
> @@ -0,0 +1,1286 @@
> +/*
> + * i740fb - framebuffer driver for Intel740
> + * Copyright (c) 2011 Ondrej Zary
> + *
> + * Based on old i740fb driver (c) 2001-2002 Andrey Ulanov <drey@rt.mipt.ru> which was partially based on:
> + *  VGA 16-color framebuffer driver (c) 1999 Ben Pfaff <pfaffben@debian.org> and Petr Vandrovec <VANDROVE@vc.cvut.cz>
> + *  i740 driver from XFree86 (c) 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
> + *  i740fb by Patrick LERDA, v0.9
> + */

Although there are exception where checkpatch errors/warnings can be ignored,
you really shouldn't cause unnecessary ones which you would not like to defend.
After all there are some people running around and "fixing" those in existing
code. And at least I'd consider those "line over 80 characters" due to comments
absolutely unnecessary.

> +
> +#include <linux/module.h>
> +#include <linux/kernel.h>
> +#include <linux/errno.h>
> +#include <linux/string.h>
> +#include <linux/mm.h>
> +#include <linux/slab.h>
> +#include <linux/delay.h>
> +#include <linux/fb.h>
> +#include <linux/init.h>
> +#include <linux/pci.h>
> +#include <linux/pci_ids.h>
> +#include <linux/i2c.h>
> +#include <linux/i2c-algo-bit.h>
> +#include <linux/console.h>
> +#include <video/vga.h>
> +
> +#ifdef CONFIG_MTRR
> +#include <asm/mtrr.h>
> +#endif
> +
> +#include "i740_reg.h"
> +
> +static char *mode_option __devinitdata;
> +
> +#ifdef CONFIG_MTRR
> +static int mtrr __devinitdata = 1;
> +#endif
> +
> +struct i740fb_par {
> +	unsigned char __iomem *regs;
> +	bool has_sgram;
> +#ifdef CONFIG_MTRR
> +	int mtrr_reg;
> +#endif
> +	bool ddc_registered;
> +	struct i2c_adapter ddc_adapter;
> +	struct i2c_algo_bit_data ddc_algo;
> +	u32 pseudo_palette[16];
> +	struct mutex open_lock;
> +	unsigned int ref_count;
> +
> +	u8 crtc[VGA_CRT_C];
> +	u8 atc[VGA_ATT_C];
> +	u8 gdc[VGA_GFX_C];
> +	u8 seq[VGA_SEQ_C];
> +	u8 misc;
> +	u8 vss;
> +
> +	/* i740 specific registers */
> +	u8 display_cntl;
> +	u8 pixelpipe_cfg0;
> +	u8 pixelpipe_cfg1;
> +	u8 pixelpipe_cfg2;
> +	u8 video_clk2_m;
> +	u8 video_clk2_n;
> +	u8 video_clk2_mn_msbs;
> +	u8 video_clk2_div_sel;
> +	u8 pll_cntl;
> +	u8 address_mapping;
> +	u8 io_cntl;
> +	u8 bitblt_cntl;
> +	u8 ext_vert_total;
> +	u8 ext_vert_disp_end;
> +	u8 ext_vert_sync_start;
> +	u8 ext_vert_blank_start;
> +	u8 ext_horiz_total;
> +	u8 ext_horiz_blank;
> +	u8 ext_offset;
> +	u8 interlace_cntl;
> +	u32 lmi_fifo_watermark;
> +	u8 ext_start_addr;
> +	u8 ext_start_addr_hi;
> +};
> +
> +#define DACSPEED8	203
> +#define DACSPEED16	163
> +#define DACSPEED24_SG	136
> +#define DACSPEED24_SD	128
> +#define DACSPEED32	86
> +
> +static struct fb_fix_screeninfo i740fb_fix __devinitdata = {
> +	.id =		"i740fb",
> +	.type =		FB_TYPE_PACKED_PIXELS,
> +	.visual =	FB_VISUAL_TRUECOLOR,
> +	.xpanstep =	8,
> +	.ypanstep =	1,
> +	.accel =	FB_ACCEL_NONE,
> +};
> +
> +static inline void i740outb(struct i740fb_par *par, u16 port, u8 val)
> +{
> +	vga_mm_w(par->regs, port, val);
> +}
> +static inline u8 i740inb(struct i740fb_par *par, u16 port)
> +{
> +	return vga_mm_r(par->regs, port);
> +}
> +static inline void i740outreg(struct i740fb_par *par, u16 port, u8 reg, u8 val)
> +{
> +	vga_mm_w_fast(par->regs, port, reg, val);
> +}
> +static inline u8 i740inreg(struct i740fb_par *par, u16 port, u8 reg)
> +{
> +	vga_mm_w(par->regs, port, reg);
> +	return vga_mm_r(par->regs, port+1);
> +}
> +static inline void i740outreg_mask(struct i740fb_par *par, u16 port, u8 reg, u8 val, u8 mask)
> +{
> +	vga_mm_w_fast(par->regs, port, reg, (val & mask) | (i740inreg(par, port, reg) & ~mask));
> +}
> +static inline void i740outb_p(struct i740fb_par *par, u16 port, u8 val)
> +{
> +	vga_mm_w(par->regs, port, val);
> +}
> +static inline u8 i740inb_p(struct i740fb_par *par, unsigned short port)
> +{
> +	return vga_mm_r(par->regs, port);
> +}

What are those *_p functions for? Aren't they identical to those without _p?

> +
> +#define REG_DDC_DRIVE	0x62
> +#define REG_DDC_STATE	0x63
> +#define DDC_SCL		(1 << 3)
> +#define DDC_SDA		(1 << 2)
> +
> +static void i740fb_ddc_setscl(void *data, int val)
> +{
> +	struct i740fb_par *par = data;
> +	unsigned char reg;
> +
> +	i740outreg(par, XRX, REG_DDC_DRIVE,
> +		i740inreg(par, XRX, REG_DDC_DRIVE) | DDC_SCL);

Shouldn't you use i740outreg_mask here?

> +
> +	reg = i740inreg(par, XRX, REG_DDC_STATE);
> +	if (val)
> +		reg |= DDC_SCL;
> +	else
> +		reg &= ~DDC_SCL;
> +	i740outreg(par, XRX, REG_DDC_STATE, reg);

Shouldn't you use i740outreg_mask here?

> +}
> +
> +static void i740fb_ddc_setsda(void *data, int val)
> +{
> +	struct i740fb_par *par = data;
> +	unsigned char reg;
> +
> +	i740outreg(par, XRX, REG_DDC_DRIVE,
> +		i740inreg(par, XRX, REG_DDC_DRIVE) | DDC_SDA);

Shouldn't you use i740outreg_mask here?

> +
> +	reg = i740inreg(par, XRX, REG_DDC_STATE);
> +	if (val)
> +		reg |= DDC_SDA;
> +	else
> +		reg &= ~DDC_SDA;
> +	i740outreg(par, XRX, REG_DDC_STATE, reg);

Shouldn't you use i740outreg_mask here?

> +}
> +
> +static int i740fb_ddc_getscl(void *data)
> +{
> +	struct i740fb_par *par = data;
> +
> +	i740outreg(par, XRX, REG_DDC_DRIVE,
> +		i740inreg(par, XRX, REG_DDC_DRIVE) & ~DDC_SCL);

Shouldn't you use i740outreg_mask here?

> +
> +	return !!(i740inreg(par, XRX, REG_DDC_STATE) & DDC_SCL);

Why "!!"?

> +}
> +
> +static int i740fb_ddc_getsda(void *data)
> +{
> +	struct i740fb_par *par = data;
> +
> +	i740outreg(par, XRX, REG_DDC_DRIVE,
> +		i740inreg(par, XRX, REG_DDC_DRIVE) & ~DDC_SDA);

Shouldn't you use i740outreg_mask here?

> +
> +	return !!(i740inreg(par, XRX, REG_DDC_STATE) & DDC_SDA);

Why "!!"?

> +}
> +
> +static int __devinit i740fb_setup_ddc_bus(struct fb_info *info)
> +{
> +	struct i740fb_par *par = info->par;
> +
> +	strlcpy(par->ddc_adapter.name, info->fix.id,
> +		sizeof(par->ddc_adapter.name));
> +	par->ddc_adapter.owner		= THIS_MODULE;
> +	par->ddc_adapter.class		= I2C_CLASS_DDC;
> +	par->ddc_adapter.algo_data	= &par->ddc_algo;
> +	par->ddc_adapter.dev.parent	= info->device;
> +	par->ddc_algo.setsda		= i740fb_ddc_setsda;
> +	par->ddc_algo.setscl		= i740fb_ddc_setscl;
> +	par->ddc_algo.getsda		= i740fb_ddc_getsda;
> +	par->ddc_algo.getscl		= i740fb_ddc_getscl;
> +	par->ddc_algo.udelay		= 10;
> +	par->ddc_algo.timeout		= 20;
> +	par->ddc_algo.data		= par;
> +
> +	i2c_set_adapdata(&par->ddc_adapter, par);
> +
> +	return i2c_bit_add_bus(&par->ddc_adapter);
> +}
> +
> +static int i740fb_open(struct fb_info *info, int user)
> +{
> +	struct i740fb_par *par = info->par;
> +
> +	mutex_lock(&(par->open_lock));
> +	par->ref_count++;
> +	mutex_unlock(&(par->open_lock));
> +
> +	return 0;
> +}
> +
> +static int i740fb_release(struct fb_info *info, int user)
> +{
> +	struct i740fb_par *par = info->par;
> +
> +	mutex_lock(&(par->open_lock));
> +	if (par->ref_count = 0) {
> +		mutex_unlock(&(par->open_lock));
> +		return -EINVAL;

This should never happen? Probably any of the kernel error reporting mechanisms
like BUG_ON or printk would be better suited. I'm not sure whether returning an
error on release is a good idea.

> +	}
> +
> +	par->ref_count--;
> +	mutex_unlock(&(par->open_lock));
> +
> +	return 0;
> +}
> +
> +static u32 i740_calc_fifo(struct i740fb_par *par, u32 freq, int bpp)
> +{
> +	/*
> +	 * Would like to calculate these values automatically, but a generic
> +	 * algorithm does not seem possible.  Note: These FIFO water mark
> +	 * values were tested on several cards and seem to eliminate the
> +	 * all of the snow and vertical banding, but fine adjustments will
> +	 * probably be required for other cards.
> +	 */
> +
> +	u32 wm = 0x18120000;

The initial value will always be overwritten, or? Why do we initialize it at all?

> +
> +	switch (bpp) {
> +	case 8:
> +		if	(freq > 200) wm = 0x18120000;
> +		else if (freq > 175) wm = 0x16110000;
> +		else if (freq > 135) wm = 0x120E0000;
> +		else		     wm = 0x100D0000;
> +		break;
> +	case 15:
> +	case 16:
> +		if (par->has_sgram) {
> +			if	(freq > 140) wm = 0x2C1D0000;
> +			else if (freq > 120) wm = 0x2C180000;
> +			else if (freq > 100) wm = 0x24160000;
> +			else if (freq >  90) wm = 0x18120000;
> +			else if (freq >  50) wm = 0x16110000;
> +			else if (freq >  32) wm = 0x13100000;
> +			else		     wm = 0x120E0000;
> +		} else {
> +			if	(freq > 160) wm = 0x28200000;
> +			else if (freq > 140) wm = 0x2A1E0000;
> +			else if (freq > 130) wm = 0x2B1A0000;
> +			else if (freq > 120) wm = 0x2C180000;
> +			else if (freq > 100) wm = 0x24180000;
> +			else if (freq >  90) wm = 0x18120000;
> +			else if (freq >  50) wm = 0x16110000;
> +			else if (freq >  32) wm = 0x13100000;
> +			else		     wm = 0x120E0000;
> +		}
> +		break;
> +	case 24:
> +		if (par->has_sgram) {
> +			if	(freq > 130) wm = 0x31200000;
> +			else if (freq > 120) wm = 0x2E200000;
> +			else if (freq > 100) wm = 0x2C1D0000;
> +			else if (freq >  80) wm = 0x25180000;
> +			else if (freq >  64) wm = 0x24160000;
> +			else if (freq >  49) wm = 0x18120000;
> +			else if (freq >  32) wm = 0x16110000;
> +			else		     wm = 0x13100000;
> +		} else {
> +			if	(freq > 120) wm = 0x311F0000;
> +			else if (freq > 100) wm = 0x2C1D0000;
> +			else if (freq >  80) wm = 0x25180000;
> +			else if (freq >  64) wm = 0x24160000;
> +			else if (freq >  49) wm = 0x18120000;
> +			else if (freq >  32) wm = 0x16110000;
> +			else		     wm = 0x13100000;
> +		}
> +		break;
> +	case 32:
> +		if (par->has_sgram) {
> +			if	(freq >  80) wm = 0x2A200000;
> +			else if (freq >  60) wm = 0x281A0000;
> +			else if (freq >  49) wm = 0x25180000;
> +			else if (freq >  32) wm = 0x18120000;
> +			else		     wm = 0x16110000;
> +		} else {
> +			if	(freq >  80) wm = 0x29200000;
> +			else if (freq >  60) wm = 0x281A0000;
> +			else if (freq >  49) wm = 0x25180000;
> +			else if (freq >  32) wm = 0x18120000;
> +			else		     wm = 0x16110000;
> +		}
> +		break;
> +	}

It's a minor thing, but maybe it would be better to write those magic values as
pairs in arrays {freq, wm} and just loop trough the right array.

> +
> +	return wm;
> +}
> +
> +/* clock calculation from i740fb by Patrick LERDA */
> +
> +#define I740_RFREQ (1e6)
> +#define TARGET_MAX_N 30
> +
> +#define I740_FFIX		8
> +#define I740_REF_FREQ		(u32) (66.66666666667 * (1 << I740_FFIX) + 0.5)
> +#define I740_MAX_VCO_FREQ	(u32)(450.00000000000 * (1 << I740_FFIX) + 0.5)
> +
> +#define I740_CALC_VCLKfix(m, n, p, d)   ((((((m) * I740_REF_FREQ * (4 << ((d) << 1)))) / (n)) + ((1 << (p)) / 2)) / (1 << (p)))
> +
> +static void i740_calc_vclk(u32 freq_hz, struct i740fb_par *par)
> +{
> +	u32 freq = freq_hz / (u32)(1e6 / I740_RFREQ);
> +	const u32 err_max = freq / (u32)(I740_RFREQ / 0.005 / (1 << I740_FFIX) + 0.5);
> +	const u32 err_target = freq / (u32)(I740_RFREQ / 0.001 / (1 << I740_FFIX) + 0.5);
> +	u32 err_best = (u32)(512.0 * (1 << I740_FFIX));
> +	u32 f_err, f_vco;
> +	int m_best = 0, n_best = 0, p_best = 0, d_best = 0;
> +	int m, n, i;
> +
> +	/* find log2(MAX_VCO_FREQ/f_target) */
> +	for (i = 0; i < 16; i++)
> +		if ((I740_MAX_VCO_FREQ) / (1 << i) < freq / (u32)(I740_RFREQ / (1 << I740_FFIX)))
> +			break;
> +	i--;
> +	p_best = i;
> +
> +	d_best = 0;
> +	f_vco = (freq * (1 << p_best)) / (u32)(I740_RFREQ / (1 << I740_FFIX));
> +	freq = freq / (u32)(I740_RFREQ / (1 << I740_FFIX));
> +
> +	n = 2;
> +	do {
> +		n++;
> +		m = ((f_vco * n) / I740_REF_FREQ + 2) / 4;
> +
> +		if (m < 3)
> +			m = 3;
> +
> +		{
> +			u32 f_out = I740_CALC_VCLKfix(m, n, p_best, d_best);
> +
> +			f_err = (freq - f_out);
> +
> +			if (abs(f_err) < err_max) {
> +				m_best = m;
> +				n_best = n;
> +				err_best = f_err;
> +			}
> +		}
> +	} while ((abs(f_err) >= err_target) &&
> +		 ((n <= TARGET_MAX_N) || (abs(err_best) > err_max)));
> +
> +	if (abs(f_err) < err_target) {
> +		m_best = m;
> +		n_best = n;
> +	}
> +
> +	par->video_clk2_m = (m_best-2) & 0xFF;
> +	par->video_clk2_n = (n_best-2) & 0xFF;
> +	par->video_clk2_mn_msbs = ((((n_best-2) >> 4) & VCO_N_MSBS) |
> +				 (((m_best-2) >> 8) & VCO_M_MSBS));
> +	par->video_clk2_div_sel = ((p_best << 4) | (d_best ? 4 : 0) | REF_DIV_1);
> +}
> +
> +static int i740fb_decode_var(const struct fb_var_screeninfo *var, struct i740fb_par *par, struct fb_info *info)
> +{
> +	/*
> +	 *  Get the video params out of 'var'. If a value doesn't fit, round it up,
> +	 *  if it's too big, return -EINVAL.
> +	 */
> +
> +	u32 xres, right, hslen, left, xtotal;
> +	u32 yres, lower, vslen, upper, ytotal;
> +	u32 vxres, xoffset, vyres, yoffset;
> +	u32 bpp, base, dacspeed24;
> +	u8 r7;
> +	int i;
> +
> +	dev_dbg(info->device, "decode_var: xres: %i, yres: %i, xres_v: %i, xres_v: %i\n",
> +		  var->xres, var->yres, var->xres_virtual, var->xres_virtual);
> +	dev_dbg(info->device, "	xoff: %i, yoff: %i, bpp: %i, graysc: %i\n",
> +		  var->xoffset, var->yoffset, var->bits_per_pixel, var->grayscale);
> +	dev_dbg(info->device, "	activate: %i, nonstd: %i, vmode: %i\n",
> +		  var->activate, var->nonstd, var->vmode);
> +	dev_dbg(info->device, "	pixclock: %i, hsynclen:%i, vsynclen:%i\n",
> +		  var->pixclock, var->hsync_len, var->vsync_len);
> +	dev_dbg(info->device, "	left: %i, right: %i, up:%i, lower:%i\n",
> +		  var->left_margin, var->right_margin, var->upper_margin, var->lower_margin);
> +
> +
> +	bpp = var->bits_per_pixel;
> +	switch (bpp) {
> +	case 1 ... 8:
> +		bpp = 8;
> +		if ((((u32)1e6) / var->pixclock) > DACSPEED8) {
> +			dev_err(info->device, "requested pixclock %i MHz out of range (max. %i MHz at 8bpp)\n", 1000000 / var->pixclock, DACSPEED8);
> +			return -EINVAL;
> +		}
> +		break;
> +	case 9 ... 15:
> +		bpp = 15;
> +	case 16:
> +		if ((((u32)1e6) / var->pixclock) > DACSPEED16) {
> +			dev_err(info->device, "requested pixclock %i MHz out of range (max. %i MHz at 15/16bpp)\n", 1000000 / var->pixclock, DACSPEED16);
> +			return -EINVAL;
> +		}
> +		break;
> +	case 17 ... 24:
> +		bpp = 24;
> +		dacspeed24 = par->has_sgram ? DACSPEED24_SG : DACSPEED24_SD;
> +		if ((((u32)1e6) / var->pixclock) > dacspeed24) {
> +			dev_err(info->device, "requested pixclock %i MHz out of range (max. %i MHz at 24bpp)\n", 1000000 / var->pixclock, dacspeed24);
> +			return -EINVAL;
> +		}
> +		break;
> +	case 25 ... 32:
> +		bpp = 32;
> +		if ((((u32)1e6) / var->pixclock) > DACSPEED32) {
> +			dev_err(info->device, "requested pixclock %i MHz out of range (max. %i MHz at 32bpp)\n", 1000000 / var->pixclock, DACSPEED32);
> +			return -EINVAL;
> +		}
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	xres = (var->xres + 7) & ~7;
> +	vxres = (var->xres_virtual + 0xF) & ~0xF;
> +	if (vxres < xres)
> +		vxres = xres;
> +
> +	xoffset = (var->xoffset + 7) & ~7;
> +	xoffset = var->xoffset;
> +	if (xres + xoffset > vxres)
> +		xoffset = vxres - xres;
> +
> +	left = (var->left_margin + 7) & ~7;
> +	right = (var->right_margin + 7) & ~7;
> +	hslen = (var->hsync_len + 7) & ~7;

The kernel has a macro called ALIGN, using it would be better, I think.

> +
> +	yres = var->yres;
> +	vyres = var->yres_virtual;
> +	if (yres > vyres)
> +		vyres = yres;
> +
> +	yoffset = var->yoffset;
> +	if (yres + yoffset > vyres)
> +		yoffset = vyres - yres;
> +
> +	lower = var->lower_margin;
> +	vslen = var->vsync_len;
> +	upper = var->upper_margin;
> +
> +	if (vxres * vyres * ((bpp + 1) / 8) > info->screen_size || vyres = yres) {
> +		vyres = info->screen_size / vxres / ((bpp + 1) / 8);
> +		if (vyres < yres)
> +			return -ENOMEM;
> +	}
> +
> +	if (yoffset + yres > vyres)
> +		yoffset = vyres - yres;
> +
> +	xtotal = xres + right + hslen + left;
> +	ytotal = yres + lower + vslen + upper;
> +
> +	par->crtc[VGA_CRTC_H_TOTAL] = (xtotal >> 3) - 5;
> +	par->crtc[VGA_CRTC_H_DISP] = (xres >> 3) - 1;
> +	par->crtc[VGA_CRTC_H_BLANK_START] = ((xres + right) >> 3) - 1;
> +	par->crtc[VGA_CRTC_H_SYNC_START] = (xres + right) >> 3;
> +	par->crtc[VGA_CRTC_H_SYNC_END] = (((xres + right + hslen) >> 3) & 0x1F)
> +		| ((((xres + right + hslen) >> 3) & 0x20) << 2);
> +	par->crtc[VGA_CRTC_H_BLANK_END] = ((xres + right + hslen) >> 3 & 0x1F) | 0x80;
> +
> +	par->crtc[VGA_CRTC_V_TOTAL] = ytotal - 2;
> +
> +	r7 = 0x10;	/* disable linecompare */
> +	if (ytotal & 0x100)
> +		r7 |= 0x01;
> +	if (ytotal & 0x200)
> +		r7 |= 0x20;
> +
> +	par->crtc[VGA_CRTC_PRESET_ROW] = 0;
> +	par->crtc[VGA_CRTC_MAX_SCAN] = 0x40;	/* 1 scanline, no linecmp */
> +	if (var->vmode & FB_VMODE_DOUBLE)
> +		par->crtc[VGA_CRTC_MAX_SCAN] |= 0x80;
> +	par->crtc[VGA_CRTC_CURSOR_START] = 0x00;
> +	par->crtc[VGA_CRTC_CURSOR_END] = 0x00;
> +	par->crtc[VGA_CRTC_CURSOR_HI] = 0x00;
> +	par->crtc[VGA_CRTC_CURSOR_LO] = 0x00;
> +	par->crtc[VGA_CRTC_V_DISP_END] = yres-1;
> +	if ((yres-1) & 0x100)
> +		r7 |= 0x02;
> +	if ((yres-1) & 0x200)
> +		r7 |= 0x40;
> +
> +	par->crtc[VGA_CRTC_V_BLANK_START] = yres + lower - 1;
> +	par->crtc[VGA_CRTC_V_SYNC_START] = yres + lower - 1;
> +	if ((yres + lower - 1) & 0x100)
> +		r7 |= 0x0C;
> +	if ((yres + lower - 1) & 0x200) {
> +		par->crtc[VGA_CRTC_MAX_SCAN] |= 0x20;
> +		r7 |= 0x80;
> +	}
> +
> +	par->crtc[VGA_CRTC_V_SYNC_END] = ((yres + lower - 1 + vslen) & 0x0F) & ~0x10; /* disabled IRQ */
> +	par->crtc[VGA_CRTC_V_BLANK_END] = (yres + lower - 1 + vslen) & 0xFF; /* 0x7F for original VGA, but some SVGA chips requires all 8 bits to set */
> +
> +	par->crtc[VGA_CRTC_UNDERLINE] = 0x00;
> +	par->crtc[VGA_CRTC_MODE] = 0xC3 ;
> +	par->crtc[VGA_CRTC_LINE_COMPARE] = 0xFF;
> +	par->crtc[VGA_CRTC_OVERFLOW] = r7;
> +
> +	par->vss = 0x00;	/* 3DA */
> +
> +	for (i = 0x00; i < 0x10; i++)
> +		par->atc[i] = i;
> +	par->atc[VGA_ATC_MODE] = 0x81;
> +	par->atc[VGA_ATC_OVERSCAN] = 0x00;	/* 0 for EGA, 0xFF for VGA */
> +	par->atc[VGA_ATC_PLANE_ENABLE] = 0x0F;
> +	/*par->atc[VGA_ATC_PEL] = xoffset & 7;*/
> +	par->atc[VGA_ATC_COLOR_PAGE] = 0x00;
> +
> +	par->misc = 0xC3;
> +	if (var->sync & FB_SYNC_HOR_HIGH_ACT)
> +		par->misc &= ~0x40;
> +	if (var->sync & FB_SYNC_VERT_HIGH_ACT)
> +		par->misc &= ~0x80;
> +
> +	par->seq[VGA_SEQ_CLOCK_MODE] = 0x01;
> +	par->seq[VGA_SEQ_PLANE_WRITE] = 0x0F;
> +	par->seq[VGA_SEQ_CHARACTER_MAP] = 0x00;
> +	par->seq[VGA_SEQ_MEMORY_MODE] = 0x06;
> +
> +	par->gdc[VGA_GFX_SR_VALUE] = 0x00;
> +	par->gdc[VGA_GFX_SR_ENABLE] = 0x00;
> +	par->gdc[VGA_GFX_COMPARE_VALUE] = 0x00;
> +	par->gdc[VGA_GFX_DATA_ROTATE] = 0x00;
> +	par->gdc[VGA_GFX_PLANE_READ] = 0;
> +	par->gdc[VGA_GFX_MODE] = 0x02;
> +	par->gdc[VGA_GFX_MISC] = 0x05;
> +	par->gdc[VGA_GFX_COMPARE_MASK] = 0x0F;
> +	par->gdc[VGA_GFX_BIT_MASK] = 0xFF;
> +
> +	base = (yoffset * vxres + (xoffset & ~7)) >> 2;
> +	switch (bpp) {
> +	case 8:
> +		par->crtc[VGA_CRTC_OFFSET] = vxres >> 3;
> +		par->ext_offset = vxres >> 11;
> +		par->pixelpipe_cfg1 = DISPLAY_8BPP_MODE;
> +		par->bitblt_cntl = COLEXP_8BPP;
> +		break;
> +	case 15: /* 0rrrrrgg gggbbbbb */
> +	case 16: /* rrrrrggg gggbbbbb */
> +		par->pixelpipe_cfg1 = (var->green.length = 6) ? DISPLAY_16BPP_MODE : DISPLAY_15BPP_MODE;
> +		par->crtc[VGA_CRTC_OFFSET] = vxres >> 2;
> +		par->ext_offset = vxres >> 10;
> +		par->bitblt_cntl = COLEXP_16BPP;
> +		base *= 2;
> +		break;
> +	case 24:
> +		par->crtc[VGA_CRTC_OFFSET] = (vxres * 3) >> 3;
> +		par->ext_offset = (vxres * 3) >> 11;
> +		par->pixelpipe_cfg1 = DISPLAY_24BPP_MODE;
> +		par->bitblt_cntl = COLEXP_24BPP;
> +		base &= 0xFFFFFFFE; /* ...ignore the last bit. */
> +		base *= 3;
> +		break;
> +	case 32:
> +		par->crtc[VGA_CRTC_OFFSET] = vxres >> 1;
> +		par->ext_offset = vxres >> 9;
> +		par->pixelpipe_cfg1 = DISPLAY_32BPP_MODE;
> +		par->bitblt_cntl = COLEXP_RESERVED; /* Not implemented on i740 */
> +		base *= 4;
> +		break;
> +	}
> +
> +	par->crtc[VGA_CRTC_START_LO] = base & 0x000000FF;
> +	par->crtc[VGA_CRTC_START_HI] = (base & 0x0000FF00) >>  8;
> +	par->ext_start_addr = ((base & 0x003F0000) >> 16) | EXT_START_ADDR_ENABLE;
> +	par->ext_start_addr_hi = (base & 0x3FC00000) >> 22;
> +
> +	par->pixelpipe_cfg0 = DAC_8_BIT;
> +
> +	par->pixelpipe_cfg2 = DISPLAY_GAMMA_ENABLE | OVERLAY_GAMMA_ENABLE;
> +	par->io_cntl = EXTENDED_CRTC_CNTL;
> +	par->address_mapping = LINEAR_MODE_ENABLE | PAGE_MAPPING_ENABLE;
> +	par->display_cntl = HIRES_MODE;
> +
> +	/* Set the MCLK freq */
> +	par->pll_cntl = PLL_MEMCLK_100000KHZ; /* 100 MHz -- use as default */
> +
> +	/* Calculate the extended CRTC regs */
> +	par->ext_vert_total = (ytotal - 2) >> 8;
> +	par->ext_vert_disp_end = (yres - 1) >> 8;
> +	par->ext_vert_sync_start = (yres + lower) >> 8;
> +	par->ext_vert_blank_start = (yres + lower) >> 8;
> +	par->ext_horiz_total = ((xtotal >> 3) - 5) >> 8;
> +	par->ext_horiz_blank = (((xres + right) >> 3) & 0x40) >> 6;
> +
> +	par->interlace_cntl = INTERLACE_DISABLE;
> +
> +	/* Set the overscan color to 0. (NOTE: This only affects >8bpp mode.) */
> +	par->atc[VGA_ATC_OVERSCAN] = 0;
> +
> +	/* Calculate VCLK that most closely matches the requested dot clock */
> +	i740_calc_vclk((((u32)1e9) / var->pixclock) * (u32)(1e3), par);
> +
> +	/* Since we program the clocks ourselves, always use VCLK2. */
> +	par->misc |= 0x0C;
> +
> +	/* Calculate the FIFO Watermark and Burst Length. */
> +	par->lmi_fifo_watermark = i740_calc_fifo(par, ((int)1e6) / var->pixclock, bpp);
> +
> +	/*if (!fbmon_valid_timings(var->pixclock, ytotal, xtotal, info))
> +	return -EINVAL;*/

You shouldn't add dead/inactive code, I think.

> +
> +	return 0;
> +}
> +
> +static int i740fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
> +{
> +	switch (var->bits_per_pixel) {
> +	case 8:
> +		var->red.offset	= var->green.offset = var->blue.offset = 0;
> +		var->red.length	= var->green.length = var->blue.length = 8;
> +		break;
> +	case 16:
> +		switch (var->green.length) {
> +		default:
> +		case 5:
> +			var->red.offset = 10;
> +			var->green.offset = 5;
> +			var->blue.offset = 0;
> +			var->red.length	= var->green.length = var->blue.length = 5;
> +			break;
> +		case 6:
> +			var->red.offset = 11;
> +			var->green.offset = 5;
> +			var->blue.offset = 0;
> +			var->green.length = 6;
> +			var->red.length = var->blue.length = 5;
> +			break;
> +		}
> +		break;
> +	case 24:
> +		var->red.offset = 16;
> +		var->green.offset = 8;
> +		var->blue.offset = 0;
> +		var->red.length	= var->green.length = var->blue.length = 8;
> +		break;
> +	case 32:
> +		var->transp.offset = 24;
> +		var->red.offset = 16;
> +		var->green.offset = 8;
> +		var->blue.offset = 0;
> +		var->transp.length = var->red.length = var->green.length = var->blue.length = 8;
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	if (var->xres > var->xres_virtual)
> +		var->xres_virtual = var->xres;
> +
> +	if (var->yres > var->yres_virtual)
> +		var->yres_virtual = var->yres;
> +
> +	if (info->monspecs.hfmax && info->monspecs.vfmax &&
> +	    info->monspecs.dclkmax && fb_validate_mode(var, info) < 0)
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +static void vga_protect(struct i740fb_par *par)
> +{
> +	i740outreg(par, VGA_SEQ_I, VGA_SEQ_CLOCK_MODE, i740inreg(par, VGA_SEQ_I, VGA_SEQ_CLOCK_MODE) | 0x20);	/* disable the display */

Shouldn't you use i740outreg_mask here?

> +
> +	i740inb(par, 0x3DA);
> +	i740outb(par, VGA_ATT_W, 0x00);	/* enable pallete access */
> +}
> +
> +static void vga_unprotect(struct i740fb_par *par)
> +{
> +	i740outreg(par, VGA_SEQ_I, VGA_SEQ_CLOCK_MODE, i740inreg(par, VGA_SEQ_I, VGA_SEQ_CLOCK_MODE) & 0xDF);	/* reenable display */

Shouldn't you use i740outreg_mask here?

> +
> +	i740inb(par, 0x3DA);
> +	i740outb(par, VGA_ATT_W, 0x20);	/* disable pallete access */
> +}
> +
> +static int i740fb_set_par(struct fb_info *info)
> +{
> +	struct i740fb_par *par = info->par;
> +	u32 itemp;
> +	int i;
> +
> +	i = i740fb_decode_var(&info->var, par, info);
> +	if (i)
> +		return i;
> +
> +	memset(info->screen_base, 0, info->screen_size);
> +
> +	vga_protect(par);
> +
> +	i740outreg(par, XRX, DRAM_EXT_CNTL, DRAM_REFRESH_DISABLE);
> +
> +	mdelay(1);
> +
> +	i740outreg(par, XRX, VCLK2_VCO_M, par->video_clk2_m);
> +	i740outreg(par, XRX, VCLK2_VCO_N, par->video_clk2_n);
> +	i740outreg(par, XRX, VCLK2_VCO_MN_MSBS, par->video_clk2_mn_msbs);
> +	i740outreg(par, XRX, VCLK2_VCO_DIV_SEL, par->video_clk2_div_sel);
> +
> +	i740outreg_mask(par, XRX, PIXPIPE_CONFIG_0, par->pixelpipe_cfg0 & DAC_8_BIT, 0x80);
> +
> +	i740inb(par, 0x3DA);
> +	i740outb(par, 0x3C0, 0x00);
> +
> +	/* update misc output register */
> +	i740outb(par, VGA_MIS_W, par->misc | 0x01);
> +
> +	/* synchronous reset on */
> +	i740outreg(par, VGA_SEQ_I, VGA_SEQ_RESET, 0x01);
> +	/* write sequencer registers */
> +	i740outreg(par, VGA_SEQ_I, VGA_SEQ_CLOCK_MODE, par->seq[VGA_SEQ_CLOCK_MODE] | 0x20);
> +	for (i = 2; i < VGA_SEQ_C; i++)
> +		i740outreg(par, VGA_SEQ_I, i, par->seq[i]);
> +
> +	/* synchronous reset off */
> +	i740outreg(par, VGA_SEQ_I, VGA_SEQ_RESET, 0x03);
> +
> +	/* deprotect CRT registers 0-7 */
> +	i740outreg(par, VGA_CRT_IC, VGA_CRTC_V_SYNC_END, par->crtc[VGA_CRTC_V_SYNC_END]);
> +
> +	/* write CRT registers */
> +	for (i = 0; i < VGA_CRT_C; i++)
> +		i740outreg(par, VGA_CRT_IC, i, par->crtc[i]);
> +
> +	/* write graphics controller registers */
> +	for (i = 0; i < VGA_GFX_C; i++)
> +		i740outreg(par, VGA_GFX_I, i, par->gdc[i]);
> +
> +	/* write attribute controller registers */
> +	for (i = 0; i < VGA_ATT_C; i++) {
> +		i740inb_p(par, VGA_IS1_RC);		/* reset flip-flop */
> +		i740outb_p(par, VGA_ATT_IW, i);
> +		i740outb_p(par, VGA_ATT_IW, par->atc[i]);
> +	}
> +
> +	i740outreg(par, VGA_SEQ_I, VGA_SEQ_CLOCK_MODE, par->seq[VGA_SEQ_CLOCK_MODE]);
> +
> +	i740inb(par, VGA_IS1_RC);
> +	i740outb(par, VGA_ATT_IW, 0x20);
> +
> +	i740outreg(par, VGA_CRT_IC, EXT_VERT_TOTAL, par->ext_vert_total);
> +	i740outreg(par, VGA_CRT_IC, EXT_VERT_DISPLAY, par->ext_vert_disp_end);
> +	i740outreg(par, VGA_CRT_IC, EXT_VERT_SYNC_START, par->ext_vert_sync_start);
> +	i740outreg(par, VGA_CRT_IC, EXT_VERT_BLANK_START, par->ext_vert_blank_start);
> +	i740outreg(par, VGA_CRT_IC, EXT_HORIZ_TOTAL, par->ext_horiz_total);
> +	i740outreg(par, VGA_CRT_IC, EXT_HORIZ_BLANK, par->ext_horiz_blank);
> +	i740outreg(par, VGA_CRT_IC, EXT_OFFSET, par->ext_offset);
> +	i740outreg(par, VGA_CRT_IC, EXT_START_ADDR_HI, par->ext_start_addr_hi);
> +	i740outreg(par, VGA_CRT_IC, EXT_START_ADDR, par->ext_start_addr);
> +
> +	i740outreg_mask(par, VGA_CRT_IC, INTERLACE_CNTL, par->interlace_cntl, INTERLACE_ENABLE);
> +	i740outreg_mask(par, XRX, ADDRESS_MAPPING, par->address_mapping, 0x1F);
> +	i740outreg_mask(par, XRX, BITBLT_CNTL, par->bitblt_cntl, COLEXP_MODE);
> +	i740outreg_mask(par, XRX, DISPLAY_CNTL, par->display_cntl, VGA_WRAP_MODE | GUI_MODE);
> +	i740outreg_mask(par, XRX, PIXPIPE_CONFIG_0, par->pixelpipe_cfg0, 0x9B);
> +	i740outreg_mask(par, XRX, PIXPIPE_CONFIG_2, par->pixelpipe_cfg2, 0x0C);
> +
> +	i740outreg(par, XRX, PLL_CNTL, par->pll_cntl);
> +
> +	i740outreg_mask(par, XRX, PIXPIPE_CONFIG_1, par->pixelpipe_cfg1, DISPLAY_COLOR_MODE);
> +
> +	itemp = readl(par->regs + FWATER_BLC);
> +	itemp &= ~(LMI_BURST_LENGTH | LMI_FIFO_WATERMARK);
> +	itemp |= par->lmi_fifo_watermark;
> +	writel(itemp, par->regs + FWATER_BLC);
> +
> +	i740outreg(par, XRX, DRAM_EXT_CNTL, DRAM_REFRESH_60HZ);
> +
> +	i740outreg_mask(par, MRX, COL_KEY_CNTL_1, 0, BLANK_DISP_OVERLAY);
> +	i740outreg_mask(par, XRX, IO_CTNL, par->io_cntl, EXTENDED_ATTR_CNTL | EXTENDED_CRTC_CNTL);
> +
> +	if (par->pixelpipe_cfg1 != DISPLAY_8BPP_MODE) {
> +		i740outb(par, VGA_PEL_MSK, 0xFF);
> +		i740outb(par, VGA_PEL_IW, 0x00);
> +		for (i = 0; i < 256; i++) {
> +			i740outb_p(par, VGA_PEL_D, (par->pixelpipe_cfg0 & DAC_8_BIT) ? i : i >> 2);
> +			i740outb_p(par, VGA_PEL_D, (par->pixelpipe_cfg0 & DAC_8_BIT) ? i : i >> 2);
> +			i740outb_p(par, VGA_PEL_D, (par->pixelpipe_cfg0 & DAC_8_BIT) ? i : i >> 2);
> +		}
> +	}
> +
> +	/* Wait for screen to stabilize. */
> +	mdelay(50);
> +	vga_unprotect(par);
> +
> +	info->fix.line_length = info->var.xres_virtual * info->var.bits_per_pixel / 8;
> +	if (info->var.bits_per_pixel = 8)
> +		info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
> +	else
> +		info->fix.visual = FB_VISUAL_TRUECOLOR;
> +
> +	return 0;
> +}
> +
> +static int i740fb_setcolreg(unsigned regno, unsigned red, unsigned green,
> +			   unsigned blue, unsigned transp,
> +			   struct fb_info *info)
> +{
> +	dev_dbg(info->device, "setcolreg: regno: %i, red=%d, green=%d, blue=%d, transp=%d, bpp=%d\n", regno, red, green, blue, transp, info->var.bits_per_pixel);
> +
> +	switch (info->var.bits_per_pixel) {
> +	case 8:
> +		if (regno >= 256)
> +			return 1;
> +		i740outb(info->par, VGA_PEL_IW, regno);
> +		i740outb(info->par, VGA_PEL_D, red >> 8);
> +		i740outb(info->par, VGA_PEL_D, green >> 8);
> +		i740outb(info->par, VGA_PEL_D, blue >> 8);
> +		break;
> +	case 15:
> +	case 16:
> +		if (regno >= 16)
> +			return 0;
> +		if (info->var.green.length = 5)
> +			((u32 *)info->pseudo_palette)[regno] = ((red & 0xF800) >> 1) | ((green & 0xF800) >> 6) | ((blue & 0xF800) >> 11);
> +		else if (info->var.green.length = 6)
> +			((u32 *)info->pseudo_palette)[regno] = (red & 0xF800) |	((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11);
> +		else
> +			return -EINVAL;
> +		break;
> +	case 24:
> +	case 32:
> +		if (regno >= 16)
> +			return 0;
> +		((u32 *)info->pseudo_palette)[regno] = ((red & 0xFF00) << 8) | (green & 0xFF00) | ((blue & 0xFF00) >> 8);
> +		break;

You can use the same code for 15, 16, 24, 32 (as you normally should distinguish
whether it is truecolor or pseudocolor) by using the length and offset of red,
green, blue.

> +	default:
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
> +static int i740fb_pan_display(struct fb_var_screeninfo *var,
> +				 struct fb_info *info)
> +{
> +	struct i740fb_par *par = info->par;
> +	u32 base = (var->yoffset * var->xres_virtual + (var->xoffset & ~7)) >> 2;

You shouldn't use xres_virtual of var but info->var for panning. Only the
xoffset and yoffset of var can be expected to be valid.

> +
> +	dev_dbg(info->device, "pan_display: xoffset: %i, yoffset: %i base: %i\n", var->xoffset, var->yoffset, base);
> +
> +	switch (var->bits_per_pixel) {

Again, info->var, please.

> +	case 8:
> +		break;
> +	case 15:
> +	case 16:
> +		base *= 2;
> +		break;
> +	case 24:
> +		/*
> +		 * The last bit does not seem to have any effect on the start
> +		 * address register in 24bpp mode, so...
> +		 */
> +		base &= 0xFFFFFFFE; /* ...ignore the last bit. */
> +		base *= 3;
> +		break;
> +	case 32:
> +		base *= 4;
> +		break;
> +	}
> +
> +	par->crtc[VGA_CRTC_START_LO] = base & 0x000000FF;
> +	par->crtc[VGA_CRTC_START_HI] = (base & 0x0000FF00) >>  8;
> +	par->ext_start_addr_hi = (base & 0x3FC00000) >> 22;
> +	par->ext_start_addr = ((base & 0x003F0000) >> 16) | EXT_START_ADDR_ENABLE;
> +	/*par->atc[VGA_ATC_PEL] = var->xoffset & 7;*/

You shouldn't add dead/inactive code, I think.

> +
> +	i740outreg(par, VGA_CRT_IC, VGA_CRTC_START_LO,  base & 0x000000FF);
> +	i740outreg(par, VGA_CRT_IC, VGA_CRTC_START_HI, (base & 0x0000FF00) >>  8);
> +	i740outreg(par, VGA_CRT_IC, EXT_START_ADDR_HI, (base & 0x3FC00000) >> 22);
> +	i740outreg(par, VGA_CRT_IC, EXT_START_ADDR, ((base & 0x003F0000) >> 16) | EXT_START_ADDR_ENABLE);
> +	/*i740outreg(par, VGA_ATT_W, VGA_ATC_PEL, var->xoffset & 7);*/

You shouldn't add dead/inactive code, I think.

> +
> +	return 0;
> +}
> +
> +static int i740fb_blank(int blank_mode, struct fb_info *info)
> +{
> +	struct i740fb_par *par = info->par;
> +
> +	unsigned char SEQ01;
> +	int DPMSSyncSelect;
> +
> +	switch (blank_mode) {
> +	case FB_BLANK_UNBLANK:
> +	case FB_BLANK_NORMAL:
> +		SEQ01 = 0x00;
> +		DPMSSyncSelect = HSYNC_ON | VSYNC_ON;
> +		break;
> +	case FB_BLANK_VSYNC_SUSPEND:
> +		SEQ01 = 0x20;
> +		DPMSSyncSelect = HSYNC_ON | VSYNC_OFF;
> +		break;
> +	case FB_BLANK_HSYNC_SUSPEND:
> +		SEQ01 = 0x20;
> +		DPMSSyncSelect = HSYNC_OFF | VSYNC_ON;
> +		break;
> +	case FB_BLANK_POWERDOWN:
> +		SEQ01 = 0x20;
> +		DPMSSyncSelect = HSYNC_OFF | VSYNC_OFF;
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +	/* Turn the screen on/off */
> +	i740outb(par, SRX, 0x01);
> +	SEQ01 |= i740inb(par, SRX + 1) & ~0x20;
> +	i740outb(par, SRX, 0x01);
> +	i740outb(par, SRX + 1, SEQ01);
> +
> +	/* Set the DPMS mode */
> +	i740outreg(par, XRX, DPMS_SYNC_SELECT, DPMSSyncSelect);
> +
> +	/* Let fbcon do a soft blank for us */
> +	return (blank_mode = FB_BLANK_NORMAL) ? 1 : 0;
> +}
> +
> +static struct fb_ops i740fb_ops = {
> +	.owner		= THIS_MODULE,
> +	.fb_open	= i740fb_open,
> +	.fb_release	= i740fb_release,
> +	.fb_check_var	= i740fb_check_var,
> +	.fb_set_par	= i740fb_set_par,
> +	.fb_setcolreg	= i740fb_setcolreg,
> +	.fb_blank	= i740fb_blank,
> +	.fb_pan_display	= i740fb_pan_display,
> +	.fb_fillrect	= cfb_fillrect,
> +	.fb_copyarea	= cfb_copyarea,
> +	.fb_imageblit	= cfb_imageblit,
> +};
> +
> +/* ------------------------------------------------------------------------- */
> +
> +static int __devinit i740fb_probe(struct pci_dev *dev,
> +				  const struct pci_device_id *ent)
> +{
> +	struct fb_info *info;
> +	struct i740fb_par *par;
> +	int ret;
> +	bool found = false;
> +	u8 *edid;
> +
> +	info = framebuffer_alloc(sizeof(struct i740fb_par), &(dev->dev));
> +	if (!info) {
> +		dev_err(&(dev->dev), "cannot allocate framebuffer\n");
> +		return -ENOMEM;
> +	}
> +
> +	par = info->par;
> +	mutex_init(&par->open_lock);
> +
> +	info->var.activate = FB_ACTIVATE_NOW;
> +	info->var.bits_per_pixel = 8;
> +	info->fbops = &i740fb_ops;
> +	info->pseudo_palette = par->pseudo_palette;
> +
> +	ret = pci_enable_device(dev);
> +	if (ret) {
> +		dev_err(info->device, "cannot enable PCI device\n");
> +		goto err_enable_device;
> +	}
> +
> +	ret = pci_request_regions(dev, info->fix.id);
> +	if (ret) {
> +		dev_err(info->device, "error requesting regions\n");
> +		goto err_request_regions;
> +	}
> +
> +	info->screen_base = pci_ioremap_bar(dev, 0);
> +	if (!info->screen_base) {
> +		dev_err(info->device, "error remapping base\n");
> +		ret = -ENOMEM;
> +		goto err_ioremap_1;
> +	}
> +
> +	par->regs = pci_ioremap_bar(dev, 1);
> +	if (!par->regs) {
> +		dev_err(info->device, "error remapping MMIO\n");
> +		ret = -ENOMEM;
> +		goto err_ioremap_2;
> +	}
> +
> +	/* detect memory size */
> +	if ((i740inreg(par, XRX, DRAM_ROW_TYPE) & DRAM_ROW_1) = DRAM_ROW_1_SDRAM)
> +		i740outb(par, XRX, DRAM_ROW_BNDRY_1);
> +	else
> +		i740outb(par, XRX, DRAM_ROW_BNDRY_0);
> +	info->screen_size = i740inb(par, XRX + 1) * 1024 * 1024;
> +	/* detect memory type */
> +	par->has_sgram = i740inreg(par, XRX, DRAM_ROW_CNTL_LO);
> +	par->has_sgram = !((par->has_sgram & DRAM_RAS_TIMING) ||
> +			   (par->has_sgram & DRAM_RAS_PRECHARGE));
> +
> +	printk(KERN_INFO "fb%d: Intel740 on %s, %ld KB %s\n", info->node,
> +		pci_name(dev), info->screen_size >> 10,
> +		par->has_sgram ? "SGRAM" : "SDRAM");
> +
> +	info->fix = i740fb_fix;
> +	info->fix.mmio_start = pci_resource_start(dev, 1);
> +	info->fix.mmio_len = pci_resource_len(dev, 1);
> +	info->fix.smem_start = pci_resource_start(dev, 0);
> +	info->fix.smem_len = info->screen_size;
> +	info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
> +
> +	if (i740fb_setup_ddc_bus(info) = 0) {
> +		par->ddc_registered = true;
> +		edid = fb_ddc_read(&par->ddc_adapter);
> +		if (edid) {
> +			fb_edid_to_monspecs(edid, &info->monspecs);
> +			kfree(edid);
> +			if (!info->monspecs.modedb)
> +				dev_err(info->device, "error getting mode database\n");
> +			else {
> +				const struct fb_videomode *m;
> +
> +				fb_videomode_to_modelist(info->monspecs.modedb,
> +							 info->monspecs.modedb_len,
> +							 &info->modelist);
> +				m = fb_find_best_display(&info->monspecs, &info->modelist);
> +				if (m) {
> +					fb_videomode_to_var(&info->var, m);
> +					/* fill all other info->var's fields */
> +					if (i740fb_check_var(&info->var, info) = 0)
> +						found = true;
> +				}
> +			}
> +		}
> +	}
> +
> +	if (!mode_option && !found)
> +		mode_option = "640x480-8@60";
> +
> +	if (mode_option) {
> +		ret = fb_find_mode(&info->var, info, mode_option,
> +				   info->monspecs.modedb, info->monspecs.modedb_len,
> +				   NULL, info->var.bits_per_pixel);
> +		if (!ret || ret = 4) {
> +			dev_err(info->device, "mode %s not found\n", mode_option);
> +			ret = -EINVAL;
> +		}
> +	}
> +
> +	fb_destroy_modedb(info->monspecs.modedb);
> +	info->monspecs.modedb = NULL;
> +
> +	/* maximize virtual vertical size for fast scrolling */
> +	info->var.yres_virtual = info->fix.smem_len * 8 /
> +			(info->var.bits_per_pixel * info->var.xres_virtual);
> +
> +	if (ret = -EINVAL)
> +		goto err_find_mode;
> +
> +	ret = fb_alloc_cmap(&info->cmap, 256, 0);
> +	if (ret) {
> +		dev_err(info->device, "cannot allocate colormap\n");
> +		goto err_alloc_cmap;
> +	}
> +
> +	ret = register_framebuffer(info);
> +	if (ret) {
> +		dev_err(info->device, "error registering framebuffer\n");
> +		goto err_reg_framebuffer;
> +	}
> +
> +	printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, info->fix.id);
> +	pci_set_drvdata(dev, info);
> +#ifdef CONFIG_MTRR
> +	if (mtrr) {
> +		par->mtrr_reg = -1;
> +		par->mtrr_reg = mtrr_add(info->fix.smem_start, info->fix.smem_len, MTRR_TYPE_WRCOMB, 1);
> +	}
> +#endif
> +	return 0;
> +
> +err_reg_framebuffer:
> +	fb_dealloc_cmap(&info->cmap);
> +err_alloc_cmap:
> +err_find_mode:
> +	if (par->ddc_registered)
> +		i2c_del_adapter(&par->ddc_adapter);
> +	pci_iounmap(dev, par->regs);
> +err_ioremap_2:
> +	pci_iounmap(dev, info->screen_base);
> +err_ioremap_1:
> +	pci_release_regions(dev);
> +err_request_regions:
> +/*	pci_disable_device(dev); */
> +err_enable_device:
> +	framebuffer_release(info);
> +	return ret;
> +}
> +
> +static void __devexit i740fb_remove(struct pci_dev *dev)
> +{
> +	struct fb_info *info = pci_get_drvdata(dev);
> +
> +	if (info) {
> +#ifdef CONFIG_MTRR
> +		struct i740fb_par *par = info->par;
> +
> +		if (par->mtrr_reg >= 0) {
> +			mtrr_del(par->mtrr_reg, 0, 0);
> +			par->mtrr_reg = -1;
> +		}
> +#endif
> +		unregister_framebuffer(info);
> +		fb_dealloc_cmap(&info->cmap);
> +		if (par->ddc_registered)
> +			i2c_del_adapter(&par->ddc_adapter);
> +		pci_iounmap(dev, par->regs);
> +		pci_iounmap(dev, info->screen_base);
> +		pci_release_regions(dev);
> +/*		pci_disable_device(dev); */
> +		pci_set_drvdata(dev, NULL);
> +		framebuffer_release(info);
> +	}
> +}
> +
> +#ifdef CONFIG_PM
> +static int i740fb_suspend(struct pci_dev *dev, pm_message_t state)
> +{
> +	struct fb_info *info = pci_get_drvdata(dev);
> +	struct i740fb_par *par = info->par;
> +
> +	/* don't disable console during hibernation and wakeup from it */
> +	if (state.event = PM_EVENT_FREEZE || state.event = PM_EVENT_PRETHAW)
> +		return 0;
> +
> +	console_lock();
> +	mutex_lock(&(par->open_lock));
> +
> +	/* do nothing if framebuffer is not active */
> +	if (par->ref_count = 0) {
> +		mutex_unlock(&(par->open_lock));
> +		console_unlock();
> +		return 0;
> +	}
> +
> +	fb_set_suspend(info, 1);
> +
> +	pci_save_state(dev);
> +	pci_disable_device(dev);
> +	pci_set_power_state(dev, pci_choose_state(dev, state));
> +
> +	mutex_unlock(&(par->open_lock));
> +	console_unlock();
> +
> +	return 0;
> +}
> +
> +static int i740fb_resume(struct pci_dev *dev)
> +{
> +	struct fb_info *info = pci_get_drvdata(dev);
> +	struct i740fb_par *par = info->par;
> +
> +	console_lock();
> +	mutex_lock(&(par->open_lock));
> +
> +	if (par->ref_count = 0)
> +		goto fail;
> +
> +	pci_set_power_state(dev, PCI_D0);
> +	pci_restore_state(dev);
> +	if (pci_enable_device(dev))
> +		goto fail;
> +
> +	i740fb_set_par(info);
> +	fb_set_suspend(info, 0);
> +
> +fail:
> +	mutex_unlock(&(par->open_lock));
> +	console_unlock();
> +	return 0;
> +}
> +#else
> +#define i740fb_suspend NULL
> +#define i740fb_resume NULL
> +#endif /* CONFIG_PM */
> +
> +#define I740_ID_PCI 0x00d1
> +#define I740_ID_AGP 0x7800
> +
> +static DEFINE_PCI_DEVICE_TABLE(i740fb_id_table) = {
> +	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, I740_ID_PCI) },
> +	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, I740_ID_AGP) },
> +	{ 0 }
> +};
> +MODULE_DEVICE_TABLE(pci, i740fb_id_table);
> +
> +static struct pci_driver i740fb_driver = {
> +	.name		= "i740fb",
> +	.id_table	= i740fb_id_table,
> +	.probe		= i740fb_probe,
> +	.remove		= __devexit_p(i740fb_remove),
> +	.suspend	= i740fb_suspend,
> +	.resume		= i740fb_resume,
> +};
> +
> +#ifndef MODULE
> +static int  __init i740fb_setup(char *options)
> +{
> +	char *opt;
> +
> +	if (!options || !*options)
> +		return 0;
> +
> +	while ((opt = strsep(&options, ",")) != NULL) {
> +		if (!*opt)
> +			continue;
> +#ifdef CONFIG_MTRR
> +		else if (!strncmp(opt, "mtrr:", 5))
> +			mtrr = simple_strtoul(opt + 5, NULL, 0);
> +#endif
> +		else
> +			mode_option = opt;
> +	}
> +
> +	return 0;
> +}
> +#endif
> +
> +int __init i740fb_init(void)
> +{
> +#ifndef MODULE
> +	char *option = NULL;
> +
> +	if (fb_get_options("i740fb", &option))
> +		return -ENODEV;
> +	i740fb_setup(option);
> +#endif
> +
> +	return pci_register_driver(&i740fb_driver);
> +}
> +
> +static void __exit i740fb_exit(void)
> +{
> +	pci_unregister_driver(&i740fb_driver);
> +}
> +
> +module_init(i740fb_init);
> +module_exit(i740fb_exit);
> +
> +MODULE_AUTHOR("(c) 2011 Ondrej Zary <linux@rainbow-software.org>");
> +MODULE_LICENSE("GPL");
> +MODULE_DESCRIPTION("fbdev driver for Intel740");
> +
> +module_param(mode_option, charp, 0444);
> +MODULE_PARM_DESC(mode_option, "Default video mode ('640x480-8@60', etc)");
> +
> +#ifdef CONFIG_MTRR
> +module_param(mtrr, int, 0444);
> +MODULE_PARM_DESC(mtrr, "Enable write-combining with MTRR (1=enable, 0=disable, default=1)");
> +#endif
> --- /dev/null	2011-10-28 20:05:27.615214131 +0200
> +++ linux-2.6.39-rc2/drivers/video/i740_reg.h	2011-08-14 23:47:48.000000000 +0200
> @@ -0,0 +1,309 @@
> +/**************************************************************************
> +
> +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
> +All Rights Reserved.
> +
> +Permission is hereby granted, free of charge, to any person obtaining a
> +copy of this software and associated documentation files (the
> +"Software"), to deal in the Software without restriction, including
> +without limitation the rights to use, copy, modify, merge, publish,
> +distribute, sub license, and/or sell copies of the Software, and to
> +permit persons to whom the Software is furnished to do so, subject to
> +the following conditions:
> +
> +The above copyright notice and this permission notice (including the
> +next paragraph) shall be included in all copies or substantial portions
> +of the Software.
> +
> +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
> +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
> +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
> +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
> +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> +
> +**************************************************************************/
> +
> +/*
> + * Authors:
> + *   Kevin E. Martin <kevin@precisioninsight.com>
> + */
> +
> +/* I/O register offsets */
> +#define SRX VGA_SEQ_I
> +#define GRX VGA_GFX_I
> +#define ARX VGA_ATT_IW
> +#define XRX 0x3D6
> +#define MRX 0x3D2
> +
> +/* VGA Color Palette Registers */
> +#define DACMASK		0x3C6
> +#define DACSTATE	0x3C7
> +#define DACRX		0x3C7
> +#define DACWX		0x3C8
> +#define DACDATA		0x3C9
> +
> +/* CRT Controller Registers (CRX) */
> +#define START_ADDR_HI		0x0C
> +#define START_ADDR_LO		0x0D
> +#define VERT_SYNC_END		0x11
> +#define EXT_VERT_TOTAL		0x30
> +#define EXT_VERT_DISPLAY	0x31
> +#define EXT_VERT_SYNC_START	0x32
> +#define EXT_VERT_BLANK_START	0x33
> +#define EXT_HORIZ_TOTAL		0x35
> +#define EXT_HORIZ_BLANK		0x39
> +#define EXT_START_ADDR		0x40
> +#define EXT_START_ADDR_ENABLE	0x80
> +#define EXT_OFFSET		0x41
> +#define EXT_START_ADDR_HI	0x42
> +#define INTERLACE_CNTL		0x70
> +#define INTERLACE_ENABLE	0x80
> +#define INTERLACE_DISABLE	0x00
> +
> +/* Miscellaneous Output Register */
> +#define MSR_R		0x3CC
> +#define MSR_W		0x3C2
> +#define IO_ADDR_SELECT	0x01
> +
> +#define MDA_BASE	0x3B0
> +#define CGA_BASE	0x3D0
> +
> +/* System Configuration Extension Registers (XRX) */
> +#define IO_CTNL		0x09
> +#define EXTENDED_ATTR_CNTL	0x02
> +#define EXTENDED_CRTC_CNTL	0x01
> +
> +#define ADDRESS_MAPPING	0x0A
> +#define PACKED_MODE_ENABLE	0x04
> +#define LINEAR_MODE_ENABLE	0x02
> +#define PAGE_MAPPING_ENABLE	0x01
> +
> +#define BITBLT_CNTL	0x20
> +#define COLEXP_MODE		0x30
> +#define COLEXP_8BPP		0x00
> +#define COLEXP_16BPP		0x10
> +#define COLEXP_24BPP		0x20
> +#define COLEXP_RESERVED		0x30
> +#define CHIP_RESET		0x02
> +#define BITBLT_STATUS		0x01
> +
> +#define DISPLAY_CNTL	0x40
> +#define VGA_WRAP_MODE		0x02
> +#define VGA_WRAP_AT_256KB	0x00
> +#define VGA_NO_WRAP		0x02
> +#define GUI_MODE		0x01
> +#define STANDARD_VGA_MODE	0x00
> +#define HIRES_MODE		0x01
> +
> +#define DRAM_ROW_TYPE	0x50
> +#define DRAM_ROW_0		0x07
> +#define DRAM_ROW_0_SDRAM	0x00
> +#define DRAM_ROW_0_EMPTY	0x07
> +#define DRAM_ROW_1		0x38
> +#define DRAM_ROW_1_SDRAM	0x00
> +#define DRAM_ROW_1_EMPTY	0x38
> +#define DRAM_ROW_CNTL_LO 0x51
> +#define DRAM_CAS_LATENCY	0x10
> +#define DRAM_RAS_TIMING		0x08
> +#define DRAM_RAS_PRECHARGE	0x04
> +#define DRAM_ROW_CNTL_HI 0x52
> +#define DRAM_EXT_CNTL	0x53
> +#define DRAM_REFRESH_RATE	0x03
> +#define DRAM_REFRESH_DISABLE	0x00
> +#define DRAM_REFRESH_60HZ	0x01
> +#define DRAM_REFRESH_FAST_TEST	0x02
> +#define DRAM_REFRESH_RESERVED	0x03
> +#define DRAM_TIMING	0x54
> +#define DRAM_ROW_BNDRY_0 0x55
> +#define DRAM_ROW_BNDRY_1 0x56
> +
> +#define DPMS_SYNC_SELECT 0x61
> +#define VSYNC_CNTL		0x08
> +#define VSYNC_ON		0x00
> +#define VSYNC_OFF		0x08
> +#define HSYNC_CNTL		0x02
> +#define HSYNC_ON		0x00
> +#define HSYNC_OFF		0x02
> +
> +#define PIXPIPE_CONFIG_0 0x80
> +#define DAC_8_BIT		0x80
> +#define DAC_6_BIT		0x00
> +#define HW_CURSOR_ENABLE	0x10
> +#define EXTENDED_PALETTE	0x01
> +
> +#define PIXPIPE_CONFIG_1 0x81
> +#define DISPLAY_COLOR_MODE	0x0F
> +#define DISPLAY_VGA_MODE	0x00
> +#define DISPLAY_8BPP_MODE	0x02
> +#define DISPLAY_15BPP_MODE	0x04
> +#define DISPLAY_16BPP_MODE	0x05
> +#define DISPLAY_24BPP_MODE	0x06
> +#define DISPLAY_32BPP_MODE	0x07
> +
> +#define PIXPIPE_CONFIG_2 0x82
> +#define DISPLAY_GAMMA_ENABLE	0x08
> +#define DISPLAY_GAMMA_DISABLE	0x00
> +#define OVERLAY_GAMMA_ENABLE	0x04
> +#define OVERLAY_GAMMA_DISABLE	0x00
> +
> +#define CURSOR_CONTROL	0xA0
> +#define CURSOR_ORIGIN_SCREEN	0x00
> +#define CURSOR_ORIGIN_DISPLAY	0x10
> +#define CURSOR_MODE		0x07
> +#define CURSOR_MODE_DISABLE	0x00
> +#define CURSOR_MODE_32_4C_AX	0x01
> +#define CURSOR_MODE_128_2C	0x02
> +#define CURSOR_MODE_128_1C	0x03
> +#define CURSOR_MODE_64_3C	0x04
> +#define CURSOR_MODE_64_4C_AX	0x05
> +#define CURSOR_MODE_64_4C	0x06
> +#define CURSOR_MODE_RESERVED	0x07
> +#define CURSOR_BASEADDR_LO 0xA2
> +#define CURSOR_BASEADDR_HI 0xA3
> +#define CURSOR_X_LO	0xA4
> +#define CURSOR_X_HI	0xA5
> +#define CURSOR_X_POS		0x00
> +#define CURSOR_X_NEG		0x80
> +#define CURSOR_Y_LO	0xA6
> +#define CURSOR_Y_HI	0xA7
> +#define CURSOR_Y_POS		0x00
> +#define CURSOR_Y_NEG		0x80
> +
> +#define VCLK2_VCO_M	0xC8
> +#define VCLK2_VCO_N	0xC9
> +#define VCLK2_VCO_MN_MSBS 0xCA
> +#define VCO_N_MSBS		0x30
> +#define VCO_M_MSBS		0x03
> +#define VCLK2_VCO_DIV_SEL 0xCB
> +#define POST_DIV_SELECT		0x70
> +#define POST_DIV_1		0x00
> +#define POST_DIV_2		0x10
> +#define POST_DIV_4		0x20
> +#define POST_DIV_8		0x30
> +#define POST_DIV_16		0x40
> +#define POST_DIV_32		0x50
> +#define VCO_LOOP_DIV_BY_4M	0x00
> +#define VCO_LOOP_DIV_BY_16M	0x04
> +#define REF_CLK_DIV_BY_5	0x02
> +#define REF_DIV_4		0x00
> +#define REF_DIV_1		0x01
> +
> +#define PLL_CNTL	0xCE
> +#define PLL_MEMCLK_SEL		0x03
> +#define PLL_MEMCLK__66667KHZ	0x00
> +#define PLL_MEMCLK__75000KHZ	0x01
> +#define PLL_MEMCLK__88889KHZ	0x02
> +#define PLL_MEMCLK_100000KHZ	0x03
> +
> +/* Multimedia Extension Registers (MRX) */
> +#define ACQ_CNTL_1	0x02
> +#define ACQ_CNTL_2	0x03
> +#define FRAME_CAP_MODE		0x01
> +#define CONT_CAP_MODE		0x00
> +#define SINGLE_CAP_MODE		0x01
> +#define ACQ_CNTL_3	0x04
> +#define COL_KEY_CNTL_1		0x3C
> +#define BLANK_DISP_OVERLAY	0x20
> +
> +/* FIFOs */
> +#define LP_FIFO		0x1000
> +#define HP_FIFO		0x2000
> +#define INSTPNT		0x3040
> +#define LP_FIFO_COUNT	0x3040
> +#define HP_FIFO_COUNT	0x3041
> +
> +/* FIFO Commands */
> +#define CLIENT		0xE0000000
> +#define CLIENT_2D	0x60000000
> +
> +/* Command Parser Mode Register */
> +#define COMPARS		0x3038
> +#define TWO_D_INST_DISABLE		0x08
> +#define THREE_D_INST_DISABLE		0x04
> +#define STATE_VAR_UPDATE_DISABLE	0x02
> +#define PAL_STIP_DISABLE		0x01
> +
> +/* Interrupt Control Registers */
> +#define IER		0x3030
> +#define IIR		0x3032
> +#define IMR		0x3034
> +#define ISR		0x3036
> +#define VMIINTB_EVENT		0x2000
> +#define GPIO4_INT		0x1000
> +#define DISP_FLIP_EVENT		0x0800
> +#define DVD_PORT_DMA		0x0400
> +#define DISP_VBLANK		0x0200
> +#define FIFO_EMPTY_DMA_DONE	0x0100
> +#define INST_PARSER_ERROR	0x0080
> +#define USER_DEFINED		0x0040
> +#define BREAKPOINT		0x0020
> +#define DISP_HORIZ_COUNT	0x0010
> +#define DISP_VSYNC		0x0008
> +#define CAPTURE_HORIZ_COUNT	0x0004
> +#define CAPTURE_VSYNC		0x0002
> +#define THREE_D_PIPE_FLUSHED	0x0001
> +
> +/* FIFO Watermark and Burst Length Control Register */
> +#define FWATER_BLC	0x00006000
> +#define LMI_BURST_LENGTH	0x7F000000
> +#define LMI_FIFO_WATERMARK	0x003F0000
> +#define AGP_BURST_LENGTH	0x00007F00
> +#define AGP_FIFO_WATERMARK	0x0000003F
> +
> +/* BitBLT Registers */
> +#define SRC_DST_PITCH	0x00040000
> +#define DST_PITCH		0x1FFF0000
> +#define SRC_PITCH		0x00001FFF
> +#define COLEXP_BG_COLOR	0x00040004
> +#define COLEXP_FG_COLOR	0x00040008
> +#define MONO_SRC_CNTL	0x0004000C
> +#define MONO_USE_COLEXP		0x00000000
> +#define MONO_USE_SRCEXP		0x08000000
> +#define MONO_DATA_ALIGN		0x07000000
> +#define MONO_BIT_ALIGN		0x01000000
> +#define MONO_BYTE_ALIGN		0x02000000
> +#define MONO_WORD_ALIGN		0x03000000
> +#define MONO_DWORD_ALIGN	0x04000000
> +#define MONO_QWORD_ALIGN	0x05000000
> +#define MONO_SRC_INIT_DSCRD	0x003F0000
> +#define MONO_SRC_RIGHT_CLIP	0x00003F00
> +#define MONO_SRC_LEFT_CLIP	0x0000003F
> +#define BITBLT_CONTROL	0x00040010
> +#define BLTR_STATUS		0x80000000
> +#define DYN_DEPTH		0x03000000
> +#define DYN_DEPTH_8BPP		0x00000000
> +#define DYN_DEPTH_16BPP		0x01000000
> +#define DYN_DEPTH_24BPP		0x02000000
> +#define DYN_DEPTH_32BPP		0x03000000	/* Not implemented on the i740 */
> +#define DYN_DEPTH_ENABLE	0x00800000
> +#define PAT_VERT_ALIGN		0x00700000
> +#define SOLID_PAT_SELECT	0x00080000
> +#define PAT_IS_IN_COLOR		0x00000000
> +#define PAT_IS_MONO		0x00040000
> +#define MONO_PAT_TRANSP		0x00020000
> +#define COLOR_TRANSP_ROP	0x00000000
> +#define COLOR_TRANSP_DST	0x00008000
> +#define COLOR_TRANSP_EQ		0x00000000
> +#define COLOR_TRANSP_NOT_EQ	0x00010000
> +#define COLOR_TRANSP_ENABLE	0x00004000
> +#define MONO_SRC_TRANSP		0x00002000
> +#define SRC_IS_IN_COLOR		0x00000000
> +#define SRC_IS_MONO		0x00001000
> +#define SRC_USE_SRC_ADDR	0x00000000
> +#define SRC_USE_BLTDATA		0x00000400
> +#define BLT_TOP_TO_BOT		0x00000000
> +#define BLT_BOT_TO_TOP		0x00000200
> +#define BLT_LEFT_TO_RIGHT	0x00000000
> +#define BLT_RIGHT_TO_LEFT	0x00000100
> +#define BLT_ROP			0x000000FF
> +#define BLT_PAT_ADDR	0x00040014
> +#define BLT_SRC_ADDR	0x00040018
> +#define BLT_DST_ADDR	0x0004001C
> +#define BLT_DST_H_W	0x00040020
> +#define BLT_DST_HEIGHT		0x1FFF0000
> +#define BLT_DST_WIDTH		0x00001FFF
> +#define SRCEXP_BG_COLOR	0x00040024
> +#define SRCEXP_FG_COLOR	0x00040028
> +#define BLTDATA		0x00050000
> 
> 


Best regards,

Florian Tobias Schandinat

^ permalink raw reply

* Re: [PATCH 1/8] fbdev/amifb: Correct whitespace
From: Florian Tobias Schandinat @ 2011-12-04  0:35 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-fbdev, linux-m68k, linux-kernel
In-Reply-To: <1321908839-11419-1-git-send-email-geert@linux-m68k.org>

Hi Geert,

I applied all 8 patches of this series.


Thanks,

Florian Tobias Schandinat


On 11/21/2011 08:53 PM, Geert Uytterhoeven wrote:
>   - indentation
>   - spacing around binary operators
> 
> No functional changes
> 
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
>  drivers/video/amifb.c | 1186 +++++++++++++++++++++++++------------------------
>  1 files changed, 606 insertions(+), 580 deletions(-)
> 
> diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c
> index 5ea6596..72454c7 100644
> --- a/drivers/video/amifb.c
> +++ b/drivers/video/amifb.c
> @@ -152,10 +152,10 @@
>  
>        - hsstrt:   Start of horizontal synchronization pulse
>        - hsstop:   End of horizontal synchronization pulse
> -      - htotal:   Last value on the line (i.e. line length = htotal+1)
> +      - htotal:   Last value on the line (i.e. line length = htotal + 1)
>        - vsstrt:   Start of vertical synchronization pulse
>        - vsstop:   End of vertical synchronization pulse
> -      - vtotal:   Last line value (i.e. number of lines = vtotal+1)
> +      - vtotal:   Last line value (i.e. number of lines = vtotal + 1)
>        - hcenter:  Start of vertical retrace for interlace
>  
>     You can specify the blanking timings independently. Currently I just set
> @@ -184,7 +184,7 @@
>     clock):
>  
>        - diwstrt_h:   Horizontal start of the visible window
> -      - diwstop_h:   Horizontal stop+1(*) of the visible window
> +      - diwstop_h:   Horizontal stop + 1(*) of the visible window
>        - diwstrt_v:   Vertical start of the visible window
>        - diwstop_v:   Vertical stop of the visible window
>        - ddfstrt:     Horizontal start of display DMA
> @@ -193,7 +193,7 @@
>  
>     Sprite positioning:
>  
> -      - sprstrt_h:   Horizontal start-4 of sprite
> +      - sprstrt_h:   Horizontal start - 4 of sprite
>        - sprstrt_v:   Vertical start of sprite
>  
>     (*) Even Commodore did it wrong in the AGA monitor drivers by not adding 1.
> @@ -212,21 +212,21 @@
>     display parameters. Here's what I found out:
>  
>        - ddfstrt and ddfstop are best aligned to 64 pixels.
> -      - the chipset needs 64+4 horizontal pixels after the DMA start before the
> -        first pixel is output, so diwstrt_h = ddfstrt+64+4 if you want to
> -        display the first pixel on the line too. Increase diwstrt_h for virtual
> -        screen panning.
> +      - the chipset needs 64 + 4 horizontal pixels after the DMA start before
> +	the first pixel is output, so diwstrt_h = ddfstrt + 64 + 4 if you want
> +	to display the first pixel on the line too. Increase diwstrt_h for
> +	virtual screen panning.
>        - the display DMA always fetches 64 pixels at a time (fmode = 3).
> -      - ddfstop is ddfstrt+#pixels-64.
> -      - diwstop_h = diwstrt_h+xres+1. Because of the additional 1 this can be 1
> -        more than htotal.
> +      - ddfstop is ddfstrt+#pixels - 64.
> +      - diwstop_h = diwstrt_h + xres + 1. Because of the additional 1 this can
> +	be 1 more than htotal.
>        - hscroll simply adds a delay to the display output. Smooth horizontal
> -        panning needs an extra 64 pixels on the left to prefetch the pixels that
> -        `fall off' on the left.
> +	panning needs an extra 64 pixels on the left to prefetch the pixels that
> +	`fall off' on the left.
>        - if ddfstrt < 192, the sprite DMA cycles are all stolen by the bitplane
> -        DMA, so it's best to make the DMA start as late as possible.
> +	DMA, so it's best to make the DMA start as late as possible.
>        - you really don't want to make ddfstrt < 128, since this will steal DMA
> -        cycles from the other DMA channels (audio, floppy and Chip RAM refresh).
> +	cycles from the other DMA channels (audio, floppy and Chip RAM refresh).
>        - I make diwstop_h and diwstop_v as large as possible.
>  
>     General dependencies
> @@ -234,8 +234,8 @@
>  
>        - all values are SHRES pixel (35ns)
>  
> -                  table 1:fetchstart  table 2:prefetch    table 3:fetchsize
> -                  ------------------  ----------------    -----------------
> +		  table 1:fetchstart  table 2:prefetch    table 3:fetchsize
> +		  ------------------  ----------------    -----------------
>     Pixclock     # SHRES|HIRES|LORES # SHRES|HIRES|LORES # SHRES|HIRES|LORES
>     -------------#------+-----+------#------+-----+------#------+-----+------
>     Bus width 1x #   16 |  32 |  64  #   16 |  32 |  64  #   64 |  64 |  64
> @@ -245,21 +245,21 @@
>        - chipset needs 4 pixels before the first pixel is output
>        - ddfstrt must be aligned to fetchstart (table 1)
>        - chipset needs also prefetch (table 2) to get first pixel data, so
> -        ddfstrt = ((diwstrt_h-4) & -fetchstart) - prefetch
> +	ddfstrt = ((diwstrt_h - 4) & -fetchstart) - prefetch
>        - for horizontal panning decrease diwstrt_h
>        - the length of a fetchline must be aligned to fetchsize (table 3)
>        - if fetchstart is smaller than fetchsize, then ddfstrt can a little bit
> -        moved to optimize use of dma (useful for OCS/ECS overscan displays)
> -      - ddfstop is ddfstrt+ddfsize-fetchsize
> +	moved to optimize use of dma (useful for OCS/ECS overscan displays)
> +      - ddfstop is ddfstrt + ddfsize - fetchsize
>        - If C= didn't change anything for AGA, then at following positions the
> -        dma bus is already used:
> -        ddfstrt <  48 -> memory refresh
> -                <  96 -> disk dma
> -                < 160 -> audio dma
> -                < 192 -> sprite 0 dma
> -                < 416 -> sprite dma (32 per sprite)
> +	dma bus is already used:
> +	ddfstrt <  48 -> memory refresh
> +		<  96 -> disk dma
> +		< 160 -> audio dma
> +		< 192 -> sprite 0 dma
> +		< 416 -> sprite dma (32 per sprite)
>        - in accordance with the hardware reference manual a hardware stop is at
> -        192, but AGA (ECS?) can go below this.
> +	192, but AGA (ECS?) can go below this.
>  
>     DMA priorities
>     --------------
> @@ -269,7 +269,7 @@
>     the hardware cursor:
>  
>        - if you want to start display DMA too early, you lose the ability to
> -        do smooth horizontal panning (xpanstep 1 -> 64).
> +	do smooth horizontal panning (xpanstep 1 -> 64).
>        - if you want to go even further, you lose the hardware cursor too.
>  
>     IMHO a hardware cursor is more important for X than horizontal scrolling,
> @@ -286,8 +286,8 @@
>     Standard VGA timings
>     --------------------
>  
> -               xres  yres    left  right  upper  lower    hsync    vsync
> -               ----  ----    ----  -----  -----  -----    -----    -----
> +	       xres  yres    left  right  upper  lower    hsync    vsync
> +	       ----  ----    ----  -----  -----  -----    -----    -----
>        80x25     720   400      27     45     35     12      108        2
>        80x30     720   480      27     45     30      9      108        2
>  
> @@ -297,8 +297,8 @@
>  
>     As a comparison, graphics/monitor.h suggests the following:
>  
> -               xres  yres    left  right  upper  lower    hsync    vsync
> -               ----  ----    ----  -----  -----  -----    -----    -----
> +	       xres  yres    left  right  upper  lower    hsync    vsync
> +	       ----  ----    ----  -----  -----  -----    -----    -----
>  
>        VGA       640   480      52    112     24     19    112 -      2 +
>        VGA70     640   400      52    112     27     21    112 -      2 -
> @@ -309,10 +309,10 @@
>  
>        VSYNC    HSYNC    Vertical size    Vertical total
>        -----    -----    -------------    --------------
> -        +        +           Reserved          Reserved
> -        +        -                400               414
> -        -        +                350               362
> -        -        -                480               496
> +	+        +           Reserved          Reserved
> +	+        -                400               414
> +	-        +                350               362
> +	-        -                480               496
>  
>     Source: CL-GD542X Technical Reference Manual, Cirrus Logic, Oct 1992
>  
> @@ -326,33 +326,34 @@
>     -----------
>  
>        - a scanline is 64 µs long, of which 52.48 µs are visible. This is about
> -        736 visible 70 ns pixels per line.
> +	736 visible 70 ns pixels per line.
>        - we have 625 scanlines, of which 575 are visible (interlaced); after
> -        rounding this becomes 576.
> +	rounding this becomes 576.
>  
>     RETMA -> NTSC
>     -------------
>  
>        - a scanline is 63.5 µs long, of which 53.5 µs are visible.  This is about
> -        736 visible 70 ns pixels per line.
> +	736 visible 70 ns pixels per line.
>        - we have 525 scanlines, of which 485 are visible (interlaced); after
> -        rounding this becomes 484.
> +	rounding this becomes 484.
>  
>     Thus if you want a PAL compatible display, you have to do the following:
>  
>        - set the FB_SYNC_BROADCAST flag to indicate that standard broadcast
> -        timings are to be used.
> -      - make sure upper_margin+yres+lower_margin+vsync_len = 625 for an
> -        interlaced, 312 for a non-interlaced and 156 for a doublescanned
> -        display.
> -      - make sure left_margin+xres+right_margin+hsync_len = 1816 for a SHRES,
> -        908 for a HIRES and 454 for a LORES display.
> +	timings are to be used.
> +      - make sure upper_margin + yres + lower_margin + vsync_len = 625 for an
> +	interlaced, 312 for a non-interlaced and 156 for a doublescanned
> +	display.
> +      - make sure left_margin + xres + right_margin + hsync_len = 1816 for a
> +	SHRES, 908 for a HIRES and 454 for a LORES display.
>        - the left visible part begins at 360 (SHRES; HIRES:180, LORES:90),
> -        left_margin+2*hsync_len must be greater or equal.
> +	left_margin + 2 * hsync_len must be greater or equal.
>        - the upper visible part begins at 48 (interlaced; non-interlaced:24,
> -        doublescanned:12), upper_margin+2*vsync_len must be greater or equal.
> +	doublescanned:12), upper_margin + 2 * vsync_len must be greater or
> +	equal.
>        - ami_encode_var() calculates margins with a hsync of 5320 ns and a vsync
> -        of 4 scanlines
> +	of 4 scanlines
>  
>     The settings for a NTSC compatible display are straightforward.
>  
> @@ -361,7 +362,7 @@
>     anything about horizontal/vertical synchronization nor refresh rates.
>  
>  
> -                                                            -- Geert --
> +							    -- Geert --
>  
>  *******************************************************************************/
>  
> @@ -540,45 +541,45 @@ static u_short maxfmode, chipset;
>  	 * Various macros
>  	 */
>  
> -#define up2(v)		(((v)+1) & -2)
> +#define up2(v)		(((v) + 1) & -2)
>  #define down2(v)	((v) & -2)
>  #define div2(v)		((v)>>1)
>  #define mod2(v)		((v) & 1)
>  
> -#define up4(v)		(((v)+3) & -4)
> +#define up4(v)		(((v) + 3) & -4)
>  #define down4(v)	((v) & -4)
> -#define mul4(v)		((v)<<2)
> +#define mul4(v)		((v) << 2)
>  #define div4(v)		((v)>>2)
>  #define mod4(v)		((v) & 3)
>  
> -#define up8(v)		(((v)+7) & -8)
> +#define up8(v)		(((v) + 7) & -8)
>  #define down8(v)	((v) & -8)
>  #define div8(v)		((v)>>3)
>  #define mod8(v)		((v) & 7)
>  
> -#define up16(v)		(((v)+15) & -16)
> +#define up16(v)		(((v) + 15) & -16)
>  #define down16(v)	((v) & -16)
>  #define div16(v)	((v)>>4)
>  #define mod16(v)	((v) & 15)
>  
> -#define up32(v)		(((v)+31) & -32)
> +#define up32(v)		(((v) + 31) & -32)
>  #define down32(v)	((v) & -32)
>  #define div32(v)	((v)>>5)
>  #define mod32(v)	((v) & 31)
>  
> -#define up64(v)		(((v)+63) & -64)
> +#define up64(v)		(((v) + 63) & -64)
>  #define down64(v)	((v) & -64)
>  #define div64(v)	((v)>>6)
>  #define mod64(v)	((v) & 63)
>  
> -#define upx(x,v)	(((v)+(x)-1) & -(x))
> -#define downx(x,v)	((v) & -(x))
> -#define modx(x,v)	((v) & ((x)-1))
> +#define upx(x, v)	(((v) + (x) - 1) & -(x))
> +#define downx(x, v)	((v) & -(x))
> +#define modx(x, v)	((v) & ((x) - 1))
>  
>  /* if x1 is not a constant, this macro won't make real sense :-) */
>  #ifdef __mc68000__
>  #define DIVUL(x1, x2) ({int res; asm("divul %1,%2,%3": "=d" (res): \
> -	"d" (x2), "d" ((long)((x1)/0x100000000ULL)), "0" ((long)(x1))); res;})
> +	"d" (x2), "d" ((long)((x1) / 0x100000000ULL)), "0" ((long)(x1))); res;})
>  #else
>  /* We know a bit about the numbers, so we can do it this way */
>  #define DIVUL(x1, x2) ((((long)((unsigned long long)x1 >> 8) / x2) << 8) + \
> @@ -607,7 +608,7 @@ static u_short maxfmode, chipset;
>  #define VIDEOMEMSIZE_ECS_1M	(393216)  /* ECS (1MB) : max 1024*768*16    */
>  #define VIDEOMEMSIZE_OCS	(262144)  /* OCS       : max ca. 800*600*16 */
>  
> -#define SPRITEMEMSIZE		(64*64/4) /* max 64*64*4 */
> +#define SPRITEMEMSIZE		(64 * 64 / 4) /* max 64*64*4 */
>  #define DUMMYSPRITEMEMSIZE	(8)
>  static u_long spritememory;
>  
> @@ -634,9 +635,9 @@ static u_long min_fstrt = 192;
>  	 * Copper Instructions
>  	 */
>  
> -#define CMOVE(val, reg)		(CUSTOM_OFS(reg)<<16 | (val))
> -#define CMOVE2(val, reg)	((CUSTOM_OFS(reg)+2)<<16 | (val))
> -#define CWAIT(x, y)		(((y) & 0x1fe)<<23 | ((x) & 0x7f0)<<13 | 0x0001fffe)
> +#define CMOVE(val, reg)		(CUSTOM_OFS(reg) << 16 | (val))
> +#define CMOVE2(val, reg)	((CUSTOM_OFS(reg) + 2) << 16 | (val))
> +#define CWAIT(x, y)		(((y) & 0x1fe) << 23 | ((x) & 0x7f0) << 13 | 0x0001fffe)
>  #define CEND			(0xfffffffe)
>  
>  
> @@ -776,11 +777,11 @@ static struct amifb_par {
>  
>  
>  static struct fb_info fb_info = {
> -    .fix = {
> -	.id		= "Amiga ",
> -	.visual		= FB_VISUAL_PSEUDOCOLOR,
> -	.accel		= FB_ACCEL_AMIGABLITT
> -    }
> +	.fix = {
> +		.id		= "Amiga ",
> +		.visual		= FB_VISUAL_PSEUDOCOLOR,
> +		.accel		= FB_ACCEL_AMIGABLITT
> +	}
>  };
>  
>  
> @@ -820,116 +821,123 @@ static u_short is_lace = 0;		/* Screen is laced */
>  
>  static struct fb_videomode ami_modedb[] __initdata = {
>  
> -    /*
> -     *  AmigaOS Video Modes
> -     *
> -     *  If you change these, make sure to update DEFMODE_* as well!
> -     */
> -
> -    {
> -	/* 640x200, 15 kHz, 60 Hz (NTSC) */
> -	"ntsc", 60, 640, 200, TAG_HIRES, 106, 86, 44, 16, 76, 2,
> -	FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x400, 15 kHz, 60 Hz interlaced (NTSC) */
> -	"ntsc-lace", 60, 640, 400, TAG_HIRES, 106, 86, 88, 33, 76, 4,
> -	FB_SYNC_BROADCAST, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x256, 15 kHz, 50 Hz (PAL) */
> -	"pal", 50, 640, 256, TAG_HIRES, 106, 86, 40, 14, 76, 2,
> -	FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x512, 15 kHz, 50 Hz interlaced (PAL) */
> -	"pal-lace", 50, 640, 512, TAG_HIRES, 106, 86, 80, 29, 76, 4,
> -	FB_SYNC_BROADCAST, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x480, 29 kHz, 57 Hz */
> -	"multiscan", 57, 640, 480, TAG_SHRES, 96, 112, 29, 8, 72, 8,
> -	0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x960, 29 kHz, 57 Hz interlaced */
> -	"multiscan-lace", 57, 640, 960, TAG_SHRES, 96, 112, 58, 16, 72, 16,
> -	0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x200, 15 kHz, 72 Hz */
> -	"euro36", 72, 640, 200, TAG_HIRES, 92, 124, 6, 6, 52, 5,
> -	0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x400, 15 kHz, 72 Hz interlaced */
> -	"euro36-lace", 72, 640, 400, TAG_HIRES, 92, 124, 12, 12, 52, 10,
> -	0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x400, 29 kHz, 68 Hz */
> -	"euro72", 68, 640, 400, TAG_SHRES, 164, 92, 9, 9, 80, 8,
> -	0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x800, 29 kHz, 68 Hz interlaced */
> -	"euro72-lace", 68, 640, 800, TAG_SHRES, 164, 92, 18, 18, 80, 16,
> -	0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 800x300, 23 kHz, 70 Hz */
> -	"super72", 70, 800, 300, TAG_SHRES, 212, 140, 10, 11, 80, 7,
> -	0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 800x600, 23 kHz, 70 Hz interlaced */
> -	"super72-lace", 70, 800, 600, TAG_SHRES, 212, 140, 20, 22, 80, 14,
> -	0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x200, 27 kHz, 57 Hz doublescan */
> -	"dblntsc", 57, 640, 200, TAG_SHRES, 196, 124, 18, 17, 80, 4,
> -	0, FB_VMODE_DOUBLE | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x400, 27 kHz, 57 Hz */
> -	"dblntsc-ff", 57, 640, 400, TAG_SHRES, 196, 124, 36, 35, 80, 7,
> -	0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x800, 27 kHz, 57 Hz interlaced */
> -	"dblntsc-lace", 57, 640, 800, TAG_SHRES, 196, 124, 72, 70, 80, 14,
> -	0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x256, 27 kHz, 47 Hz doublescan */
> -	"dblpal", 47, 640, 256, TAG_SHRES, 196, 124, 14, 13, 80, 4,
> -	0, FB_VMODE_DOUBLE | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x512, 27 kHz, 47 Hz */
> -	"dblpal-ff", 47, 640, 512, TAG_SHRES, 196, 124, 28, 27, 80, 7,
> -	0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x1024, 27 kHz, 47 Hz interlaced */
> -	"dblpal-lace", 47, 640, 1024, TAG_SHRES, 196, 124, 56, 54, 80, 14,
> -	0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> -    },
> -
> -    /*
> -     *  VGA Video Modes
> -     */
> -
> -    {
> -	/* 640x480, 31 kHz, 60 Hz (VGA) */
> -	"vga", 60, 640, 480, TAG_SHRES, 64, 96, 30, 9, 112, 2,
> -	0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 640x400, 31 kHz, 70 Hz (VGA) */
> -	"vga70", 70, 640, 400, TAG_SHRES, 64, 96, 35, 12, 112, 2,
> -	FB_SYNC_VERT_HIGH_ACT | FB_SYNC_COMP_HIGH_ACT, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> -    },
> +	/*
> +	 *  AmigaOS Video Modes
> +	 *
> +	 *  If you change these, make sure to update DEFMODE_* as well!
> +	 */
> +
> +	{
> +		/* 640x200, 15 kHz, 60 Hz (NTSC) */
> +		"ntsc", 60, 640, 200, TAG_HIRES, 106, 86, 44, 16, 76, 2,
> +		FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x400, 15 kHz, 60 Hz interlaced (NTSC) */
> +		"ntsc-lace", 60, 640, 400, TAG_HIRES, 106, 86, 88, 33, 76, 4,
> +		FB_SYNC_BROADCAST, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x256, 15 kHz, 50 Hz (PAL) */
> +		"pal", 50, 640, 256, TAG_HIRES, 106, 86, 40, 14, 76, 2,
> +		FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x512, 15 kHz, 50 Hz interlaced (PAL) */
> +		"pal-lace", 50, 640, 512, TAG_HIRES, 106, 86, 80, 29, 76, 4,
> +		FB_SYNC_BROADCAST, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x480, 29 kHz, 57 Hz */
> +		"multiscan", 57, 640, 480, TAG_SHRES, 96, 112, 29, 8, 72, 8,
> +		0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x960, 29 kHz, 57 Hz interlaced */
> +		"multiscan-lace", 57, 640, 960, TAG_SHRES, 96, 112, 58, 16, 72,
> +		16,
> +		0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x200, 15 kHz, 72 Hz */
> +		"euro36", 72, 640, 200, TAG_HIRES, 92, 124, 6, 6, 52, 5,
> +		0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x400, 15 kHz, 72 Hz interlaced */
> +		"euro36-lace", 72, 640, 400, TAG_HIRES, 92, 124, 12, 12, 52,
> +		10,
> +		0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x400, 29 kHz, 68 Hz */
> +		"euro72", 68, 640, 400, TAG_SHRES, 164, 92, 9, 9, 80, 8,
> +		0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x800, 29 kHz, 68 Hz interlaced */
> +		"euro72-lace", 68, 640, 800, TAG_SHRES, 164, 92, 18, 18, 80,
> +		16,
> +		0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 800x300, 23 kHz, 70 Hz */
> +		"super72", 70, 800, 300, TAG_SHRES, 212, 140, 10, 11, 80, 7,
> +		0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 800x600, 23 kHz, 70 Hz interlaced */
> +		"super72-lace", 70, 800, 600, TAG_SHRES, 212, 140, 20, 22, 80,
> +		14,
> +		0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x200, 27 kHz, 57 Hz doublescan */
> +		"dblntsc", 57, 640, 200, TAG_SHRES, 196, 124, 18, 17, 80, 4,
> +		0, FB_VMODE_DOUBLE | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x400, 27 kHz, 57 Hz */
> +		"dblntsc-ff", 57, 640, 400, TAG_SHRES, 196, 124, 36, 35, 80, 7,
> +		0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x800, 27 kHz, 57 Hz interlaced */
> +		"dblntsc-lace", 57, 640, 800, TAG_SHRES, 196, 124, 72, 70, 80,
> +		14,
> +		0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x256, 27 kHz, 47 Hz doublescan */
> +		"dblpal", 47, 640, 256, TAG_SHRES, 196, 124, 14, 13, 80, 4,
> +		0, FB_VMODE_DOUBLE | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x512, 27 kHz, 47 Hz */
> +		"dblpal-ff", 47, 640, 512, TAG_SHRES, 196, 124, 28, 27, 80, 7,
> +		0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x1024, 27 kHz, 47 Hz interlaced */
> +		"dblpal-lace", 47, 640, 1024, TAG_SHRES, 196, 124, 56, 54, 80,
> +		14,
> +		0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
> +	},
> +
> +	/*
> +	 *  VGA Video Modes
> +	 */
> +
> +	{
> +		/* 640x480, 31 kHz, 60 Hz (VGA) */
> +		"vga", 60, 640, 480, TAG_SHRES, 64, 96, 30, 9, 112, 2,
> +		0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 640x400, 31 kHz, 70 Hz (VGA) */
> +		"vga70", 70, 640, 400, TAG_SHRES, 64, 96, 35, 12, 112, 2,
> +		FB_SYNC_VERT_HIGH_ACT | FB_SYNC_COMP_HIGH_ACT,
> +		FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> +	},
>  
>  #if 0
>  
> -    /*
> -     *  A2024 video modes
> -     *  These modes don't work yet because there's no A2024 driver.
> -     */
> -
> -    {
> -	/* 1024x800, 10 Hz */
> -	"a2024-10", 10, 1024, 800, TAG_HIRES, 0, 0, 0, 0, 0, 0,
> -	0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> -    }, {
> -	/* 1024x800, 15 Hz */
> -	"a2024-15", 15, 1024, 800, TAG_HIRES, 0, 0, 0, 0, 0, 0,
> -	0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> -    }
> +	/*
> +	 *  A2024 video modes
> +	 *  These modes don't work yet because there's no A2024 driver.
> +	 */
> +
> +	{
> +		/* 1024x800, 10 Hz */
> +		"a2024-10", 10, 1024, 800, TAG_HIRES, 0, 0, 0, 0, 0, 0,
> +		0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> +	}, {
> +		/* 1024x800, 15 Hz */
> +		"a2024-15", 15, 1024, 800, TAG_HIRES, 0, 0, 0, 0, 0, 0,
> +		0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP
> +	}
>  #endif
>  };
>  
> @@ -992,19 +1000,20 @@ static int amifb_inverse = 0;
>  /* bplcon1 (smooth scrolling) */
>  
>  #define hscroll2hw(hscroll) \
> -	(((hscroll)<<12 & 0x3000) | ((hscroll)<<8 & 0xc300) | \
> -	 ((hscroll)<<4 & 0x0c00) | ((hscroll)<<2 & 0x00f0) | ((hscroll)>>2 & 0x000f))
> +	(((hscroll) << 12 & 0x3000) | ((hscroll) << 8 & 0xc300) | \
> +	 ((hscroll) << 4 & 0x0c00) | ((hscroll) << 2 & 0x00f0) | \
> +	 ((hscroll)>>2 & 0x000f))
>  
>  /* diwstrt/diwstop/diwhigh (visible display window) */
>  
>  #define diwstrt2hw(diwstrt_h, diwstrt_v) \
> -	(((diwstrt_v)<<7 & 0xff00) | ((diwstrt_h)>>2 & 0x00ff))
> +	(((diwstrt_v) << 7 & 0xff00) | ((diwstrt_h)>>2 & 0x00ff))
>  #define diwstop2hw(diwstop_h, diwstop_v) \
> -	(((diwstop_v)<<7 & 0xff00) | ((diwstop_h)>>2 & 0x00ff))
> +	(((diwstop_v) << 7 & 0xff00) | ((diwstop_h)>>2 & 0x00ff))
>  #define diwhigh2hw(diwstrt_h, diwstrt_v, diwstop_h, diwstop_v) \
> -	(((diwstop_h)<<3 & 0x2000) | ((diwstop_h)<<11 & 0x1800) | \
> +	(((diwstop_h) << 3 & 0x2000) | ((diwstop_h) << 11 & 0x1800) | \
>  	 ((diwstop_v)>>1 & 0x0700) | ((diwstrt_h)>>5 & 0x0020) | \
> -	 ((diwstrt_h)<<3 & 0x0018) | ((diwstrt_v)>>9 & 0x0007))
> +	 ((diwstrt_h) << 3 & 0x0018) | ((diwstrt_v)>>9 & 0x0007))
>  
>  /* ddfstrt/ddfstop (display DMA) */
>  
> @@ -1015,38 +1024,39 @@ static int amifb_inverse = 0;
>  
>  #define hsstrt2hw(hsstrt)	(div8(hsstrt))
>  #define hsstop2hw(hsstop)	(div8(hsstop))
> -#define htotal2hw(htotal)	(div8(htotal)-1)
> +#define htotal2hw(htotal)	(div8(htotal) - 1)
>  #define vsstrt2hw(vsstrt)	(div2(vsstrt))
>  #define vsstop2hw(vsstop)	(div2(vsstop))
> -#define vtotal2hw(vtotal)	(div2(vtotal)-1)
> +#define vtotal2hw(vtotal)	(div2(vtotal) - 1)
>  #define hcenter2hw(htotal)	(div8(htotal))
>  
>  /* hbstrt/hbstop/vbstrt/vbstop (blanking timings) */
>  
> -#define hbstrt2hw(hbstrt)	(((hbstrt)<<8 & 0x0700) | ((hbstrt)>>3 & 0x00ff))
> -#define hbstop2hw(hbstop)	(((hbstop)<<8 & 0x0700) | ((hbstop)>>3 & 0x00ff))
> +#define hbstrt2hw(hbstrt)	(((hbstrt) << 8 & 0x0700) | ((hbstrt)>>3 & 0x00ff))
> +#define hbstop2hw(hbstop)	(((hbstop) << 8 & 0x0700) | ((hbstop)>>3 & 0x00ff))
>  #define vbstrt2hw(vbstrt)	(div2(vbstrt))
>  #define vbstop2hw(vbstop)	(div2(vbstop))
>  
>  /* colour */
>  
>  #define rgb2hw8_high(red, green, blue) \
> -	(((red & 0xf0)<<4) | (green & 0xf0) | ((blue & 0xf0)>>4))
> +	(((red & 0xf0) << 4) | (green & 0xf0) | ((blue & 0xf0)>>4))
>  #define rgb2hw8_low(red, green, blue) \
> -	(((red & 0x0f)<<8) | ((green & 0x0f)<<4) | (blue & 0x0f))
> +	(((red & 0x0f) << 8) | ((green & 0x0f) << 4) | (blue & 0x0f))
>  #define rgb2hw4(red, green, blue) \
> -	(((red & 0xf0)<<4) | (green & 0xf0) | ((blue & 0xf0)>>4))
> +	(((red & 0xf0) << 4) | (green & 0xf0) | ((blue & 0xf0)>>4))
>  #define rgb2hw2(red, green, blue) \
> -	(((red & 0xc0)<<4) | (green & 0xc0) | ((blue & 0xc0)>>4))
> +	(((red & 0xc0) << 4) | (green & 0xc0) | ((blue & 0xc0)>>4))
>  
>  /* sprpos/sprctl (sprite positioning) */
>  
>  #define spr2hw_pos(start_v, start_h) \
> -	(((start_v)<<7&0xff00) | ((start_h)>>3&0x00ff))
> +	(((start_v) << 7 & 0xff00) | ((start_h)>>3 & 0x00ff))
>  #define spr2hw_ctl(start_v, start_h, stop_v) \
> -	(((stop_v)<<7&0xff00) | ((start_v)>>4&0x0040) | ((stop_v)>>5&0x0020) | \
> -	 ((start_h)<<3&0x0018) | ((start_v)>>7&0x0004) | ((stop_v)>>8&0x0002) | \
> -	 ((start_h)>>2&0x0001))
> +	(((stop_v) << 7 & 0xff00) | ((start_v)>>4 & 0x0040) | \
> +	 ((stop_v)>>5 & 0x0020) | ((start_h) << 3 & 0x0018) | \
> +	 ((start_v)>>7 & 0x0004) | ((stop_v)>>8 & 0x0002) | \
> +	 ((start_h)>>2 & 0x0001))
>  
>  /* get current vertical position of beam */
>  #define get_vbpos()	((u_short)((*(u_long volatile *)&custom.vposr >> 7) & 0xffe))
> @@ -1055,7 +1065,7 @@ static int amifb_inverse = 0;
>  	 * Copper Initialisation List
>  	 */
>  
> -#define COPINITSIZE (sizeof(copins)*40)
> +#define COPINITSIZE (sizeof(copins) * 40)
>  
>  enum {
>  	cip_bplcon0
> @@ -1066,7 +1076,7 @@ enum {
>  	 * Don't change the order, build_copper()/rebuild_copper() rely on this
>  	 */
>  
> -#define COPLISTSIZE (sizeof(copins)*64)
> +#define COPLISTSIZE (sizeof(copins) * 64)
>  
>  enum {
>  	cop_wait, cop_bplcon0,
> @@ -1152,9 +1162,9 @@ static void chipfree(void);
>  	 */
>  
>  static int ami_decode_var(struct fb_var_screeninfo *var,
> -                          struct amifb_par *par);
> +			  struct amifb_par *par);
>  static int ami_encode_var(struct fb_var_screeninfo *var,
> -                          struct amifb_par *par);
> +			  struct amifb_par *par);
>  static void ami_pan_var(struct fb_var_screeninfo *var);
>  static int ami_update_par(void);
>  static void ami_update_display(void);
> @@ -1238,9 +1248,9 @@ int __init amifb_setup(char *options)
>  		} else if (!strcmp(this_opt, "ilbm"))
>  			amifb_ilbm = 1;
>  		else if (!strncmp(this_opt, "monitorcap:", 11))
> -			amifb_setup_mcap(this_opt+11);
> +			amifb_setup_mcap(this_opt + 11);
>  		else if (!strncmp(this_opt, "fstart:", 7))
> -			min_fstrt = simple_strtoul(this_opt+7, NULL, 0);
> +			min_fstrt = simple_strtoul(this_opt + 7, NULL, 0);
>  		else
>  			mode_option = this_opt;
>  	}
> @@ -1295,20 +1305,20 @@ static int amifb_set_par(struct fb_info *info)
>  		info->fix.type = FB_TYPE_PLANES;
>  		info->fix.type_aux = 0;
>  	}
> -	info->fix.line_length = div8(upx(16<<maxfmode, par->vxres));
> +	info->fix.line_length = div8(upx(16 << maxfmode, par->vxres));
>  
>  	if (par->vmode & FB_VMODE_YWRAP) {
>  		info->fix.ywrapstep = 1;
>  		info->fix.xpanstep = 0;
>  		info->fix.ypanstep = 0;
>  		info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YWRAP |
> -		    FBINFO_READS_FAST; /* override SCROLL_REDRAW */
> +			FBINFO_READS_FAST; /* override SCROLL_REDRAW */
>  	} else {
>  		info->fix.ywrapstep = 0;
>  		if (par->vmode & FB_VMODE_SMOOTH_XPAN)
>  			info->fix.xpanstep = 1;
>  		else
> -			info->fix.xpanstep = 16<<maxfmode;
> +			info->fix.xpanstep = 16 << maxfmode;
>  		info->fix.ypanstep = 1;
>  		info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
>  	}
> @@ -1327,15 +1337,16 @@ static int amifb_pan_display(struct fb_var_screeninfo *var,
>  {
>  	if (var->vmode & FB_VMODE_YWRAP) {
>  		if (var->yoffset < 0 ||
> -		    var->yoffset >= info->var.yres_virtual || var->xoffset)
> -			return -EINVAL;
> +			var->yoffset >= info->var.yres_virtual || var->xoffset)
> +				return -EINVAL;
>  	} else {
>  		/*
>  		 * TODO: There will be problems when xpan!=1, so some columns
>  		 * on the right side will never be seen
>  		 */
> -		if (var->xoffset+info->var.xres > upx(16<<maxfmode, info->var.xres_virtual) ||
> -		    var->yoffset+info->var.yres > info->var.yres_virtual)
> +		if (var->xoffset + info->var.xres >
> +		    upx(16 << maxfmode, info->var.xres_virtual) ||
> +		    var->yoffset + info->var.yres > info->var.yres_virtual)
>  			return -EINVAL;
>  	}
>  	ami_pan_var(var);
> @@ -1360,10 +1371,10 @@ static int amifb_pan_display(struct fb_var_screeninfo *var,
>  #endif
>  
>  
> -    /*
> -     *  Compose two values, using a bitmask as decision value
> -     *  This is equivalent to (a & mask) | (b & ~mask)
> -     */
> +	/*
> +	 *  Compose two values, using a bitmask as decision value
> +	 *  This is equivalent to (a & mask) | (b & ~mask)
> +	 */
>  
>  static inline unsigned long comp(unsigned long a, unsigned long b,
>  				 unsigned long mask)
> @@ -1379,29 +1390,29 @@ static inline unsigned long xor(unsigned long a, unsigned long b,
>  }
>  
>  
> -    /*
> -     *  Unaligned forward bit copy using 32-bit or 64-bit memory accesses
> -     */
> +	/*
> +	 *  Unaligned forward bit copy using 32-bit or 64-bit memory accesses
> +	 */
>  
>  static void bitcpy(unsigned long *dst, int dst_idx, const unsigned long *src,
>  		   int src_idx, u32 n)
>  {
>  	unsigned long first, last;
> -	int shift = dst_idx-src_idx, left, right;
> +	int shift = dst_idx - src_idx, left, right;
>  	unsigned long d0, d1;
>  	int m;
>  
>  	if (!n)
>  		return;
>  
> -	shift = dst_idx-src_idx;
> +	shift = dst_idx - src_idx;
>  	first = ~0UL >> dst_idx;
> -	last = ~(~0UL >> ((dst_idx+n) % BITS_PER_LONG));
> +	last = ~(~0UL >> ((dst_idx + n) % BITS_PER_LONG));
>  
>  	if (!shift) {
>  		// Same alignment for source and dest
>  
> -		if (dst_idx+n <= BITS_PER_LONG) {
> +		if (dst_idx + n <= BITS_PER_LONG) {
>  			// Single word
>  			if (last)
>  				first &= last;
> @@ -1413,7 +1424,7 @@ static void bitcpy(unsigned long *dst, int dst_idx, const unsigned long *src,
>  				*dst = comp(*src, *dst, first);
>  				dst++;
>  				src++;
> -				n -= BITS_PER_LONG-dst_idx;
> +				n -= BITS_PER_LONG - dst_idx;
>  			}
>  
>  			// Main chunk
> @@ -1439,17 +1450,17 @@ static void bitcpy(unsigned long *dst, int dst_idx, const unsigned long *src,
>  	} else {
>  		// Different alignment for source and dest
>  
> -		right = shift & (BITS_PER_LONG-1);
> -		left = -shift & (BITS_PER_LONG-1);
> +		right = shift & (BITS_PER_LONG - 1);
> +		left = -shift & (BITS_PER_LONG - 1);
>  
> -		if (dst_idx+n <= BITS_PER_LONG) {
> +		if (dst_idx + n <= BITS_PER_LONG) {
>  			// Single destination word
>  			if (last)
>  				first &= last;
>  			if (shift > 0) {
>  				// Single source word
>  				*dst = comp(*src >> right, *dst, first);
> -			} else if (src_idx+n <= BITS_PER_LONG) {
> +			} else if (src_idx + n <= BITS_PER_LONG) {
>  				// Single source word
>  				*dst = comp(*src << left, *dst, first);
>  			} else {
> @@ -1467,7 +1478,7 @@ static void bitcpy(unsigned long *dst, int dst_idx, const unsigned long *src,
>  				// Single source word
>  				*dst = comp(d0 >> right, *dst, first);
>  				dst++;
> -				n -= BITS_PER_LONG-dst_idx;
> +				n -= BITS_PER_LONG - dst_idx;
>  			} else {
>  				// 2 source words
>  				d1 = *src++;
> @@ -1475,7 +1486,7 @@ static void bitcpy(unsigned long *dst, int dst_idx, const unsigned long *src,
>  					    first);
>  				d0 = d1;
>  				dst++;
> -				n -= BITS_PER_LONG-dst_idx;
> +				n -= BITS_PER_LONG - dst_idx;
>  			}
>  
>  			// Main chunk
> @@ -1519,40 +1530,40 @@ static void bitcpy(unsigned long *dst, int dst_idx, const unsigned long *src,
>  }
>  
>  
> -    /*
> -     *  Unaligned reverse bit copy using 32-bit or 64-bit memory accesses
> -     */
> +	/*
> +	 *  Unaligned reverse bit copy using 32-bit or 64-bit memory accesses
> +	 */
>  
>  static void bitcpy_rev(unsigned long *dst, int dst_idx,
>  		       const unsigned long *src, int src_idx, u32 n)
>  {
>  	unsigned long first, last;
> -	int shift = dst_idx-src_idx, left, right;
> +	int shift = dst_idx - src_idx, left, right;
>  	unsigned long d0, d1;
>  	int m;
>  
>  	if (!n)
>  		return;
>  
> -	dst += (n-1)/BITS_PER_LONG;
> -	src += (n-1)/BITS_PER_LONG;
> -	if ((n-1) % BITS_PER_LONG) {
> -		dst_idx += (n-1) % BITS_PER_LONG;
> +	dst += (n - 1) / BITS_PER_LONG;
> +	src += (n - 1) / BITS_PER_LONG;
> +	if ((n - 1) % BITS_PER_LONG) {
> +		dst_idx += (n - 1) % BITS_PER_LONG;
>  		dst += dst_idx >> SHIFT_PER_LONG;
> -		dst_idx &= BITS_PER_LONG-1;
> -		src_idx += (n-1) % BITS_PER_LONG;
> +		dst_idx &= BITS_PER_LONG - 1;
> +		src_idx += (n - 1) % BITS_PER_LONG;
>  		src += src_idx >> SHIFT_PER_LONG;
> -		src_idx &= BITS_PER_LONG-1;
> +		src_idx &= BITS_PER_LONG - 1;
>  	}
>  
> -	shift = dst_idx-src_idx;
> -	first = ~0UL << (BITS_PER_LONG-1-dst_idx);
> -	last = ~(~0UL << (BITS_PER_LONG-1-((dst_idx-n) % BITS_PER_LONG)));
> +	shift = dst_idx - src_idx;
> +	first = ~0UL << (BITS_PER_LONG - 1 - dst_idx);
> +	last = ~(~0UL << (BITS_PER_LONG - 1 - ((dst_idx - n) % BITS_PER_LONG)));
>  
>  	if (!shift) {
>  		// Same alignment for source and dest
>  
> -		if ((unsigned long)dst_idx+1 >= n) {
> +		if ((unsigned long)dst_idx + 1 >= n) {
>  			// Single word
>  			if (last)
>  				first &= last;
> @@ -1564,7 +1575,7 @@ static void bitcpy_rev(unsigned long *dst, int dst_idx,
>  				*dst = comp(*src, *dst, first);
>  				dst--;
>  				src--;
> -				n -= dst_idx+1;
> +				n -= dst_idx + 1;
>  			}
>  
>  			// Main chunk
> @@ -1590,17 +1601,17 @@ static void bitcpy_rev(unsigned long *dst, int dst_idx,
>  	} else {
>  		// Different alignment for source and dest
>  
> -		right = shift & (BITS_PER_LONG-1);
> -		left = -shift & (BITS_PER_LONG-1);
> +		right = shift & (BITS_PER_LONG - 1);
> +		left = -shift & (BITS_PER_LONG - 1);
>  
> -		if ((unsigned long)dst_idx+1 >= n) {
> +		if ((unsigned long)dst_idx + 1 >= n) {
>  			// Single destination word
>  			if (last)
>  				first &= last;
>  			if (shift < 0) {
>  				// Single source word
>  				*dst = comp(*src << left, *dst, first);
> -			} else if (1+(unsigned long)src_idx >= n) {
> +			} else if (1 + (unsigned long)src_idx >= n) {
>  				// Single source word
>  				*dst = comp(*src >> right, *dst, first);
>  			} else {
> @@ -1618,7 +1629,7 @@ static void bitcpy_rev(unsigned long *dst, int dst_idx,
>  				// Single source word
>  				*dst = comp(d0 << left, *dst, first);
>  				dst--;
> -				n -= dst_idx+1;
> +				n -= dst_idx + 1;
>  			} else {
>  				// 2 source words
>  				d1 = *src--;
> @@ -1626,7 +1637,7 @@ static void bitcpy_rev(unsigned long *dst, int dst_idx,
>  					    first);
>  				d0 = d1;
>  				dst--;
> -				n -= dst_idx+1;
> +				n -= dst_idx + 1;
>  			}
>  
>  			// Main chunk
> @@ -1670,30 +1681,30 @@ static void bitcpy_rev(unsigned long *dst, int dst_idx,
>  }
>  
>  
> -    /*
> -     *  Unaligned forward inverting bit copy using 32-bit or 64-bit memory
> -     *  accesses
> -     */
> +	/*
> +	 *  Unaligned forward inverting bit copy using 32-bit or 64-bit memory
> +	 *  accesses
> +	 */
>  
>  static void bitcpy_not(unsigned long *dst, int dst_idx,
>  		       const unsigned long *src, int src_idx, u32 n)
>  {
>  	unsigned long first, last;
> -	int shift = dst_idx-src_idx, left, right;
> +	int shift = dst_idx - src_idx, left, right;
>  	unsigned long d0, d1;
>  	int m;
>  
>  	if (!n)
>  		return;
>  
> -	shift = dst_idx-src_idx;
> +	shift = dst_idx - src_idx;
>  	first = ~0UL >> dst_idx;
> -	last = ~(~0UL >> ((dst_idx+n) % BITS_PER_LONG));
> +	last = ~(~0UL >> ((dst_idx + n) % BITS_PER_LONG));
>  
>  	if (!shift) {
>  		// Same alignment for source and dest
>  
> -		if (dst_idx+n <= BITS_PER_LONG) {
> +		if (dst_idx + n <= BITS_PER_LONG) {
>  			// Single word
>  			if (last)
>  				first &= last;
> @@ -1705,7 +1716,7 @@ static void bitcpy_not(unsigned long *dst, int dst_idx,
>  				*dst = comp(~*src, *dst, first);
>  				dst++;
>  				src++;
> -				n -= BITS_PER_LONG-dst_idx;
> +				n -= BITS_PER_LONG - dst_idx;
>  			}
>  
>  			// Main chunk
> @@ -1731,17 +1742,17 @@ static void bitcpy_not(unsigned long *dst, int dst_idx,
>  	} else {
>  		// Different alignment for source and dest
>  
> -		right = shift & (BITS_PER_LONG-1);
> -		left = -shift & (BITS_PER_LONG-1);
> +		right = shift & (BITS_PER_LONG - 1);
> +		left = -shift & (BITS_PER_LONG - 1);
>  
> -		if (dst_idx+n <= BITS_PER_LONG) {
> +		if (dst_idx + n <= BITS_PER_LONG) {
>  			// Single destination word
>  			if (last)
>  				first &= last;
>  			if (shift > 0) {
>  				// Single source word
>  				*dst = comp(~*src >> right, *dst, first);
> -			} else if (src_idx+n <= BITS_PER_LONG) {
> +			} else if (src_idx + n <= BITS_PER_LONG) {
>  				// Single source word
>  				*dst = comp(~*src << left, *dst, first);
>  			} else {
> @@ -1759,7 +1770,7 @@ static void bitcpy_not(unsigned long *dst, int dst_idx,
>  				// Single source word
>  				*dst = comp(d0 >> right, *dst, first);
>  				dst++;
> -				n -= BITS_PER_LONG-dst_idx;
> +				n -= BITS_PER_LONG - dst_idx;
>  			} else {
>  				// 2 source words
>  				d1 = ~*src++;
> @@ -1767,7 +1778,7 @@ static void bitcpy_not(unsigned long *dst, int dst_idx,
>  					    first);
>  				d0 = d1;
>  				dst++;
> -				n -= BITS_PER_LONG-dst_idx;
> +				n -= BITS_PER_LONG - dst_idx;
>  			}
>  
>  			// Main chunk
> @@ -1811,9 +1822,9 @@ static void bitcpy_not(unsigned long *dst, int dst_idx,
>  }
>  
>  
> -    /*
> -     *  Unaligned 32-bit pattern fill using 32/64-bit memory accesses
> -     */
> +	/*
> +	 *  Unaligned 32-bit pattern fill using 32/64-bit memory accesses
> +	 */
>  
>  static void bitfill32(unsigned long *dst, int dst_idx, u32 pat, u32 n)
>  {
> @@ -1828,9 +1839,9 @@ static void bitfill32(unsigned long *dst, int dst_idx, u32 pat, u32 n)
>  #endif
>  
>  	first = ~0UL >> dst_idx;
> -	last = ~(~0UL >> ((dst_idx+n) % BITS_PER_LONG));
> +	last = ~(~0UL >> ((dst_idx + n) % BITS_PER_LONG));
>  
> -	if (dst_idx+n <= BITS_PER_LONG) {
> +	if (dst_idx + n <= BITS_PER_LONG) {
>  		// Single word
>  		if (last)
>  			first &= last;
> @@ -1841,7 +1852,7 @@ static void bitfill32(unsigned long *dst, int dst_idx, u32 pat, u32 n)
>  		if (first) {
>  			*dst = comp(val, *dst, first);
>  			dst++;
> -			n -= BITS_PER_LONG-dst_idx;
> +			n -= BITS_PER_LONG - dst_idx;
>  		}
>  
>  		// Main chunk
> @@ -1867,9 +1878,9 @@ static void bitfill32(unsigned long *dst, int dst_idx, u32 pat, u32 n)
>  }
>  
>  
> -    /*
> -     *  Unaligned 32-bit pattern xor using 32/64-bit memory accesses
> -     */
> +	/*
> +	 *  Unaligned 32-bit pattern xor using 32/64-bit memory accesses
> +	 */
>  
>  static void bitxor32(unsigned long *dst, int dst_idx, u32 pat, u32 n)
>  {
> @@ -1884,9 +1895,9 @@ static void bitxor32(unsigned long *dst, int dst_idx, u32 pat, u32 n)
>  #endif
>  
>  	first = ~0UL >> dst_idx;
> -	last = ~(~0UL >> ((dst_idx+n) % BITS_PER_LONG));
> +	last = ~(~0UL >> ((dst_idx + n) % BITS_PER_LONG));
>  
> -	if (dst_idx+n <= BITS_PER_LONG) {
> +	if (dst_idx + n <= BITS_PER_LONG) {
>  		// Single word
>  		if (last)
>  			first &= last;
> @@ -1897,7 +1908,7 @@ static void bitxor32(unsigned long *dst, int dst_idx, u32 pat, u32 n)
>  		if (first) {
>  			*dst = xor(val, *dst, first);
>  			dst++;
> -			n -= BITS_PER_LONG-dst_idx;
> +			n -= BITS_PER_LONG - dst_idx;
>  		}
>  
>  		// Main chunk
> @@ -1924,12 +1935,12 @@ static inline void fill_one_line(int bpp, unsigned long next_plane,
>  {
>  	while (1) {
>  		dst += dst_idx >> SHIFT_PER_LONG;
> -		dst_idx &= (BITS_PER_LONG-1);
> +		dst_idx &= (BITS_PER_LONG - 1);
>  		bitfill32(dst, dst_idx, color & 1 ? ~0 : 0, n);
>  		if (!--bpp)
>  			break;
>  		color >>= 1;
> -		dst_idx += next_plane*8;
> +		dst_idx += next_plane * 8;
>  	}
>  }
>  
> @@ -1939,12 +1950,12 @@ static inline void xor_one_line(int bpp, unsigned long next_plane,
>  {
>  	while (color) {
>  		dst += dst_idx >> SHIFT_PER_LONG;
> -		dst_idx &= (BITS_PER_LONG-1);
> +		dst_idx &= (BITS_PER_LONG - 1);
>  		bitxor32(dst, dst_idx, color & 1 ? ~0 : 0, n);
>  		if (!--bpp)
>  			break;
>  		color >>= 1;
> -		dst_idx += next_plane*8;
> +		dst_idx += next_plane * 8;
>  	}
>  }
>  
> @@ -1972,23 +1983,23 @@ static void amifb_fillrect(struct fb_info *info,
>  	height = y2 - rect->dy;
>  
>  	dst = (unsigned long *)
> -		((unsigned long)info->screen_base & ~(BYTES_PER_LONG-1));
> -	dst_idx = ((unsigned long)info->screen_base & (BYTES_PER_LONG-1))*8;
> -	dst_idx += rect->dy*par->next_line*8+rect->dx;
> +		((unsigned long)info->screen_base & ~(BYTES_PER_LONG - 1));
> +	dst_idx = ((unsigned long)info->screen_base & (BYTES_PER_LONG - 1)) * 8;
> +	dst_idx += rect->dy * par->next_line * 8 + rect->dx;
>  	while (height--) {
>  		switch (rect->rop) {
> -		    case ROP_COPY:
> +		case ROP_COPY:
>  			fill_one_line(info->var.bits_per_pixel,
>  				      par->next_plane, dst, dst_idx, width,
>  				      rect->color);
>  			break;
>  
> -		    case ROP_XOR:
> +		case ROP_XOR:
>  			xor_one_line(info->var.bits_per_pixel, par->next_plane,
>  				     dst, dst_idx, width, rect->color);
>  			break;
>  		}
> -		dst_idx += par->next_line*8;
> +		dst_idx += par->next_line * 8;
>  	}
>  }
>  
> @@ -1998,14 +2009,14 @@ static inline void copy_one_line(int bpp, unsigned long next_plane,
>  {
>  	while (1) {
>  		dst += dst_idx >> SHIFT_PER_LONG;
> -		dst_idx &= (BITS_PER_LONG-1);
> +		dst_idx &= (BITS_PER_LONG - 1);
>  		src += src_idx >> SHIFT_PER_LONG;
> -		src_idx &= (BITS_PER_LONG-1);
> +		src_idx &= (BITS_PER_LONG - 1);
>  		bitcpy(dst, dst_idx, src, src_idx, n);
>  		if (!--bpp)
>  			break;
> -		dst_idx += next_plane*8;
> -		src_idx += next_plane*8;
> +		dst_idx += next_plane * 8;
> +		src_idx += next_plane * 8;
>  	}
>  }
>  
> @@ -2015,14 +2026,14 @@ static inline void copy_one_line_rev(int bpp, unsigned long next_plane,
>  {
>  	while (1) {
>  		dst += dst_idx >> SHIFT_PER_LONG;
> -		dst_idx &= (BITS_PER_LONG-1);
> +		dst_idx &= (BITS_PER_LONG - 1);
>  		src += src_idx >> SHIFT_PER_LONG;
> -		src_idx &= (BITS_PER_LONG-1);
> +		src_idx &= (BITS_PER_LONG - 1);
>  		bitcpy_rev(dst, dst_idx, src, src_idx, n);
>  		if (!--bpp)
>  			break;
> -		dst_idx += next_plane*8;
> -		src_idx += next_plane*8;
> +		dst_idx += next_plane * 8;
> +		src_idx += next_plane * 8;
>  	}
>  }
>  
> @@ -2065,16 +2076,16 @@ static void amifb_copyarea(struct fb_info *info,
>  		rev_copy = 1;
>  	}
>  	dst = (unsigned long *)
> -		((unsigned long)info->screen_base & ~(BYTES_PER_LONG-1));
> +		((unsigned long)info->screen_base & ~(BYTES_PER_LONG - 1));
>  	src = dst;
> -	dst_idx = ((unsigned long)info->screen_base & (BYTES_PER_LONG-1))*8;
> +	dst_idx = ((unsigned long)info->screen_base & (BYTES_PER_LONG - 1)) * 8;
>  	src_idx = dst_idx;
> -	dst_idx += dy*par->next_line*8+dx;
> -	src_idx += sy*par->next_line*8+sx;
> +	dst_idx += dy * par->next_line * 8 + dx;
> +	src_idx += sy * par->next_line * 8 + sx;
>  	if (rev_copy) {
>  		while (height--) {
> -			dst_idx -= par->next_line*8;
> -			src_idx -= par->next_line*8;
> +			dst_idx -= par->next_line * 8;
> +			src_idx -= par->next_line * 8;
>  			copy_one_line_rev(info->var.bits_per_pixel,
>  					  par->next_plane, dst, dst_idx, src,
>  					  src_idx, width);
> @@ -2084,8 +2095,8 @@ static void amifb_copyarea(struct fb_info *info,
>  			copy_one_line(info->var.bits_per_pixel,
>  				      par->next_plane, dst, dst_idx, src,
>  				      src_idx, width);
> -			dst_idx += par->next_line*8;
> -			src_idx += par->next_line*8;
> +			dst_idx += par->next_line * 8;
> +			src_idx += par->next_line * 8;
>  		}
>  	}
>  }
> @@ -2095,28 +2106,29 @@ static inline void expand_one_line(int bpp, unsigned long next_plane,
>  				   unsigned long *dst, int dst_idx, u32 n,
>  				   const u8 *data, u32 bgcolor, u32 fgcolor)
>  {
> -    const unsigned long *src;
> -    int src_idx;
> -
> -    while (1) {
> -	dst += dst_idx >> SHIFT_PER_LONG;
> -	dst_idx &= (BITS_PER_LONG-1);
> -	if ((bgcolor ^ fgcolor) & 1) {
> -	    src = (unsigned long *)((unsigned long)data & ~(BYTES_PER_LONG-1));
> -	    src_idx = ((unsigned long)data & (BYTES_PER_LONG-1))*8;
> -	    if (fgcolor & 1)
> -		bitcpy(dst, dst_idx, src, src_idx, n);
> -	    else
> -		bitcpy_not(dst, dst_idx, src, src_idx, n);
> -	    /* set or clear */
> -	} else
> -	    bitfill32(dst, dst_idx, fgcolor & 1 ? ~0 : 0, n);
> -	if (!--bpp)
> -	    break;
> -	bgcolor >>= 1;
> -	fgcolor >>= 1;
> -	dst_idx += next_plane*8;
> -    }
> +	const unsigned long *src;
> +	int src_idx;
> +
> +	while (1) {
> +		dst += dst_idx >> SHIFT_PER_LONG;
> +		dst_idx &= (BITS_PER_LONG - 1);
> +		if ((bgcolor ^ fgcolor) & 1) {
> +			src = (unsigned long *)
> +				((unsigned long)data & ~(BYTES_PER_LONG - 1));
> +			src_idx = ((unsigned long)data & (BYTES_PER_LONG - 1)) * 8;
> +			if (fgcolor & 1)
> +				bitcpy(dst, dst_idx, src, src_idx, n);
> +			else
> +				bitcpy_not(dst, dst_idx, src, src_idx, n);
> +			/* set or clear */
> +		} else
> +			bitfill32(dst, dst_idx, fgcolor & 1 ? ~0 : 0, n);
> +		if (!--bpp)
> +			break;
> +		bgcolor >>= 1;
> +		fgcolor >>= 1;
> +		dst_idx += next_plane * 8;
> +	}
>  }
>  
>  
> @@ -2145,17 +2157,17 @@ static void amifb_imageblit(struct fb_info *info, const struct fb_image *image)
>  
>  	if (image->depth = 1) {
>  		dst = (unsigned long *)
> -			((unsigned long)info->screen_base & ~(BYTES_PER_LONG-1));
> -		dst_idx = ((unsigned long)info->screen_base & (BYTES_PER_LONG-1))*8;
> -		dst_idx += dy*par->next_line*8+dx;
> +			((unsigned long)info->screen_base & ~(BYTES_PER_LONG - 1));
> +		dst_idx = ((unsigned long)info->screen_base & (BYTES_PER_LONG - 1)) * 8;
> +		dst_idx += dy * par->next_line * 8 + dx;
>  		src = image->data;
> -		pitch = (image->width+7)/8;
> +		pitch = (image->width + 7) / 8;
>  		while (height--) {
>  			expand_one_line(info->var.bits_per_pixel,
>  					par->next_plane, dst, dst_idx, width,
>  					src, image->bg_color,
>  					image->fg_color);
> -			dst_idx += par->next_line*8;
> +			dst_idx += par->next_line * 8;
>  			src += pitch;
>  		}
>  	} else {
> @@ -2182,39 +2194,38 @@ static int amifb_ioctl(struct fb_info *info,
>  	int i;
>  
>  	switch (cmd) {
> -		case FBIOGET_FCURSORINFO:
> -			i = ami_get_fix_cursorinfo(&crsr.fix);
> -			if (i)
> -				return i;
> -			return copy_to_user(argp, &crsr.fix,
> -					    sizeof(crsr.fix)) ? -EFAULT : 0;
> -
> -		case FBIOGET_VCURSORINFO:
> -			i = ami_get_var_cursorinfo(&crsr.var,
> -				((struct fb_var_cursorinfo __user *)arg)->data);
> -			if (i)
> -				return i;
> -			return copy_to_user(argp, &crsr.var,
> -					    sizeof(crsr.var)) ? -EFAULT : 0;
> -
> -		case FBIOPUT_VCURSORINFO:
> -			if (copy_from_user(&crsr.var, argp, sizeof(crsr.var)))
> -				return -EFAULT;
> -			return ami_set_var_cursorinfo(&crsr.var,
> -				((struct fb_var_cursorinfo __user *)arg)->data);
> -
> -		case FBIOGET_CURSORSTATE:
> -			i = ami_get_cursorstate(&crsr.state);
> -			if (i)
> -				return i;
> -			return copy_to_user(argp, &crsr.state,
> -					    sizeof(crsr.state)) ? -EFAULT : 0;
> -
> -		case FBIOPUT_CURSORSTATE:
> -			if (copy_from_user(&crsr.state, argp,
> -					   sizeof(crsr.state)))
> -				return -EFAULT;
> -			return ami_set_cursorstate(&crsr.state);
> +	case FBIOGET_FCURSORINFO:
> +		i = ami_get_fix_cursorinfo(&crsr.fix);
> +		if (i)
> +			return i;
> +		return copy_to_user(argp, &crsr.fix,
> +				    sizeof(crsr.fix)) ? -EFAULT : 0;
> +
> +	case FBIOGET_VCURSORINFO:
> +		i = ami_get_var_cursorinfo(&crsr.var,
> +			((struct fb_var_cursorinfo __user *)arg)->data);
> +		if (i)
> +			return i;
> +		return copy_to_user(argp, &crsr.var,
> +				    sizeof(crsr.var)) ? -EFAULT : 0;
> +
> +	case FBIOPUT_VCURSORINFO:
> +		if (copy_from_user(&crsr.var, argp, sizeof(crsr.var)))
> +			return -EFAULT;
> +		return ami_set_var_cursorinfo(&crsr.var,
> +			((struct fb_var_cursorinfo __user *)arg)->data);
> +
> +	case FBIOGET_CURSORSTATE:
> +		i = ami_get_cursorstate(&crsr.state);
> +		if (i)
> +			return i;
> +		return copy_to_user(argp, &crsr.state,
> +				    sizeof(crsr.state)) ? -EFAULT : 0;
> +
> +	case FBIOPUT_CURSORSTATE:
> +		if (copy_from_user(&crsr.state, argp, sizeof(crsr.state)))
> +			return -EFAULT;
> +		return ami_set_cursorstate(&crsr.state);
>  	}
>  	return -EINVAL;
>  }
> @@ -2267,69 +2278,68 @@ static int __init amifb_probe(struct platform_device *pdev)
>  
>  	switch (amiga_chipset) {
>  #ifdef CONFIG_FB_AMIGA_OCS
> -		case CS_OCS:
> -			strcat(fb_info.fix.id, "OCS");
> +	case CS_OCS:
> +		strcat(fb_info.fix.id, "OCS");
>  default_chipset:
> -			chipset = TAG_OCS;
> -			maxdepth[TAG_SHRES] = 0;	/* OCS means no SHRES */
> -			maxdepth[TAG_HIRES] = 4;
> -			maxdepth[TAG_LORES] = 6;
> -			maxfmode = TAG_FMODE_1;
> -			defmode = amiga_vblank = 50 ? DEFMODE_PAL
> -						     : DEFMODE_NTSC;
> -			fb_info.fix.smem_len = VIDEOMEMSIZE_OCS;
> -			break;
> +		chipset = TAG_OCS;
> +		maxdepth[TAG_SHRES] = 0;	/* OCS means no SHRES */
> +		maxdepth[TAG_HIRES] = 4;
> +		maxdepth[TAG_LORES] = 6;
> +		maxfmode = TAG_FMODE_1;
> +		defmode = amiga_vblank = 50 ? DEFMODE_PAL : DEFMODE_NTSC;
> +		fb_info.fix.smem_len = VIDEOMEMSIZE_OCS;
> +		break;
>  #endif /* CONFIG_FB_AMIGA_OCS */
>  
>  #ifdef CONFIG_FB_AMIGA_ECS
> -		case CS_ECS:
> -			strcat(fb_info.fix.id, "ECS");
> -			chipset = TAG_ECS;
> -			maxdepth[TAG_SHRES] = 2;
> -			maxdepth[TAG_HIRES] = 4;
> -			maxdepth[TAG_LORES] = 6;
> -			maxfmode = TAG_FMODE_1;
> -			if (AMIGAHW_PRESENT(AMBER_FF))
> -			    defmode = amiga_vblank = 50 ? DEFMODE_AMBER_PAL
> -							 : DEFMODE_AMBER_NTSC;
> -			else
> -			    defmode = amiga_vblank = 50 ? DEFMODE_PAL
> -							 : DEFMODE_NTSC;
> -			if (amiga_chip_avail()-CHIPRAM_SAFETY_LIMIT >
> -			    VIDEOMEMSIZE_ECS_2M)
> -				fb_info.fix.smem_len = VIDEOMEMSIZE_ECS_2M;
> -			else
> -				fb_info.fix.smem_len = VIDEOMEMSIZE_ECS_1M;
> -			break;
> +	case CS_ECS:
> +		strcat(fb_info.fix.id, "ECS");
> +		chipset = TAG_ECS;
> +		maxdepth[TAG_SHRES] = 2;
> +		maxdepth[TAG_HIRES] = 4;
> +		maxdepth[TAG_LORES] = 6;
> +		maxfmode = TAG_FMODE_1;
> +		if (AMIGAHW_PRESENT(AMBER_FF))
> +			defmode = amiga_vblank = 50 ? DEFMODE_AMBER_PAL
> +						     : DEFMODE_AMBER_NTSC;
> +		else
> +			defmode = amiga_vblank = 50 ? DEFMODE_PAL
> +						     : DEFMODE_NTSC;
> +		if (amiga_chip_avail() - CHIPRAM_SAFETY_LIMIT >
> +		    VIDEOMEMSIZE_ECS_2M)
> +			fb_info.fix.smem_len = VIDEOMEMSIZE_ECS_2M;
> +		else
> +			fb_info.fix.smem_len = VIDEOMEMSIZE_ECS_1M;
> +		break;
>  #endif /* CONFIG_FB_AMIGA_ECS */
>  
>  #ifdef CONFIG_FB_AMIGA_AGA
> -		case CS_AGA:
> -			strcat(fb_info.fix.id, "AGA");
> -			chipset = TAG_AGA;
> -			maxdepth[TAG_SHRES] = 8;
> -			maxdepth[TAG_HIRES] = 8;
> -			maxdepth[TAG_LORES] = 8;
> -			maxfmode = TAG_FMODE_4;
> -			defmode = DEFMODE_AGA;
> -			if (amiga_chip_avail()-CHIPRAM_SAFETY_LIMIT >
> -			    VIDEOMEMSIZE_AGA_2M)
> -				fb_info.fix.smem_len = VIDEOMEMSIZE_AGA_2M;
> -			else
> -				fb_info.fix.smem_len = VIDEOMEMSIZE_AGA_1M;
> -			break;
> +	case CS_AGA:
> +		strcat(fb_info.fix.id, "AGA");
> +		chipset = TAG_AGA;
> +		maxdepth[TAG_SHRES] = 8;
> +		maxdepth[TAG_HIRES] = 8;
> +		maxdepth[TAG_LORES] = 8;
> +		maxfmode = TAG_FMODE_4;
> +		defmode = DEFMODE_AGA;
> +		if (amiga_chip_avail() - CHIPRAM_SAFETY_LIMIT >
> +		    VIDEOMEMSIZE_AGA_2M)
> +			fb_info.fix.smem_len = VIDEOMEMSIZE_AGA_2M;
> +		else
> +			fb_info.fix.smem_len = VIDEOMEMSIZE_AGA_1M;
> +		break;
>  #endif /* CONFIG_FB_AMIGA_AGA */
>  
> -		default:
> +	default:
>  #ifdef CONFIG_FB_AMIGA_OCS
> -			printk("Unknown graphics chipset, defaulting to OCS\n");
> -			strcat(fb_info.fix.id, "Unknown");
> -			goto default_chipset;
> +		printk("Unknown graphics chipset, defaulting to OCS\n");
> +		strcat(fb_info.fix.id, "Unknown");
> +		goto default_chipset;
>  #else /* CONFIG_FB_AMIGA_OCS */
> -			err = -ENODEV;
> -			goto amifb_error;
> +		err = -ENODEV;
> +		goto amifb_error;
>  #endif /* CONFIG_FB_AMIGA_OCS */
> -			break;
> +		break;
>  	}
>  
>  	/*
> @@ -2360,10 +2370,10 @@ default_chipset:
>  	 *  These monitor specs are for a typical Amiga monitor (e.g. A1960)
>  	 */
>  	if (fb_info.monspecs.hfmin = 0) {
> -	    fb_info.monspecs.hfmin = 15000;
> -	    fb_info.monspecs.hfmax = 38000;
> -	    fb_info.monspecs.vfmin = 49;
> -	    fb_info.monspecs.vfmax = 90;
> +		fb_info.monspecs.hfmin = 15000;
> +		fb_info.monspecs.hfmax = 38000;
> +		fb_info.monspecs.vfmin = 49;
> +		fb_info.monspecs.vfmax = 90;
>  	}
>  
>  	fb_info.fbops = &amifb_ops;
> @@ -2381,11 +2391,9 @@ default_chipset:
>  				 &fb_info.modelist);
>  
>  	round_down_bpp = 0;
> -	chipptr = chipalloc(fb_info.fix.smem_len+
> -	                    SPRITEMEMSIZE+
> -	                    DUMMYSPRITEMEMSIZE+
> -	                    COPINITSIZE+
> -	                    4*COPLISTSIZE);
> +	chipptr = chipalloc(fb_info.fix.smem_len + SPRITEMEMSIZE +
> +			    DUMMYSPRITEMEMSIZE + COPINITSIZE +
> +			    4 * COPLISTSIZE);
>  	if (!chipptr) {
>  		err = -ENOMEM;
>  		goto amifb_error;
> @@ -2419,7 +2427,7 @@ default_chipset:
>  	 */
>  
>  	custom.dmacon = DMAF_SETCLR | DMAF_MASTER | DMAF_RASTER | DMAF_COPPER |
> -	                DMAF_BLITTER | DMAF_SPRITE;
> +			DMAF_BLITTER | DMAF_SPRITE;
>  
>  	/*
>  	 * Make sure the Copper has something to do
> @@ -2428,12 +2436,12 @@ default_chipset:
>  	ami_init_copper();
>  
>  	if (request_irq(IRQ_AMIGA_COPPER, amifb_interrupt, 0,
> -	                "fb vertb handler", &currentpar)) {
> +			"fb vertb handler", &currentpar)) {
>  		err = -EBUSY;
>  		goto amifb_error;
>  	}
>  
> -	err = fb_alloc_cmap(&fb_info.cmap, 1<<fb_info.var.bits_per_pixel, 0);
> +	err = fb_alloc_cmap(&fb_info.cmap, 1 << fb_info.var.bits_per_pixel, 0);
>  	if (err)
>  		goto amifb_error;
>  
> @@ -2459,7 +2467,7 @@ static void amifb_deinit(struct platform_device *pdev)
>  	fb_dealloc_cmap(&fb_info.cmap);
>  	chipfree();
>  	if (videomemory)
> -		iounmap((void*)videomemory);
> +		iounmap((void *)videomemory);
>  	custom.dmacon = DMAF_ALL | DMAF_MASTER;
>  }
>  
> @@ -2539,7 +2547,7 @@ static irqreturn_t amifb_interrupt(int irq, void *dev_id)
>  	 */
>  
>  static int ami_decode_var(struct fb_var_screeninfo *var,
> -                          struct amifb_par *par)
> +			  struct amifb_par *par)
>  {
>  	u_short clk_shift, line_shift;
>  	u_long maxfetchstop, fstrt, fsize, fconst, xres_n, yres_n;
> @@ -2606,23 +2614,23 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  
>  	par->vmode = var->vmode | FB_VMODE_SMOOTH_XPAN;
>  	switch (par->vmode & FB_VMODE_MASK) {
> -		case FB_VMODE_INTERLACED:
> -			line_shift = 0;
> -			break;
> -		case FB_VMODE_NONINTERLACED:
> -			line_shift = 1;
> -			break;
> -		case FB_VMODE_DOUBLE:
> -			if (!IS_AGA) {
> -				DPRINTK("double mode only possible with aga\n");
> -				return -EINVAL;
> -			}
> -			line_shift = 2;
> -			break;
> -		default:
> -			DPRINTK("unknown video mode\n");
> +	case FB_VMODE_INTERLACED:
> +		line_shift = 0;
> +		break;
> +	case FB_VMODE_NONINTERLACED:
> +		line_shift = 1;
> +		break;
> +	case FB_VMODE_DOUBLE:
> +		if (!IS_AGA) {
> +			DPRINTK("double mode only possible with aga\n");
>  			return -EINVAL;
> -			break;
> +		}
> +		line_shift = 2;
> +		break;
> +	default:
> +		DPRINTK("unknown video mode\n");
> +		return -EINVAL;
> +		break;
>  	}
>  	par->line_shift = line_shift;
>  
> @@ -2630,26 +2638,31 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  	 * Vertical and Horizontal Timings
>  	 */
>  
> -	xres_n = par->xres<<clk_shift;
> -	yres_n = par->yres<<line_shift;
> -	par->htotal = down8((var->left_margin+par->xres+var->right_margin+var->hsync_len)<<clk_shift);
> -	par->vtotal = down2(((var->upper_margin+par->yres+var->lower_margin+var->vsync_len)<<line_shift)+1);
> +	xres_n = par->xres << clk_shift;
> +	yres_n = par->yres << line_shift;
> +	par->htotal = down8((var->left_margin + par->xres + var->right_margin +
> +			     var->hsync_len) << clk_shift);
> +	par->vtotal > +		down2(((var->upper_margin + par->yres + var->lower_margin +
> +			var->vsync_len) << line_shift) + 1);
>  
>  	if (IS_AGA)
>  		par->bplcon3 = sprpixmode[clk_shift];
>  	else
>  		par->bplcon3 = 0;
>  	if (var->sync & FB_SYNC_BROADCAST) {
> -		par->diwstop_h = par->htotal-((var->right_margin-var->hsync_len)<<clk_shift);
> +		par->diwstop_h = par->htotal -
> +			((var->right_margin - var->hsync_len) << clk_shift);
>  		if (IS_AGA)
>  			par->diwstop_h += mod4(var->hsync_len);
>  		else
>  			par->diwstop_h = down4(par->diwstop_h);
>  
>  		par->diwstrt_h = par->diwstop_h - xres_n;
> -		par->diwstop_v = par->vtotal-((var->lower_margin-var->vsync_len)<<line_shift);
> +		par->diwstop_v = par->vtotal -
> +			((var->lower_margin - var->vsync_len) << line_shift);
>  		par->diwstrt_v = par->diwstop_v - yres_n;
> -		if (par->diwstop_h >= par->htotal+8) {
> +		if (par->diwstop_h >= par->htotal + 8) {
>  			DPRINTK("invalid diwstop_h\n");
>  			return -EINVAL;
>  		}
> @@ -2670,7 +2683,7 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  			par->vsstrt = 0;
>  			par->vsstop = 0;
>  		}
> -		if (par->vtotal > (PAL_VTOTAL+NTSC_VTOTAL)/2) {
> +		if (par->vtotal > (PAL_VTOTAL + NTSC_VTOTAL) / 2) {
>  			/* PAL video mode */
>  			if (par->htotal != PAL_HTOTAL) {
>  				DPRINTK("htotal invalid for pal\n");
> @@ -2690,7 +2703,7 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  				par->beamcon0 = BMC0_PAL;
>  				par->bplcon3 |= BPC3_BRDRBLNK;
>  			} else if (AMIGAHW_PRESENT(AGNUS_HR_PAL) ||
> -			           AMIGAHW_PRESENT(AGNUS_HR_NTSC)) {
> +				   AMIGAHW_PRESENT(AGNUS_HR_NTSC)) {
>  				par->beamcon0 = BMC0_PAL;
>  				par->hsstop = 1;
>  			} else if (amiga_vblank != 50) {
> @@ -2720,7 +2733,7 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  				par->beamcon0 = 0;
>  				par->bplcon3 |= BPC3_BRDRBLNK;
>  			} else if (AMIGAHW_PRESENT(AGNUS_HR_PAL) ||
> -			           AMIGAHW_PRESENT(AGNUS_HR_NTSC)) {
> +				   AMIGAHW_PRESENT(AGNUS_HR_NTSC)) {
>  				par->beamcon0 = 0;
>  				par->hsstop = 1;
>  			} else if (amiga_vblank != 60) {
> @@ -2737,8 +2750,8 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  		}
>  	} else if (!IS_OCS) {
>  		/* Programmable video mode */
> -		par->hsstrt = var->right_margin<<clk_shift;
> -		par->hsstop = (var->right_margin+var->hsync_len)<<clk_shift;
> +		par->hsstrt = var->right_margin << clk_shift;
> +		par->hsstop = (var->right_margin + var->hsync_len) << clk_shift;
>  		par->diwstop_h = par->htotal - mod8(par->hsstrt) + 8 - (1 << clk_shift);
>  		if (!IS_AGA)
>  			par->diwstop_h = down4(par->diwstop_h) - 16;
> @@ -2748,8 +2761,8 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  		if (par->hbstrt >= par->htotal + 8)
>  			par->hbstrt -= par->htotal;
>  		par->hcenter = par->hsstrt + (par->htotal >> 1);
> -		par->vsstrt = var->lower_margin<<line_shift;
> -		par->vsstop = (var->lower_margin+var->vsync_len)<<line_shift;
> +		par->vsstrt = var->lower_margin << line_shift;
> +		par->vsstop = (var->lower_margin + var->vsync_len) << line_shift;
>  		par->diwstop_v = par->vtotal;
>  		if ((par->vmode & FB_VMODE_MASK) = FB_VMODE_INTERLACED)
>  			par->diwstop_v -= 2;
> @@ -2766,8 +2779,8 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  		}
>  		par->bplcon3 |= BPC3_EXTBLKEN;
>  		par->beamcon0 = BMC0_HARDDIS | BMC0_VARVBEN | BMC0_LOLDIS |
> -		                BMC0_VARVSYEN | BMC0_VARHSYEN | BMC0_VARBEAMEN |
> -		                BMC0_PAL | BMC0_VARCSYEN;
> +				BMC0_VARVSYEN | BMC0_VARHSYEN | BMC0_VARBEAMEN |
> +				BMC0_PAL | BMC0_VARCSYEN;
>  		if (var->sync & FB_SYNC_HOR_HIGH_ACT)
>  			par->beamcon0 |= BMC0_HSYTRUE;
>  		if (var->sync & FB_SYNC_VERT_HIGH_ACT)
> @@ -2785,7 +2798,7 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  	 * Checking the DMA timing
>  	 */
>  
> -	fconst = 16<<maxfmode<<clk_shift;
> +	fconst = 16 << maxfmode << clk_shift;
>  
>  	/*
>  	 * smallest window start value without turn off other dma cycles
> @@ -2793,8 +2806,8 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  	 */
>  
>  
> -	fsize = ((maxfmode+clk_shift <= 1) ? fconst : 64);
> -	fstrt = downx(fconst, par->diwstrt_h-4) - fsize;
> +	fsize = ((maxfmode + clk_shift <= 1) ? fconst : 64);
> +	fstrt = downx(fconst, par->diwstrt_h - 4) - fsize;
>  	if (fstrt < min_fstrt) {
>  		DPRINTK("fetch start too low\n");
>  		return -EINVAL;
> @@ -2804,14 +2817,16 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  	 * smallest window start value where smooth scrolling is possible
>  	 */
>  
> -	fstrt = downx(fconst, par->diwstrt_h-fconst+(1<<clk_shift)-4) - fsize;
> +	fstrt = downx(fconst, par->diwstrt_h - fconst + (1 << clk_shift) - 4) -
> +		fsize;
>  	if (fstrt < min_fstrt)
>  		par->vmode &= ~FB_VMODE_SMOOTH_XPAN;
>  
>  	maxfetchstop = down16(par->htotal - 80);
>  
> -	fstrt = downx(fconst, par->diwstrt_h-4) - 64 - fconst;
> -	fsize = upx(fconst, xres_n + modx(fconst, downx(1<<clk_shift, par->diwstrt_h-4)));
> +	fstrt = downx(fconst, par->diwstrt_h - 4) - 64 - fconst;
> +	fsize = upx(fconst, xres_n +
> +		    modx(fconst, downx(1 << clk_shift, par->diwstrt_h - 4)));
>  	if (fstrt + fsize > maxfetchstop)
>  		par->vmode &= ~FB_VMODE_SMOOTH_XPAN;
>  
> @@ -2840,7 +2855,7 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  	 * Check if there is enough time to update the bitplane pointers for ywrap
>  	 */
>  
> -	if (par->htotal-fsize-64 < par->bpp*64)
> +	if (par->htotal - fsize - 64 < par->bpp * 64)
>  		par->vmode &= ~FB_VMODE_YWRAP;
>  
>  	/*
> @@ -2848,15 +2863,15 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  	 */
>  
>  	if (amifb_ilbm) {
> -		par->next_plane = div8(upx(16<<maxfmode, par->vxres));
> -		par->next_line = par->bpp*par->next_plane;
> +		par->next_plane = div8(upx(16 << maxfmode, par->vxres));
> +		par->next_line = par->bpp * par->next_plane;
>  		if (par->next_line * par->vyres > fb_info.fix.smem_len) {
>  			DPRINTK("too few video mem\n");
>  			return -EINVAL;
>  		}
>  	} else {
> -		par->next_line = div8(upx(16<<maxfmode, par->vxres));
> -		par->next_plane = par->vyres*par->next_line;
> +		par->next_line = div8(upx(16 << maxfmode, par->vxres));
> +		par->next_plane = par->vyres * par->next_line;
>  		if (par->next_plane * par->bpp > fb_info.fix.smem_len) {
>  			DPRINTK("too few video mem\n");
>  			return -EINVAL;
> @@ -2873,7 +2888,7 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  	if (par->bpp = 8)
>  		par->bplcon0 |= BPC0_BPU3;
>  	else
> -		par->bplcon0 |= par->bpp<<12;
> +		par->bplcon0 |= par->bpp << 12;
>  	if (var->nonstd = FB_NONSTD_HAM)
>  		par->bplcon0 |= BPC0_HAM;
>  	if (var->sync & FB_SYNC_EXT)
> @@ -2883,24 +2898,26 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  		par->fmode = bplfetchmode[maxfmode];
>  
>  	switch (par->vmode & FB_VMODE_MASK) {
> -		case FB_VMODE_INTERLACED:
> -			par->bplcon0 |= BPC0_LACE;
> -			break;
> -		case FB_VMODE_DOUBLE:
> -			if (IS_AGA)
> -				par->fmode |= FMODE_SSCAN2 | FMODE_BSCAN2;
> -			break;
> +	case FB_VMODE_INTERLACED:
> +		par->bplcon0 |= BPC0_LACE;
> +		break;
> +	case FB_VMODE_DOUBLE:
> +		if (IS_AGA)
> +			par->fmode |= FMODE_SSCAN2 | FMODE_BSCAN2;
> +		break;
>  	}
>  
>  	if (!((par->vmode ^ var->vmode) & FB_VMODE_YWRAP)) {
>  		par->xoffset = var->xoffset;
>  		par->yoffset = var->yoffset;
>  		if (par->vmode & FB_VMODE_YWRAP) {
> -			if (par->xoffset || par->yoffset < 0 || par->yoffset >= par->vyres)
> +			if (par->xoffset || par->yoffset < 0 ||
> +			    par->yoffset >= par->vyres)
>  				par->xoffset = par->yoffset = 0;
>  		} else {
> -			if (par->xoffset < 0 || par->xoffset > upx(16<<maxfmode, par->vxres-par->xres) ||
> -			    par->yoffset < 0 || par->yoffset > par->vyres-par->yres)
> +			if (par->xoffset < 0 ||
> +			    par->xoffset > upx(16 << maxfmode, par->vxres - par->xres) ||
> +			    par->yoffset < 0 || par->yoffset > par->vyres - par->yres)
>  				par->xoffset = par->yoffset = 0;
>  		}
>  	} else
> @@ -2919,7 +2936,7 @@ static int ami_decode_var(struct fb_var_screeninfo *var,
>  	 */
>  
>  static int ami_encode_var(struct fb_var_screeninfo *var,
> -                          struct amifb_par *par)
> +			  struct amifb_par *par)
>  {
>  	u_short clk_shift, line_shift;
>  
> @@ -2942,7 +2959,7 @@ static int ami_encode_var(struct fb_var_screeninfo *var,
>  	var->red.msb_right = 0;
>  	var->red.length = par->bpp;
>  	if (par->bplcon0 & BPC0_HAM)
> -	    var->red.length -= 2;
> +		var->red.length -= 2;
>  	var->blue = var->green = var->red;
>  	var->transp.offset = 0;
>  	var->transp.length = 0;
> @@ -2967,10 +2984,10 @@ static int ami_encode_var(struct fb_var_screeninfo *var,
>  		var->vmode = FB_VMODE_NONINTERLACED;
>  
>  	if (!IS_OCS && par->beamcon0 & BMC0_VARBEAMEN) {
> -		var->hsync_len = (par->hsstop-par->hsstrt)>>clk_shift;
> +		var->hsync_len = (par->hsstop - par->hsstrt)>>clk_shift;
>  		var->right_margin = par->hsstrt>>clk_shift;
>  		var->left_margin = (par->htotal>>clk_shift) - var->xres - var->right_margin - var->hsync_len;
> -		var->vsync_len = (par->vsstop-par->vsstrt)>>line_shift;
> +		var->vsync_len = (par->vsstop - par->vsstrt)>>line_shift;
>  		var->lower_margin = par->vsstrt>>line_shift;
>  		var->upper_margin = (par->vtotal>>line_shift) - var->yres - var->lower_margin - var->vsync_len;
>  		var->sync = 0;
> @@ -2988,7 +3005,7 @@ static int ami_encode_var(struct fb_var_screeninfo *var,
>  		var->vsync_len = 4>>line_shift;
>  		var->lower_margin = ((par->vtotal - par->diwstop_v)>>line_shift) + var->vsync_len;
>  		var->upper_margin = (((par->vtotal - 2)>>line_shift) + 1) - var->yres -
> -		                    var->lower_margin - var->vsync_len;
> +				    var->lower_margin - var->vsync_len;
>  	}
>  
>  	if (par->bplcon0 & BPC0_ERSY)
> @@ -3035,14 +3052,14 @@ static int ami_update_par(void)
>  	clk_shift = par->clk_shift;
>  
>  	if (!(par->vmode & FB_VMODE_SMOOTH_XPAN))
> -		par->xoffset = upx(16<<maxfmode, par->xoffset);
> +		par->xoffset = upx(16 << maxfmode, par->xoffset);
>  
> -	fconst = 16<<maxfmode<<clk_shift;
> -	vshift = modx(16<<maxfmode, par->xoffset);
> -	fstrt = par->diwstrt_h - (vshift<<clk_shift) - 4;
> -	fsize = (par->xres+vshift)<<clk_shift;
> +	fconst = 16 << maxfmode << clk_shift;
> +	vshift = modx(16 << maxfmode, par->xoffset);
> +	fstrt = par->diwstrt_h - (vshift << clk_shift) - 4;
> +	fsize = (par->xres + vshift) << clk_shift;
>  	shift = modx(fconst, fstrt);
> -	move = downx(2<<maxfmode, div8(par->xoffset));
> +	move = downx(2 << maxfmode, div8(par->xoffset));
>  	if (maxfmode + clk_shift > 1) {
>  		fstrt = downx(fconst, fstrt) - 64;
>  		fsize = upx(fconst, fsize);
> @@ -3056,7 +3073,7 @@ static int ami_update_par(void)
>  			fstop += min_fstrt - fstrt;
>  			fstrt = min_fstrt;
>  		}
> -		move = move - div8((mod-fstrt)>>clk_shift);
> +		move = move - div8((mod - fstrt)>>clk_shift);
>  	}
>  	mod = par->next_line - div8(fsize>>clk_shift);
>  	par->ddfstrt = fstrt;
> @@ -3071,11 +3088,14 @@ static int ami_update_par(void)
>  		par->bpl1mod = par->bpl2mod;
>  
>  	if (par->yoffset) {
> -		par->bplpt0 = fb_info.fix.smem_start + par->next_line*par->yoffset + move;
> +		par->bplpt0 = fb_info.fix.smem_start +
> +			      par->next_line * par->yoffset + move;
>  		if (par->vmode & FB_VMODE_YWRAP) {
> -			if (par->yoffset > par->vyres-par->yres) {
> +			if (par->yoffset > par->vyres - par->yres) {
>  				par->bplpt0wrap = fb_info.fix.smem_start + move;
> -				if (par->bplcon0 & BPC0_LACE && mod2(par->diwstrt_v+par->vyres-par->yoffset))
> +				if (par->bplcon0 & BPC0_LACE &&
> +				    mod2(par->diwstrt_v + par->vyres -
> +					 par->yoffset))
>  					par->bplpt0wrap += par->next_line;
>  			}
>  		}
> @@ -3096,7 +3116,7 @@ static int ami_update_par(void)
>  	 */
>  
>  static int amifb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
> -                           u_int transp, struct fb_info *info)
> +			   u_int transp, struct fb_info *info)
>  {
>  	if (IS_AGA) {
>  		if (regno > 255)
> @@ -3130,10 +3150,13 @@ static int amifb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
>  		if (IS_AGA) {
>  			u_short bplcon3 = currentpar.bplcon3;
>  			VBlankOff();
> -			custom.bplcon3 = bplcon3 | (regno<<8 & 0xe000);
> -			custom.color[regno&31] = rgb2hw8_high(red, green, blue);
> -			custom.bplcon3 = bplcon3 | (regno<<8 & 0xe000) | BPC3_LOCT;
> -			custom.color[regno&31] = rgb2hw8_low(red, green, blue);
> +			custom.bplcon3 = bplcon3 | (regno << 8 & 0xe000);
> +			custom.color[regno & 31] = rgb2hw8_high(red, green,
> +								blue);
> +			custom.bplcon3 = bplcon3 | (regno << 8 & 0xe000) |
> +					 BPC3_LOCT;
> +			custom.color[regno & 31] = rgb2hw8_low(red, green,
> +							       blue);
>  			custom.bplcon3 = bplcon3;
>  			VBlankOn();
>  		} else
> @@ -3146,11 +3169,11 @@ static int amifb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
>  			mask = 0x3333;
>  			color = rgb2hw2(red, green, blue);
>  			VBlankOff();
> -			for (i = regno+12; i >= (int)regno; i -= 4)
> +			for (i = regno + 12; i >= (int)regno; i -= 4)
>  				custom.color[i] = ecs_palette[i] = (ecs_palette[i] & mask) | color;
> -			mask <<=2; color >>= 2;
> -			regno = down16(regno)+mul4(mod4(regno));
> -			for (i = regno+3; i >= (int)regno; i--)
> +			mask <<= 2; color >>= 2;
> +			regno = down16(regno) + mul4(mod4(regno));
> +			for (i = regno + 3; i >= (int)regno; i--)
>  				custom.color[i] = ecs_palette[i] = (ecs_palette[i] & mask) | color;
>  			VBlankOn();
>  		} else
> @@ -3243,30 +3266,30 @@ static void ami_do_blank(void)
>  		red = green = blue = 0;
>  		if (!IS_OCS && do_blank > 1) {
>  			switch (do_blank) {
> -				case FB_BLANK_VSYNC_SUSPEND:
> -					custom.hsstrt = hsstrt2hw(par->hsstrt);
> -					custom.hsstop = hsstop2hw(par->hsstop);
> -					custom.vsstrt = vsstrt2hw(par->vtotal+4);
> -					custom.vsstop = vsstop2hw(par->vtotal+4);
> -					break;
> -				case FB_BLANK_HSYNC_SUSPEND:
> -					custom.hsstrt = hsstrt2hw(par->htotal+16);
> -					custom.hsstop = hsstop2hw(par->htotal+16);
> -					custom.vsstrt = vsstrt2hw(par->vsstrt);
> -					custom.vsstop = vsstrt2hw(par->vsstop);
> -					break;
> -				case FB_BLANK_POWERDOWN:
> -					custom.hsstrt = hsstrt2hw(par->htotal+16);
> -					custom.hsstop = hsstop2hw(par->htotal+16);
> -					custom.vsstrt = vsstrt2hw(par->vtotal+4);
> -					custom.vsstop = vsstop2hw(par->vtotal+4);
> -					break;
> +			case FB_BLANK_VSYNC_SUSPEND:
> +				custom.hsstrt = hsstrt2hw(par->hsstrt);
> +				custom.hsstop = hsstop2hw(par->hsstop);
> +				custom.vsstrt = vsstrt2hw(par->vtotal + 4);
> +				custom.vsstop = vsstop2hw(par->vtotal + 4);
> +				break;
> +			case FB_BLANK_HSYNC_SUSPEND:
> +				custom.hsstrt = hsstrt2hw(par->htotal + 16);
> +				custom.hsstop = hsstop2hw(par->htotal + 16);
> +				custom.vsstrt = vsstrt2hw(par->vsstrt);
> +				custom.vsstop = vsstrt2hw(par->vsstop);
> +				break;
> +			case FB_BLANK_POWERDOWN:
> +				custom.hsstrt = hsstrt2hw(par->htotal + 16);
> +				custom.hsstop = hsstop2hw(par->htotal + 16);
> +				custom.vsstrt = vsstrt2hw(par->vtotal + 4);
> +				custom.vsstop = vsstop2hw(par->vtotal + 4);
> +				break;
>  			}
>  			if (!(par->beamcon0 & BMC0_VARBEAMEN)) {
>  				custom.htotal = htotal2hw(par->htotal);
>  				custom.vtotal = vtotal2hw(par->vtotal);
>  				custom.beamcon0 = BMC0_HARDDIS | BMC0_VARBEAMEN |
> -				                  BMC0_VARVSYEN | BMC0_VARHSYEN | BMC0_VARCSYEN;
> +						  BMC0_VARVSYEN | BMC0_VARHSYEN | BMC0_VARCSYEN;
>  			}
>  		}
>  	} else {
> @@ -3300,7 +3323,7 @@ static void ami_do_blank(void)
>  		color = rgb2hw2(red, green, blue);
>  		for (i = 12; i >= 0; i -= 4)
>  			custom.color[i] = ecs_palette[i] = (ecs_palette[i] & mask) | color;
> -		mask <<=2; color >>= 2;
> +		mask <<= 2; color >>= 2;
>  		for (i = 3; i >= 0; i--)
>  			custom.color[i] = ecs_palette[i] = (ecs_palette[i] & mask) | color;
>  	} else
> @@ -3334,32 +3357,32 @@ static int ami_get_var_cursorinfo(struct fb_var_cursorinfo *var, u_char __user *
>  	short height, width, bits, words;
>  	int size, alloc;
>  
> -	size = par->crsr.height*par->crsr.width;
> -	alloc = var->height*var->width;
> +	size = par->crsr.height * par->crsr.width;
> +	alloc = var->height * var->width;
>  	var->height = par->crsr.height;
>  	var->width = par->crsr.width;
>  	var->xspot = par->crsr.spot_x;
>  	var->yspot = par->crsr.spot_y;
> -	if (size > var->height*var->width)
> +	if (size > var->height * var->width)
>  		return -ENAMETOOLONG;
>  	if (!access_ok(VERIFY_WRITE, data, size))
>  		return -EFAULT;
> -	delta = 1<<par->crsr.fmode;
> -	lspr = lofsprite + (delta<<1);
> +	delta = 1 << par->crsr.fmode;
> +	lspr = lofsprite + (delta << 1);
>  	if (par->bplcon0 & BPC0_LACE)
> -		sspr = shfsprite + (delta<<1);
> +		sspr = shfsprite + (delta << 1);
>  	else
>  		sspr = NULL;
> -	for (height = (short)var->height-1; height >= 0; height--) {
> +	for (height = (short)var->height - 1; height >= 0; height--) {
>  		bits = 0; words = delta; datawords = 0;
> -		for (width = (short)var->width-1; width >= 0; width--) {
> +		for (width = (short)var->width - 1; width >= 0; width--) {
>  			if (bits = 0) {
>  				bits = 16; --words;
>  #ifdef __mc68000__
>  				asm volatile ("movew %1@(%3:w:2),%0 ; swap %0 ; movew %1@+,%0"
>  					: "=d" (datawords), "=a" (lspr) : "1" (lspr), "d" (delta));
>  #else
> -				datawords = (*(lspr+delta) << 16) | (*lspr++);
> +				datawords = (*(lspr + delta) << 16) | (*lspr++);
>  #endif
>  			}
>  			--bits;
> @@ -3422,26 +3445,26 @@ static int ami_set_var_cursorinfo(struct fb_var_cursorinfo *var, u_char __user *
>  		return -EINVAL;
>  	if (!var->height)
>  		return -EINVAL;
> -	if (!access_ok(VERIFY_READ, data, var->width*var->height))
> +	if (!access_ok(VERIFY_READ, data, var->width * var->height))
>  		return -EFAULT;
> -	delta = 1<<fmode;
> +	delta = 1 << fmode;
>  	lofsprite = shfsprite = (u_short *)spritememory;
> -	lspr = lofsprite + (delta<<1);
> +	lspr = lofsprite + (delta << 1);
>  	if (par->bplcon0 & BPC0_LACE) {
> -		if (((var->height+4)<<fmode<<2) > SPRITEMEMSIZE)
> +		if (((var->height + 4) << fmode << 2) > SPRITEMEMSIZE)
>  			return -EINVAL;
> -		memset(lspr, 0, (var->height+4)<<fmode<<2);
> -		shfsprite += ((var->height+5)&-2)<<fmode;
> -		sspr = shfsprite + (delta<<1);
> +		memset(lspr, 0, (var->height + 4) << fmode << 2);
> +		shfsprite += ((var->height + 5)&-2) << fmode;
> +		sspr = shfsprite + (delta << 1);
>  	} else {
> -		if (((var->height+2)<<fmode<<2) > SPRITEMEMSIZE)
> +		if (((var->height + 2) << fmode << 2) > SPRITEMEMSIZE)
>  			return -EINVAL;
> -		memset(lspr, 0, (var->height+2)<<fmode<<2);
> +		memset(lspr, 0, (var->height + 2) << fmode << 2);
>  		sspr = NULL;
>  	}
> -	for (height = (short)var->height-1; height >= 0; height--) {
> +	for (height = (short)var->height - 1; height >= 0; height--) {
>  		bits = 16; words = delta; datawords = 0;
> -		for (width = (short)var->width-1; width >= 0; width--) {
> +		for (width = (short)var->width - 1; width >= 0; width--) {
>  			unsigned long tdata = 0;
>  			get_user(tdata, data);
>  			data++;
> @@ -3454,7 +3477,7 @@ static int ami_set_var_cursorinfo(struct fb_var_cursorinfo *var, u_char __user *
>  #else
>  			datawords = ((datawords << 1) & 0xfffefffe);
>  			datawords |= tdata & 1;
> -			datawords |= (tdata & 2) << (16-1);
> +			datawords |= (tdata & 2) << (16 - 1);
>  #endif
>  			if (--bits = 0) {
>  				bits = 16; --words;
> @@ -3462,7 +3485,7 @@ static int ami_set_var_cursorinfo(struct fb_var_cursorinfo *var, u_char __user *
>  				asm volatile ("swap %2 ; movew %2,%0@(%3:w:2) ; swap %2 ; movew %2,%0@+"
>  					: "=a" (lspr) : "0" (lspr), "d" (datawords), "d" (delta));
>  #else
> -				*(lspr+delta) = (u_short) (datawords >> 16);
> +				*(lspr + delta) = (u_short) (datawords >> 16);
>  				*lspr++ = (u_short) (datawords & 0xffff);
>  #endif
>  			}
> @@ -3475,7 +3498,7 @@ static int ami_set_var_cursorinfo(struct fb_var_cursorinfo *var, u_char __user *
>  				"swap %2 ; lslw %4,%2 ; movew %2,%0@+"
>  				: "=a" (lspr) : "0" (lspr), "d" (datawords), "d" (delta), "d" (bits));
>  #else
> -			*(lspr+delta) = (u_short) (datawords >> (16+bits));
> +			*(lspr + delta) = (u_short) (datawords >> (16 + bits));
>  			*lspr++ = (u_short) ((datawords & 0x0000ffff) >> bits);
>  #endif
>  		}
> @@ -3484,7 +3507,7 @@ static int ami_set_var_cursorinfo(struct fb_var_cursorinfo *var, u_char __user *
>  			asm volatile ("moveql #0,%%d0 ; movew %%d0,%0@(%2:w:2) ; movew %%d0,%0@+"
>  				: "=a" (lspr) : "0" (lspr), "d" (delta) : "d0");
>  #else
> -			*(lspr+delta) = 0;
> +			*(lspr + delta) = 0;
>  			*lspr++ = 0;
>  #endif
>  		}
> @@ -3546,8 +3569,8 @@ static void ami_set_sprite(void)
>  	cops = copdisplay.list[currentcop][0];
>  	copl = copdisplay.list[currentcop][1];
>  	ps = pl = ZTWO_PADDR(dummysprite);
> -	mx = par->crsr.crsr_x-par->crsr.spot_x;
> -	my = par->crsr.crsr_y-par->crsr.spot_y;
> +	mx = par->crsr.crsr_x - par->crsr.spot_x;
> +	my = par->crsr.crsr_y - par->crsr.spot_y;
>  	if (!(par->vmode & FB_VMODE_YWRAP)) {
>  		mx -= par->xoffset;
>  		my -= par->yoffset;
> @@ -3556,24 +3579,24 @@ static void ami_set_sprite(void)
>  	    mx > -(short)par->crsr.width && mx < par->xres &&
>  	    my > -(short)par->crsr.height && my < par->yres) {
>  		pl = ZTWO_PADDR(lofsprite);
> -		hs = par->diwstrt_h + (mx<<par->clk_shift) - 4;
> -		vs = par->diwstrt_v + (my<<par->line_shift);
> -		ve = vs + (par->crsr.height<<par->line_shift);
> +		hs = par->diwstrt_h + (mx << par->clk_shift) - 4;
> +		vs = par->diwstrt_v + (my << par->line_shift);
> +		ve = vs + (par->crsr.height << par->line_shift);
>  		if (par->bplcon0 & BPC0_LACE) {
>  			ps = ZTWO_PADDR(shfsprite);
>  			lofsprite[0] = spr2hw_pos(vs, hs);
> -			shfsprite[0] = spr2hw_pos(vs+1, hs);
> +			shfsprite[0] = spr2hw_pos(vs + 1, hs);
>  			if (mod2(vs)) {
> -				lofsprite[1<<par->crsr.fmode] = spr2hw_ctl(vs, hs, ve);
> -				shfsprite[1<<par->crsr.fmode] = spr2hw_ctl(vs+1, hs, ve+1);
> +				lofsprite[1 << par->crsr.fmode] = spr2hw_ctl(vs, hs, ve);
> +				shfsprite[1 << par->crsr.fmode] = spr2hw_ctl(vs + 1, hs, ve + 1);
>  				pt = pl; pl = ps; ps = pt;
>  			} else {
> -				lofsprite[1<<par->crsr.fmode] = spr2hw_ctl(vs, hs, ve+1);
> -				shfsprite[1<<par->crsr.fmode] = spr2hw_ctl(vs+1, hs, ve);
> +				lofsprite[1 << par->crsr.fmode] = spr2hw_ctl(vs, hs, ve + 1);
> +				shfsprite[1 << par->crsr.fmode] = spr2hw_ctl(vs + 1, hs, ve);
>  			}
>  		} else {
>  			lofsprite[0] = spr2hw_pos(vs, hs) | (IS_AGA && (par->fmode & FMODE_BSCAN2) ? 0x80 : 0);
> -			lofsprite[1<<par->crsr.fmode] = spr2hw_ctl(vs, hs, ve);
> +			lofsprite[1 << par->crsr.fmode] = spr2hw_ctl(vs, hs, ve);
>  		}
>  	}
>  	copl[cop_spr0ptrh].w[1] = highw(pl);
> @@ -3624,7 +3647,7 @@ static void ami_reinit_copper(void)
>  	struct amifb_par *par = &currentpar;
>  
>  	copdisplay.init[cip_bplcon0].w[1] = ~(BPC0_BPU3 | BPC0_BPU2 | BPC0_BPU1 | BPC0_BPU0) & par->bplcon0;
> -	copdisplay.wait->l = CWAIT(32, par->diwstrt_v-4);
> +	copdisplay.wait->l = CWAIT(32, par->diwstrt_v - 4);
>  }
>  
>  	/*
> @@ -3654,20 +3677,20 @@ static void ami_build_copper(void)
>  		(cops++)->l = CMOVE(0, sprpt[0]);
>  		(cops++)->l = CMOVE2(0, sprpt[0]);
>  
> -		(copl++)->l = CMOVE(diwstrt2hw(par->diwstrt_h, par->diwstrt_v+1), diwstrt);
> -		(copl++)->l = CMOVE(diwstop2hw(par->diwstop_h, par->diwstop_v+1), diwstop);
> +		(copl++)->l = CMOVE(diwstrt2hw(par->diwstrt_h, par->diwstrt_v + 1), diwstrt);
> +		(copl++)->l = CMOVE(diwstop2hw(par->diwstop_h, par->diwstop_v + 1), diwstop);
>  		(cops++)->l = CMOVE(diwstrt2hw(par->diwstrt_h, par->diwstrt_v), diwstrt);
>  		(cops++)->l = CMOVE(diwstop2hw(par->diwstop_h, par->diwstop_v), diwstop);
>  		if (!IS_OCS) {
> -			(copl++)->l = CMOVE(diwhigh2hw(par->diwstrt_h, par->diwstrt_v+1,
> -			                    par->diwstop_h, par->diwstop_v+1), diwhigh);
> +			(copl++)->l = CMOVE(diwhigh2hw(par->diwstrt_h, par->diwstrt_v + 1,
> +					    par->diwstop_h, par->diwstop_v + 1), diwhigh);
>  			(cops++)->l = CMOVE(diwhigh2hw(par->diwstrt_h, par->diwstrt_v,
> -			                    par->diwstop_h, par->diwstop_v), diwhigh);
> +					    par->diwstop_h, par->diwstop_v), diwhigh);
>  #if 0
>  			if (par->beamcon0 & BMC0_VARBEAMEN) {
>  				(copl++)->l = CMOVE(vtotal2hw(par->vtotal), vtotal);
> -				(copl++)->l = CMOVE(vbstrt2hw(par->vbstrt+1), vbstrt);
> -				(copl++)->l = CMOVE(vbstop2hw(par->vbstop+1), vbstop);
> +				(copl++)->l = CMOVE(vbstrt2hw(par->vbstrt + 1), vbstrt);
> +				(copl++)->l = CMOVE(vbstop2hw(par->vbstop + 1), vbstop);
>  				(cops++)->l = CMOVE(vtotal2hw(par->vtotal), vtotal);
>  				(cops++)->l = CMOVE(vbstrt2hw(par->vbstrt), vbstrt);
>  				(cops++)->l = CMOVE(vbstop2hw(par->vbstop), vbstop);
> @@ -3686,7 +3709,7 @@ static void ami_build_copper(void)
>  		(copl++)->l = CMOVE(diwstop2hw(par->diwstop_h, par->diwstop_v), diwstop);
>  		if (!IS_OCS) {
>  			(copl++)->l = CMOVE(diwhigh2hw(par->diwstrt_h, par->diwstrt_v,
> -			                    par->diwstop_h, par->diwstop_v), diwhigh);
> +					    par->diwstop_h, par->diwstop_v), diwhigh);
>  #if 0
>  			if (par->beamcon0 & BMC0_VARBEAMEN) {
>  				(copl++)->l = CMOVE(vtotal2hw(par->vtotal), vtotal);
> @@ -3717,23 +3740,23 @@ static void ami_rebuild_copper(void)
>  	u_long p;
>  
>  	if (IS_AGA && maxfmode + par->clk_shift = 0)
> -		h_end1 = par->diwstrt_h-64;
> +		h_end1 = par->diwstrt_h - 64;
>  	else
> -		h_end1 = par->htotal-32;
> -	h_end2 = par->ddfstop+64;
> +		h_end1 = par->htotal - 32;
> +	h_end2 = par->ddfstop + 64;
>  
>  	ami_set_sprite();
>  
>  	copl = copdisplay.rebuild[1];
>  	p = par->bplpt0;
>  	if (par->vmode & FB_VMODE_YWRAP) {
> -		if ((par->vyres-par->yoffset) != 1 || !mod2(par->diwstrt_v)) {
> -			if (par->yoffset > par->vyres-par->yres) {
> +		if ((par->vyres - par->yoffset) != 1 || !mod2(par->diwstrt_v)) {
> +			if (par->yoffset > par->vyres - par->yres) {
>  				for (i = 0; i < (short)par->bpp; i++, p += par->next_plane) {
>  					(copl++)->l = CMOVE(highw(p), bplpt[i]);
>  					(copl++)->l = CMOVE2(loww(p), bplpt[i]);
>  				}
> -				line = par->diwstrt_v + ((par->vyres-par->yoffset)<<par->line_shift) - 1;
> +				line = par->diwstrt_v + ((par->vyres - par->yoffset) << par->line_shift) - 1;
>  				while (line >= 512) {
>  					(copl++)->l = CWAIT(h_end1, 510);
>  					line -= 512;
> @@ -3744,7 +3767,8 @@ static void ami_rebuild_copper(void)
>  					(copl++)->l = CWAIT(h_end2, line);
>  				p = par->bplpt0wrap;
>  			}
> -		} else p = par->bplpt0wrap;
> +		} else
> +			p = par->bplpt0wrap;
>  	}
>  	for (i = 0; i < (short)par->bpp; i++, p += par->next_plane) {
>  		(copl++)->l = CMOVE(highw(p), bplpt[i]);
> @@ -3760,13 +3784,13 @@ static void ami_rebuild_copper(void)
>  		else
>  			p += par->next_line;
>  		if (par->vmode & FB_VMODE_YWRAP) {
> -			if ((par->vyres-par->yoffset) != 1 || mod2(par->diwstrt_v)) {
> -				if (par->yoffset > par->vyres-par->yres+1) {
> +			if ((par->vyres - par->yoffset) != 1 || mod2(par->diwstrt_v)) {
> +				if (par->yoffset > par->vyres - par->yres + 1) {
>  					for (i = 0; i < (short)par->bpp; i++, p += par->next_plane) {
>  						(cops++)->l = CMOVE(highw(p), bplpt[i]);
>  						(cops++)->l = CMOVE2(loww(p), bplpt[i]);
>  					}
> -					line = par->diwstrt_v + ((par->vyres-par->yoffset)<<par->line_shift) - 2;
> +					line = par->diwstrt_v + ((par->vyres - par->yoffset) << par->line_shift) - 2;
>  					while (line >= 512) {
>  						(cops++)->l = CWAIT(h_end1, 510);
>  						line -= 512;
> @@ -3776,12 +3800,14 @@ static void ami_rebuild_copper(void)
>  					else
>  						(cops++)->l = CWAIT(h_end2, line);
>  					p = par->bplpt0wrap;
> -					if (mod2(par->diwstrt_v+par->vyres-par->yoffset))
> +					if (mod2(par->diwstrt_v + par->vyres -
> +					    par->yoffset))
>  						p -= par->next_line;
>  					else
>  						p += par->next_line;
>  				}
> -			} else p = par->bplpt0wrap - par->next_line;
> +			} else
> +				p = par->bplpt0wrap - par->next_line;
>  		}
>  		for (i = 0; i < (short)par->bpp; i++, p += par->next_plane) {
>  			(cops++)->l = CMOVE(highw(p), bplpt[i]);


^ permalink raw reply

* Re: [PATCH 09/11] video: Remove redundant spi driver bus initialization
From: Florian Tobias Schandinat @ 2011-12-04  0:36 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-kernel, Tomi Valkeinen, linux-fbdev, linux-omap
In-Reply-To: <1322148561-25138-9-git-send-email-lars@metafoo.de>

On 11/24/2011 03:29 PM, Lars-Peter Clausen wrote:
> In ancient times it was necessary to manually initialize the bus field of an
> spi_driver to spi_bus_type. These days this is done in spi_driver_register(),
> so we can drop the manual assignment.
> 
> The patch was generated using the following coccinelle semantic patch:
> // <smpl>
> @@
> identifier _driver;
> @@
> struct spi_driver _driver = {
> 	.driver = {
> -		.bus = &spi_bus_type,
> 	},
> };
> // </smpl>
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
> Cc: linux-fbdev@vger.kernel.org
> Cc: linux-omap@vger.kernel.org

Applied this patch.


Thanks,

Florian Tobias Schandinat

> ---
>  drivers/video/omap/lcd_mipid.c                     |    1 -
>  drivers/video/omap2/displays/panel-acx565akm.c     |    1 -
>  drivers/video/omap2/displays/panel-n8x0.c          |    1 -
>  .../omap2/displays/panel-nec-nl8048hl11-01b.c      |    1 -
>  .../video/omap2/displays/panel-tpo-td043mtea1.c    |    1 -
>  5 files changed, 0 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/video/omap/lcd_mipid.c b/drivers/video/omap/lcd_mipid.c
> index eb381db..8d546dd 100644
> --- a/drivers/video/omap/lcd_mipid.c
> +++ b/drivers/video/omap/lcd_mipid.c
> @@ -603,7 +603,6 @@ static int mipid_spi_remove(struct spi_device *spi)
>  static struct spi_driver mipid_spi_driver = {
>  	.driver = {
>  		.name	= MIPID_MODULE_NAME,
> -		.bus	= &spi_bus_type,
>  		.owner	= THIS_MODULE,
>  	},
>  	.probe	= mipid_spi_probe,
> diff --git a/drivers/video/omap2/displays/panel-acx565akm.c b/drivers/video/omap2/displays/panel-acx565akm.c
> index dbd59b8..51a87e1 100644
> --- a/drivers/video/omap2/displays/panel-acx565akm.c
> +++ b/drivers/video/omap2/displays/panel-acx565akm.c
> @@ -803,7 +803,6 @@ static int acx565akm_spi_remove(struct spi_device *spi)
>  static struct spi_driver acx565akm_spi_driver = {
>  	.driver = {
>  		.name	= "acx565akm",
> -		.bus	= &spi_bus_type,
>  		.owner	= THIS_MODULE,
>  	},
>  	.probe	= acx565akm_spi_probe,
> diff --git a/drivers/video/omap2/displays/panel-n8x0.c b/drivers/video/omap2/displays/panel-n8x0.c
> index 150e8ba..dc9408d 100644
> --- a/drivers/video/omap2/displays/panel-n8x0.c
> +++ b/drivers/video/omap2/displays/panel-n8x0.c
> @@ -708,7 +708,6 @@ static int mipid_spi_remove(struct spi_device *spi)
>  static struct spi_driver mipid_spi_driver = {
>  	.driver = {
>  		.name	= "lcd_mipid",
> -		.bus	= &spi_bus_type,
>  		.owner	= THIS_MODULE,
>  	},
>  	.probe	= mipid_spi_probe,
> diff --git a/drivers/video/omap2/displays/panel-nec-nl8048hl11-01b.c b/drivers/video/omap2/displays/panel-nec-nl8048hl11-01b.c
> index 2ba9d0c..8365e77 100644
> --- a/drivers/video/omap2/displays/panel-nec-nl8048hl11-01b.c
> +++ b/drivers/video/omap2/displays/panel-nec-nl8048hl11-01b.c
> @@ -303,7 +303,6 @@ static struct spi_driver nec_8048_spi_driver = {
>  	.resume		= nec_8048_spi_resume,
>  	.driver		= {
>  		.name	= "nec_8048_spi",
> -		.bus	= &spi_bus_type,
>  		.owner	= THIS_MODULE,
>  	},
>  };
> diff --git a/drivers/video/omap2/displays/panel-tpo-td043mtea1.c b/drivers/video/omap2/displays/panel-tpo-td043mtea1.c
> index 2462b9e..e6649aa 100644
> --- a/drivers/video/omap2/displays/panel-tpo-td043mtea1.c
> +++ b/drivers/video/omap2/displays/panel-tpo-td043mtea1.c
> @@ -512,7 +512,6 @@ static int __devexit tpo_td043_spi_remove(struct spi_device *spi)
>  static struct spi_driver tpo_td043_spi_driver = {
>  	.driver = {
>  		.name	= "tpo_td043mtea1_panel_spi",
> -		.bus	= &spi_bus_type,
>  		.owner	= THIS_MODULE,
>  	},
>  	.probe	= tpo_td043_spi_probe,


^ permalink raw reply

* Re: [PATCH] video: convert drivers/video/* to use module_platform_driver()
From: Florian Tobias Schandinat @ 2011-12-04  0:38 UTC (permalink / raw)
  To: Axel Lin
  Cc: linux-kernel, Wan ZongShun, Sascha Hauer, Lennert Buytenhek,
	Ben Dooks, Alexey Charkov, Damian Hobson-Garcia, Manuel Lauss,
	linux-fbdev
In-Reply-To: <1322274354.10633.3.camel@phoenix>

On 11/26/2011 02:25 AM, Axel Lin wrote:
> This patch converts the drivers in drivers/video/* to use the
> module_platform_driver() macro which makes the code smaller and a bit
> simpler.
> 
> Cc: Wan ZongShun <mcuos.com@gmail.com>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Lennert Buytenhek <buytenh@marvell.com>
> Cc: Ben Dooks <ben@simtec.co.uk>
> Cc: Alexey Charkov <alchark@gmail.com>
> Cc: Damian Hobson-Garcia <dhobsong@igel.co.jp>
> Cc: Manuel Lauss <mano@roarinelk.homelinux.net>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied this patch.


Thanks,

Florian Tobias Schandinat

> ---
>  drivers/video/mxsfb.c            |   13 +------------
>  drivers/video/nuc900fb.c         |   13 +------------
>  drivers/video/pxa168fb.c         |   12 +-----------
>  drivers/video/pxa3xx-gcu.c       |   15 +--------------
>  drivers/video/s3c-fb.c           |   13 +------------
>  drivers/video/sh7760fb.c         |   13 +------------
>  drivers/video/sh_mobile_lcdcfb.c |   13 +------------
>  drivers/video/sh_mobile_meram.c  |   13 +------------
>  drivers/video/sm501fb.c          |   13 +------------
>  drivers/video/vt8500lcdfb.c      |   13 +------------
>  drivers/video/w100fb.c           |   13 +------------
>  drivers/video/wm8505fb.c         |   13 +------------
>  drivers/video/wmt_ge_rops.c      |   13 +------------
>  drivers/video/xilinxfb.c         |   20 +-------------------
>  14 files changed, 14 insertions(+), 176 deletions(-)
> 
> diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
> index d837d63..18742c2 100644
> --- a/drivers/video/mxsfb.c
> +++ b/drivers/video/mxsfb.c
> @@ -902,18 +902,7 @@ static struct platform_driver mxsfb_driver = {
>  	},
>  };
>  
> -static int __init mxsfb_init(void)
> -{
> -	return platform_driver_register(&mxsfb_driver);
> -}
> -
> -static void __exit mxsfb_exit(void)
> -{
> -	platform_driver_unregister(&mxsfb_driver);
> -}
> -
> -module_init(mxsfb_init);
> -module_exit(mxsfb_exit);
> +module_platform_driver(mxsfb_devtype);
>  
>  MODULE_DESCRIPTION("Freescale mxs framebuffer driver");
>  MODULE_AUTHOR("Sascha Hauer, Pengutronix");
> diff --git a/drivers/video/nuc900fb.c b/drivers/video/nuc900fb.c
> index d1fbbd8..e10f551 100644
> --- a/drivers/video/nuc900fb.c
> +++ b/drivers/video/nuc900fb.c
> @@ -762,18 +762,7 @@ static struct platform_driver nuc900fb_driver = {
>  	},
>  };
>  
> -int __devinit nuc900fb_init(void)
> -{
> -	return platform_driver_register(&nuc900fb_driver);
> -}
> -
> -static void __exit nuc900fb_cleanup(void)
> -{
> -	platform_driver_unregister(&nuc900fb_driver);
> -}
> -
> -module_init(nuc900fb_init);
> -module_exit(nuc900fb_cleanup);
> +module_platform_driver(nuc900fb_driver);
>  
>  MODULE_DESCRIPTION("Framebuffer driver for the NUC900");
>  MODULE_LICENSE("GPL");
> diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
> index 18ead6f..8384b94 100644
> --- a/drivers/video/pxa168fb.c
> +++ b/drivers/video/pxa168fb.c
> @@ -832,17 +832,7 @@ static struct platform_driver pxa168fb_driver = {
>  	.remove		= __devexit_p(pxa168fb_remove),
>  };
>  
> -static int __init pxa168fb_init(void)
> -{
> -	return platform_driver_register(&pxa168fb_driver);
> -}
> -module_init(pxa168fb_init);
> -
> -static void __exit pxa168fb_exit(void)
> -{
> -	platform_driver_unregister(&pxa168fb_driver);
> -}
> -module_exit(pxa168fb_exit);
> +module_platform_driver(pxa168fb_driver);
>  
>  MODULE_AUTHOR("Lennert Buytenhek <buytenh@marvell.com> "
>  	      "Green Wan <gwan@marvell.com>");
> diff --git a/drivers/video/pxa3xx-gcu.c b/drivers/video/pxa3xx-gcu.c
> index 1ed8b36..1d71c08 100644
> --- a/drivers/video/pxa3xx-gcu.c
> +++ b/drivers/video/pxa3xx-gcu.c
> @@ -747,20 +747,7 @@ static struct platform_driver pxa3xx_gcu_driver = {
>  	},
>  };
>  
> -static int __init
> -pxa3xx_gcu_init(void)
> -{
> -	return platform_driver_register(&pxa3xx_gcu_driver);
> -}
> -
> -static void __exit
> -pxa3xx_gcu_exit(void)
> -{
> -	platform_driver_unregister(&pxa3xx_gcu_driver);
> -}
> -
> -module_init(pxa3xx_gcu_init);
> -module_exit(pxa3xx_gcu_exit);
> +module_platform_driver(pxa3xx_gcu_driver);
>  
>  MODULE_DESCRIPTION("PXA3xx graphics controller unit driver");
>  MODULE_LICENSE("GPL");
> diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c
> index 12eaee0..cf1d11f 100644
> --- a/drivers/video/s3c-fb.c
> +++ b/drivers/video/s3c-fb.c
> @@ -2003,18 +2003,7 @@ static struct platform_driver s3c_fb_driver = {
>  	},
>  };
>  
> -static int __init s3c_fb_init(void)
> -{
> -	return platform_driver_register(&s3c_fb_driver);
> -}
> -
> -static void __exit s3c_fb_cleanup(void)
> -{
> -	platform_driver_unregister(&s3c_fb_driver);
> -}
> -
> -module_init(s3c_fb_init);
> -module_exit(s3c_fb_cleanup);
> +module_platform_driver(s3c_fb_driver);
>  
>  MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
>  MODULE_DESCRIPTION("Samsung S3C SoC Framebuffer driver");
> diff --git a/drivers/video/sh7760fb.c b/drivers/video/sh7760fb.c
> index 45e47d8..83b16e2 100644
> --- a/drivers/video/sh7760fb.c
> +++ b/drivers/video/sh7760fb.c
> @@ -585,18 +585,7 @@ static struct platform_driver sh7760_lcdc_driver = {
>  	.remove = __devexit_p(sh7760fb_remove),
>  };
>  
> -static int __init sh7760fb_init(void)
> -{
> -	return platform_driver_register(&sh7760_lcdc_driver);
> -}
> -
> -static void __exit sh7760fb_exit(void)
> -{
> -	platform_driver_unregister(&sh7760_lcdc_driver);
> -}
> -
> -module_init(sh7760fb_init);
> -module_exit(sh7760fb_exit);
> +module_platform_driver(sh7760_lcdc_driver);
>  
>  MODULE_AUTHOR("Nobuhiro Iwamatsu, Manuel Lauss");
>  MODULE_DESCRIPTION("FBdev for SH7760/63 integrated LCD Controller");
> diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
> index 1f49ab4..a264ebf 100644
> --- a/drivers/video/sh_mobile_lcdcfb.c
> +++ b/drivers/video/sh_mobile_lcdcfb.c
> @@ -1709,18 +1709,7 @@ static struct platform_driver sh_mobile_lcdc_driver = {
>  	.remove		= sh_mobile_lcdc_remove,
>  };
>  
> -static int __init sh_mobile_lcdc_init(void)
> -{
> -	return platform_driver_register(&sh_mobile_lcdc_driver);
> -}
> -
> -static void __exit sh_mobile_lcdc_exit(void)
> -{
> -	platform_driver_unregister(&sh_mobile_lcdc_driver);
> -}
> -
> -module_init(sh_mobile_lcdc_init);
> -module_exit(sh_mobile_lcdc_exit);
> +module_platform_driver(sh_mobile_lcdc_driver);
>  
>  MODULE_DESCRIPTION("SuperH Mobile LCDC Framebuffer driver");
>  MODULE_AUTHOR("Magnus Damm <damm@opensource.se>");
> diff --git a/drivers/video/sh_mobile_meram.c b/drivers/video/sh_mobile_meram.c
> index 4d63490..f45d83e 100644
> --- a/drivers/video/sh_mobile_meram.c
> +++ b/drivers/video/sh_mobile_meram.c
> @@ -679,18 +679,7 @@ static struct platform_driver sh_mobile_meram_driver = {
>  	.remove		= sh_mobile_meram_remove,
>  };
>  
> -static int __init sh_mobile_meram_init(void)
> -{
> -	return platform_driver_register(&sh_mobile_meram_driver);
> -}
> -
> -static void __exit sh_mobile_meram_exit(void)
> -{
> -	platform_driver_unregister(&sh_mobile_meram_driver);
> -}
> -
> -module_init(sh_mobile_meram_init);
> -module_exit(sh_mobile_meram_exit);
> +module_platform_driver(sh_mobile_meram_driver);
>  
>  MODULE_DESCRIPTION("SuperH Mobile MERAM driver");
>  MODULE_AUTHOR("Damian Hobson-Garcia / Takanari Hayama");
> diff --git a/drivers/video/sm501fb.c b/drivers/video/sm501fb.c
> index a78254c..3690eff 100644
> --- a/drivers/video/sm501fb.c
> +++ b/drivers/video/sm501fb.c
> @@ -2230,18 +2230,7 @@ static struct platform_driver sm501fb_driver = {
>  	},
>  };
>  
> -static int __devinit sm501fb_init(void)
> -{
> -	return platform_driver_register(&sm501fb_driver);
> -}
> -
> -static void __exit sm501fb_cleanup(void)
> -{
> -	platform_driver_unregister(&sm501fb_driver);
> -}
> -
> -module_init(sm501fb_init);
> -module_exit(sm501fb_cleanup);
> +module_platform_driver(sm501fb_driver);
>  
>  module_param_named(mode, fb_mode, charp, 0);
>  MODULE_PARM_DESC(mode,
> diff --git a/drivers/video/vt8500lcdfb.c b/drivers/video/vt8500lcdfb.c
> index 777c21d..2a5fe6e 100644
> --- a/drivers/video/vt8500lcdfb.c
> +++ b/drivers/video/vt8500lcdfb.c
> @@ -457,18 +457,7 @@ static struct platform_driver vt8500lcd_driver = {
>  	},
>  };
>  
> -static int __init vt8500lcd_init(void)
> -{
> -	return platform_driver_register(&vt8500lcd_driver);
> -}
> -
> -static void __exit vt8500lcd_exit(void)
> -{
> -	platform_driver_unregister(&vt8500lcd_driver);
> -}
> -
> -module_init(vt8500lcd_init);
> -module_exit(vt8500lcd_exit);
> +module_platform_driver(vt8500lcd_driver);
>  
>  MODULE_AUTHOR("Alexey Charkov <alchark@gmail.com>");
>  MODULE_DESCRIPTION("LCD controller driver for VIA VT8500");
> diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c
> index 2375e5b..90a2e30 100644
> --- a/drivers/video/w100fb.c
> +++ b/drivers/video/w100fb.c
> @@ -1620,18 +1620,7 @@ static struct platform_driver w100fb_driver = {
>  	},
>  };
>  
> -int __init w100fb_init(void)
> -{
> -	return platform_driver_register(&w100fb_driver);
> -}
> -
> -void __exit w100fb_cleanup(void)
> -{
> -	platform_driver_unregister(&w100fb_driver);
> -}
> -
> -module_init(w100fb_init);
> -module_exit(w100fb_cleanup);
> +module_platform_driver(w100fb_driver);
>  
>  MODULE_DESCRIPTION("ATI Imageon w100 framebuffer driver");
>  MODULE_LICENSE("GPL");
> diff --git a/drivers/video/wm8505fb.c b/drivers/video/wm8505fb.c
> index 96e34a5..c8703bd 100644
> --- a/drivers/video/wm8505fb.c
> +++ b/drivers/video/wm8505fb.c
> @@ -404,18 +404,7 @@ static struct platform_driver wm8505fb_driver = {
>  	},
>  };
>  
> -static int __init wm8505fb_init(void)
> -{
> -	return platform_driver_register(&wm8505fb_driver);
> -}
> -
> -static void __exit wm8505fb_exit(void)
> -{
> -	platform_driver_unregister(&wm8505fb_driver);
> -}
> -
> -module_init(wm8505fb_init);
> -module_exit(wm8505fb_exit);
> +module_platform_driver(wm8505fb_driver);
>  
>  MODULE_AUTHOR("Ed Spiridonov <edo.rus@gmail.com>");
>  MODULE_DESCRIPTION("Framebuffer driver for WMT WM8505");
> diff --git a/drivers/video/wmt_ge_rops.c b/drivers/video/wmt_ge_rops.c
> index 45832b7..55be386 100644
> --- a/drivers/video/wmt_ge_rops.c
> +++ b/drivers/video/wmt_ge_rops.c
> @@ -167,18 +167,7 @@ static struct platform_driver wmt_ge_rops_driver = {
>  	},
>  };
>  
> -static int __init wmt_ge_rops_init(void)
> -{
> -	return platform_driver_register(&wmt_ge_rops_driver);
> -}
> -
> -static void __exit wmt_ge_rops_exit(void)
> -{
> -	platform_driver_unregister(&wmt_ge_rops_driver);
> -}
> -
> -module_init(wmt_ge_rops_init);
> -module_exit(wmt_ge_rops_exit);
> +module_platform_driver(wmt_ge_rops_driver);
>  
>  MODULE_AUTHOR("Alexey Charkov <alchark@gmail.com");
>  MODULE_DESCRIPTION("Accelerators for raster operations using "
> diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c
> index fcb6cd9..1808452 100644
> --- a/drivers/video/xilinxfb.c
> +++ b/drivers/video/xilinxfb.c
> @@ -511,25 +511,7 @@ static struct platform_driver xilinxfb_of_driver = {
>  	},
>  };
>  
> -
> -/* ---------------------------------------------------------------------
> - * Module setup and teardown
> - */
> -
> -static int __init
> -xilinxfb_init(void)
> -{
> -	return platform_driver_register(&xilinxfb_of_driver);
> -}
> -
> -static void __exit
> -xilinxfb_cleanup(void)
> -{
> -	platform_driver_unregister(&xilinxfb_of_driver);
> -}
> -
> -module_init(xilinxfb_init);
> -module_exit(xilinxfb_cleanup);
> +module_platform_driver(xilinxfb_of_driver);
>  
>  MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>");
>  MODULE_DESCRIPTION("Xilinx TFT frame buffer driver");


^ permalink raw reply

* Re: [PATCH 1/2] video: s3c-fb: Unify runtime and system PM functions
From: Florian Tobias Schandinat @ 2011-12-04  0:39 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1322434268-25525-1-git-send-email-broonie@opensource.wolfsonmicro.com>

On 11/27/2011 10:51 PM, Mark Brown wrote:
> The s3c-fb driver has separate runtime and system PM functions but the
> implementations are identical so far as I can tell so unify them for
> simplicity.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Applied this patch.


Thanks,

Florian Tobias Schandinat

> ---
> 
> This is a slightly updated version of the patch, previously I forgot to
> staticise the pm_ops.
> 
>  drivers/video/s3c-fb.c |   75 +-----------------------------------------------
>  1 files changed, 1 insertions(+), 74 deletions(-)
> 
> diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c
> index 12eaee0..27971bc 100644
> --- a/drivers/video/s3c-fb.c
> +++ b/drivers/video/s3c-fb.c
> @@ -1590,77 +1590,9 @@ static int s3c_fb_resume(struct device *dev)
>  
>  	return 0;
>  }
> -
> -static int s3c_fb_runtime_suspend(struct device *dev)
> -{
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct s3c_fb *sfb = platform_get_drvdata(pdev);
> -	struct s3c_fb_win *win;
> -	int win_no;
> -
> -	for (win_no = S3C_FB_MAX_WIN - 1; win_no >= 0; win_no--) {
> -		win = sfb->windows[win_no];
> -		if (!win)
> -			continue;
> -
> -		/* use the blank function to push into power-down */
> -		s3c_fb_blank(FB_BLANK_POWERDOWN, win->fbinfo);
> -	}
> -
> -	if (!sfb->variant.has_clksel)
> -		clk_disable(sfb->lcd_clk);
> -
> -	clk_disable(sfb->bus_clk);
> -	return 0;
> -}
> -
> -static int s3c_fb_runtime_resume(struct device *dev)
> -{
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct s3c_fb *sfb = platform_get_drvdata(pdev);
> -	struct s3c_fb_platdata *pd = sfb->pdata;
> -	struct s3c_fb_win *win;
> -	int win_no;
> -
> -	clk_enable(sfb->bus_clk);
> -
> -	if (!sfb->variant.has_clksel)
> -		clk_enable(sfb->lcd_clk);
> -
> -	/* setup gpio and output polarity controls */
> -	pd->setup_gpio();
> -	writel(pd->vidcon1, sfb->regs + VIDCON1);
> -
> -	/* zero all windows before we do anything */
> -	for (win_no = 0; win_no < sfb->variant.nr_windows; win_no++)
> -		s3c_fb_clear_win(sfb, win_no);
> -
> -	for (win_no = 0; win_no < sfb->variant.nr_windows - 1; win_no++) {
> -		void __iomem *regs = sfb->regs + sfb->variant.keycon;
> -
> -		regs += (win_no * 8);
> -		writel(0xffffff, regs + WKEYCON0);
> -		writel(0xffffff, regs + WKEYCON1);
> -	}
> -
> -	/* restore framebuffers */
> -	for (win_no = 0; win_no < S3C_FB_MAX_WIN; win_no++) {
> -		win = sfb->windows[win_no];
> -		if (!win)
> -			continue;
> -
> -		dev_dbg(&pdev->dev, "resuming window %d\n", win_no);
> -		s3c_fb_set_par(win->fbinfo);
> -	}
> -
> -	return 0;
> -}
> -
>  #else
>  #define s3c_fb_suspend NULL
>  #define s3c_fb_resume  NULL
> -#define s3c_fb_runtime_suspend NULL
> -#define s3c_fb_runtime_resume NULL
>  #endif
>  
>  
> @@ -1985,12 +1917,7 @@ static struct platform_device_id s3c_fb_driver_ids[] = {
>  };
>  MODULE_DEVICE_TABLE(platform, s3c_fb_driver_ids);
>  
> -static const struct dev_pm_ops s3cfb_pm_ops = {
> -	.suspend	= s3c_fb_suspend,
> -	.resume		= s3c_fb_resume,
> -	.runtime_suspend	= s3c_fb_runtime_suspend,
> -	.runtime_resume		= s3c_fb_runtime_resume,
> -};
> +static UNIVERSAL_DEV_PM_OPS(s3cfb_pm_ops, s3c_fb_suspend, s3c_fb_resume, NULL);
>  
>  static struct platform_driver s3c_fb_driver = {
>  	.probe		= s3c_fb_probe,


^ permalink raw reply

* Re: [PATCH] video: s3c2410: fix checkpatch error and warnings
From: Florian Tobias Schandinat @ 2011-12-04  0:40 UTC (permalink / raw)
  To: linux-fbdev

On 11/29/2011 09:48 AM, Jingoo Han wrote:
> This patch fixes the checkpatch errors listed below:
> 
> ERROR: do not initialise statics to 0 or NULL
> WARNING: Use #include <linux/io.h> instead of <asm/io.h>
> WARNING: braces {} are not necessary for single statement blocks
> WARNING: braces {} are not necessary for any arm of this statement
> WARNING: static char array declaration should probably be static const char
> WARNING: line over 80 characters
> WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt
> 
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>

Applied this patch.


Thanks,

Florian Tobias Schandinat

> ---
>  drivers/video/s3c2410fb.c |   29 +++++++++++++++--------------
>  1 files changed, 15 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c
> index ee4c0df..77f34c6 100644
> --- a/drivers/video/s3c2410fb.c
> +++ b/drivers/video/s3c2410fb.c
> @@ -26,8 +26,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/clk.h>
>  #include <linux/cpufreq.h>
> +#include <linux/io.h>
>  
> -#include <asm/io.h>
>  #include <asm/div64.h>
>  
>  #include <asm/mach/map.h>
> @@ -45,10 +45,10 @@
>  #ifdef CONFIG_FB_S3C2410_DEBUG
>  static int debug	= 1;
>  #else
> -static int debug	= 0;
> +static int debug;
>  #endif
>  
> -#define dprintk(msg...)	if (debug) { printk(KERN_DEBUG "s3c2410fb: " msg); }
> +#define dprintk(msg...)	if (debug) printk(KERN_DEBUG "s3c2410fb: " msg);
>  
>  /* useful functions */
>  
> @@ -567,11 +567,10 @@ static int s3c2410fb_blank(int blank_mode, struct fb_info *info)
>  
>  	tpal_reg += is_s3c2412(fbi) ? S3C2412_TPAL : S3C2410_TPAL;
>  
> -	if (blank_mode = FB_BLANK_POWERDOWN) {
> +	if (blank_mode = FB_BLANK_POWERDOWN)
>  		s3c2410fb_lcd_enable(fbi, 0);
> -	} else {
> +	else
>  		s3c2410fb_lcd_enable(fbi, 1);
> -	}
>  
>  	if (blank_mode = FB_BLANK_UNBLANK)
>  		writel(0x0, tpal_reg);
> @@ -812,7 +811,7 @@ static inline void s3c2410fb_cpufreq_deregister(struct s3c2410fb_info *info)
>  #endif
>  
>  
> -static char driver_name[] = "s3c2410fb";
> +static const char driver_name[] = "s3c2410fb";
>  
>  static int __devinit s3c24xxfb_probe(struct platform_device *pdev,
>  				  enum s3c_drv_type drv_type)
> @@ -881,7 +880,10 @@ static int __devinit s3c24xxfb_probe(struct platform_device *pdev,
>  		goto release_mem;
>  	}
>  
> -	info->irq_base = info->io + ((drv_type = DRV_S3C2412) ? S3C2412_LCDINTBASE : S3C2410_LCDINTBASE);
> +	if (drv_type = DRV_S3C2412)
> +		info->irq_base = info->io + S3C2412_LCDINTBASE;
> +	else
> +		info->irq_base = info->io + S3C2410_LCDINTBASE;
>  
>  	dprintk("devinit\n");
>  
> @@ -927,7 +929,7 @@ static int __devinit s3c24xxfb_probe(struct platform_device *pdev,
>  	clk_enable(info->clk);
>  	dprintk("got and enabled clock\n");
>  
> -	msleep(1);
> +	usleep_range(1000, 1000);
>  
>  	info->clk_rate = clk_get_rate(info->clk);
>  
> @@ -975,9 +977,8 @@ static int __devinit s3c24xxfb_probe(struct platform_device *pdev,
>  
>  	/* create device files */
>  	ret = device_create_file(&pdev->dev, &dev_attr_debug);
> -	if (ret) {
> +	if (ret)
>  		printk(KERN_ERR "failed to add debug attribute\n");
> -	}
>  
>  	printk(KERN_INFO "fb%d: %s frame buffer device\n",
>  		fbinfo->node, fbinfo->fix.id);
> @@ -1027,7 +1028,7 @@ static int __devexit s3c2410fb_remove(struct platform_device *pdev)
>  	s3c2410fb_cpufreq_deregister(info);
>  
>  	s3c2410fb_lcd_enable(info, 0);
> -	msleep(1);
> +	usleep_range(1000, 1000);
>  
>  	s3c2410fb_unmap_video_memory(fbinfo);
>  
> @@ -1064,7 +1065,7 @@ static int s3c2410fb_suspend(struct platform_device *dev, pm_message_t state)
>  	 * the LCD DMA engine is not going to get back on the bus
>  	 * before the clock goes off again (bjd) */
>  
> -	msleep(1);
> +	usleep_range(1000, 1000);
>  	clk_disable(info->clk);
>  
>  	return 0;
> @@ -1076,7 +1077,7 @@ static int s3c2410fb_resume(struct platform_device *dev)
>  	struct s3c2410fb_info *info = fbinfo->par;
>  
>  	clk_enable(info->clk);
> -	msleep(1);
> +	usleep_range(1000, 1000);
>  
>  	s3c2410fb_init_registers(fbinfo);
>  


^ permalink raw reply

* Re: [PATCH v3.1] [resend] Resurrect Intel740 driver: i740fb
From: Tabi Timur-B04825 @ 2011-12-04  2:35 UTC (permalink / raw)
  To: Florian Tobias Schandinat
  Cc: Ondrej Zary, linux-fbdev@vger.kernel.org, Paul Mundt,
	Kernel development list
In-Reply-To: <4EDA9882.208@gmx.de>

On Sat, Dec 3, 2011 at 3:45 PM, Florian Tobias Schandinat
<FlorianSchandinat@gmx.de> wrote:
>
>> +     return !!(i740inreg(par, XRX, REG_DDC_STATE) & DDC_SCL);
>
> Why "!!"?

This is a trick that guarantees that the return value is either 0 or
1.  Without the !!, the return value will be either 0 or DDC_SCL.

-- 
Timur Tabi
Linux kernel developer at Freescale

^ permalink raw reply

* [PATCH] video: s3c-fb: modify runtime pm functions
From: Jingoo Han @ 2011-12-05  2:32 UTC (permalink / raw)
  To: linux-fbdev

Runtime suspend and runtime resume are modified in order to
reduce the complexity and improve the usability of runtime pm.
After probe function, s3c-fb driver is not suspended until
suspend or remove is called.

The scheme is changed as follows:
 runtime_get is only called in probe and resume.
 runtime_put is only called in remove and suspend.
 open/close cannot call the runtime_get/put.

Also, runtime_susepnd/resume are just called by runtime pm,
not doing suspend/resume routine any longer. This is because
open/close cannot call the runtime_get/put; the suspend/resume
routine in runtime_suspend/resume were previously used when
open and close were called.

The name of s3c-fb dev_pm_ops is changed from s3cfb_pm_ops to
s3c_fb_pm_ops in order to use more consistent naming.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/video/s3c-fb.c |   51
++++++++++++++++++-----------------------------
 1 files changed, 20 insertions(+), 31 deletions(-)

diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c
index e84677e..91e629a 100644
--- a/drivers/video/s3c-fb.c
+++ b/drivers/video/s3c-fb.c
@@ -1028,30 +1028,8 @@ static int s3c_fb_ioctl(struct fb_info *info,
unsigned int cmd,
 	return ret;
 }
 
-static int s3c_fb_open(struct fb_info *info, int user)
-{
-	struct s3c_fb_win *win = info->par;
-	struct s3c_fb *sfb = win->parent;
-
-	pm_runtime_get_sync(sfb->dev);
-
-	return 0;
-}
-
-static int s3c_fb_release(struct fb_info *info, int user)
-{
-	struct s3c_fb_win *win = info->par;
-	struct s3c_fb *sfb = win->parent;
-
-	pm_runtime_put_sync(sfb->dev);
-
-	return 0;
-}
-
 static struct fb_ops s3c_fb_ops = {
 	.owner		= THIS_MODULE,
-	.fb_open	= s3c_fb_open,
-	.fb_release	= s3c_fb_release,
 	.fb_check_var	= s3c_fb_check_var,
 	.fb_set_par	= s3c_fb_set_par,
 	.fb_blank	= s3c_fb_blank,
@@ -1458,7 +1436,6 @@ static int __devinit s3c_fb_probe(struct
platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, sfb);
-	pm_runtime_put_sync(sfb->dev);
 
 	return 0;
 
@@ -1498,8 +1475,6 @@ static int __devexit s3c_fb_remove(struct
platform_device *pdev)
 	struct s3c_fb *sfb = platform_get_drvdata(pdev);
 	int win;
 
-	pm_runtime_get_sync(sfb->dev);
-
 	for (win = 0; win < S3C_FB_MAX_WIN; win++)
 		if (sfb->windows[win])
 			s3c_fb_release_win(sfb, sfb->windows[win]);
@@ -1525,7 +1500,7 @@ static int __devexit s3c_fb_remove(struct
platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int s3c_fb_suspend(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -1546,6 +1521,8 @@ static int s3c_fb_suspend(struct device *dev)
 		clk_disable(sfb->lcd_clk);
 
 	clk_disable(sfb->bus_clk);
+	pm_runtime_put_sync(sfb->dev);
+
 	return 0;
 }
 
@@ -1557,6 +1534,7 @@ static int s3c_fb_resume(struct device *dev)
 	struct s3c_fb_win *win;
 	int win_no;
 
+	pm_runtime_get_sync(sfb->dev);
 	clk_enable(sfb->bus_clk);
 
 	if (!sfb->variant.has_clksel)
@@ -1590,11 +1568,19 @@ static int s3c_fb_resume(struct device *dev)
 
 	return 0;
 }
-#else
-#define s3c_fb_suspend NULL
-#define s3c_fb_resume  NULL
 #endif
 
+#ifdef CONFIG_PM_RUNTIME
+static int s3c_fb_runtime_suspend(struct device *dev)
+{
+	return 0;
+}
+
+static int s3c_fb_runtime_resume(struct device *dev)
+{
+	return 0;
+}
+#endif
 
 #define VALID_BPP124 (VALID_BPP(1) | VALID_BPP(2) | VALID_BPP(4))
 #define VALID_BPP1248 (VALID_BPP124 | VALID_BPP(8))
@@ -1917,7 +1903,10 @@ static struct platform_device_id s3c_fb_driver_ids[]
= {
 };
 MODULE_DEVICE_TABLE(platform, s3c_fb_driver_ids);
 
-static UNIVERSAL_DEV_PM_OPS(s3cfb_pm_ops, s3c_fb_suspend, s3c_fb_resume,
NULL);
+static const struct dev_pm_ops s3c_fb_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(s3c_fb_suspend, s3c_fb_resume)
+	SET_RUNTIME_PM_OPS(s3c_fb_runtime_suspend, s3c_fb_runtime_resume,
NULL)
+};
 
 static struct platform_driver s3c_fb_driver = {
 	.probe		= s3c_fb_probe,
@@ -1926,7 +1915,7 @@ static struct platform_driver s3c_fb_driver = {
 	.driver		= {
 		.name	= "s3c-fb",
 		.owner	= THIS_MODULE,
-		.pm	= &s3cfb_pm_ops,
+		.pm	= &s3c_fb_pm_ops,
 	},
 };
 
-- 
1.7.1


^ permalink raw reply related

* [PATCH V2] video: s3c-fb: modify runtime pm functions
From: Jingoo Han @ 2011-12-05  2:42 UTC (permalink / raw)
  To: linux-fbdev

Runtime suspend and runtime resume are modified in order to
reduce the complexity and improve the usability of runtime pm.
After probe function, s3c-fb driver is not suspended until
suspend or remove is called.

The scheme is changed as follows:
 runtime_get is only called in probe and resume.
 runtime_put is only called in remove and suspend.
 open/close cannot call the runtime_get/put.

Also, runtime_susepnd/resume are just called by runtime pm,
not doing suspend/resume routine any longer. This is because
open/close cannot call the runtime_get/put; the suspend/resume
routine in runtime_suspend/resume were previously used when
open and close were called.

The name of s3c-fb dev_pm_ops is changed from s3cfb_pm_ops to
s3c_fb_pm_ops in order to use more consistent naming.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
v2: fix unaligned lines

 drivers/video/s3c-fb.c |   51 ++++++++++++++++++-----------------------------
 1 files changed, 20 insertions(+), 31 deletions(-)

diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c
index e84677e..91e629a 100644
--- a/drivers/video/s3c-fb.c
+++ b/drivers/video/s3c-fb.c
@@ -1028,30 +1028,8 @@ static int s3c_fb_ioctl(struct fb_info *info, unsigned int cmd,
 	return ret;
 }
 
-static int s3c_fb_open(struct fb_info *info, int user)
-{
-	struct s3c_fb_win *win = info->par;
-	struct s3c_fb *sfb = win->parent;
-
-	pm_runtime_get_sync(sfb->dev);
-
-	return 0;
-}
-
-static int s3c_fb_release(struct fb_info *info, int user)
-{
-	struct s3c_fb_win *win = info->par;
-	struct s3c_fb *sfb = win->parent;
-
-	pm_runtime_put_sync(sfb->dev);
-
-	return 0;
-}
-
 static struct fb_ops s3c_fb_ops = {
 	.owner		= THIS_MODULE,
-	.fb_open	= s3c_fb_open,
-	.fb_release	= s3c_fb_release,
 	.fb_check_var	= s3c_fb_check_var,
 	.fb_set_par	= s3c_fb_set_par,
 	.fb_blank	= s3c_fb_blank,
@@ -1458,7 +1436,6 @@ static int __devinit s3c_fb_probe(struct platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, sfb);
-	pm_runtime_put_sync(sfb->dev);
 
 	return 0;
 
@@ -1498,8 +1475,6 @@ static int __devexit s3c_fb_remove(struct platform_device *pdev)
 	struct s3c_fb *sfb = platform_get_drvdata(pdev);
 	int win;
 
-	pm_runtime_get_sync(sfb->dev);
-
 	for (win = 0; win < S3C_FB_MAX_WIN; win++)
 		if (sfb->windows[win])
 			s3c_fb_release_win(sfb, sfb->windows[win]);
@@ -1525,7 +1500,7 @@ static int __devexit s3c_fb_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int s3c_fb_suspend(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -1546,6 +1521,8 @@ static int s3c_fb_suspend(struct device *dev)
 		clk_disable(sfb->lcd_clk);
 
 	clk_disable(sfb->bus_clk);
+	pm_runtime_put_sync(sfb->dev);
+
 	return 0;
 }
 
@@ -1557,6 +1534,7 @@ static int s3c_fb_resume(struct device *dev)
 	struct s3c_fb_win *win;
 	int win_no;
 
+	pm_runtime_get_sync(sfb->dev);
 	clk_enable(sfb->bus_clk);
 
 	if (!sfb->variant.has_clksel)
@@ -1590,11 +1568,19 @@ static int s3c_fb_resume(struct device *dev)
 
 	return 0;
 }
-#else
-#define s3c_fb_suspend NULL
-#define s3c_fb_resume  NULL
 #endif
 
+#ifdef CONFIG_PM_RUNTIME
+static int s3c_fb_runtime_suspend(struct device *dev)
+{
+	return 0;
+}
+
+static int s3c_fb_runtime_resume(struct device *dev)
+{
+	return 0;
+}
+#endif
 
 #define VALID_BPP124 (VALID_BPP(1) | VALID_BPP(2) | VALID_BPP(4))
 #define VALID_BPP1248 (VALID_BPP124 | VALID_BPP(8))
@@ -1917,7 +1903,10 @@ static struct platform_device_id s3c_fb_driver_ids[] = {
 };
 MODULE_DEVICE_TABLE(platform, s3c_fb_driver_ids);
 
-static UNIVERSAL_DEV_PM_OPS(s3cfb_pm_ops, s3c_fb_suspend, s3c_fb_resume, NULL);
+static const struct dev_pm_ops s3c_fb_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(s3c_fb_suspend, s3c_fb_resume)
+	SET_RUNTIME_PM_OPS(s3c_fb_runtime_suspend, s3c_fb_runtime_resume, NULL)
+};
 
 static struct platform_driver s3c_fb_driver = {
 	.probe		= s3c_fb_probe,
@@ -1926,7 +1915,7 @@ static struct platform_driver s3c_fb_driver = {
 	.driver		= {
 		.name	= "s3c-fb",
 		.owner	= THIS_MODULE,
-		.pm	= &s3cfb_pm_ops,
+		.pm	= &s3c_fb_pm_ops,
 	},
 };
 
-- 
1.7.1



^ permalink raw reply related

* (no subject)
From: r66093 @ 2011-12-05  9:16 UTC (permalink / raw)
  To: linux-fbdev



^ permalink raw reply

* Re: Problems with radeon driver under KDE-4.7.2
From: Michel Dänzer @ 2011-12-05 16:57 UTC (permalink / raw)
  To: linux-fbdev

[ Moving to the mesa-dev mailing list ]

On Son, 2011-11-27 at 15:15 +0100, Hendrik Sattler wrote: 
> 
> I just upgraded to KDE-4.7.2 and Linux-3.1 and mostly when using Firefox, I 
> get issues like a stall screen, then a short blank screen and then it works 
> some time until that happens again.
> 
> The kernel log then shows something like:
> WARNING: at drivers/gpu/drm/radeon/radeon_fence.c:267 
> radeon_fence_wait+0x215/0x292()
> Hardware name: TravelMate 6592
> GPU lockup (waiting for 0x00158B0E last fence id 0x00158B0C)
[...] 
> So far, I think it's great that it can recover pretty fine most of the time 
> :-)
> I now upgraded to Linux-3.1.3 and looked at the KDE setting about the possible
> cause for this. New to me was the desktop effect setting about using 
> "OpenGL-2-Shader". I deactivated it and its stable so far. Is this a know 
> issue?

Not that I know of. Which version of which Mesa driver are you using?
The output of glxinfo would be interesting.


> One other question: I saw that vdpau seems to be supported:
> [    24.226] (II) RADEON(0): [DRI2]   VDPAU driver: r600
> What exactly is needed to use this? I tried "mplayer -vo vdpau" but that only 
> gives me:
> Failed to open VDPAU backend libvdpau_r600.so: cannot open shared object file: 
> No such file or directory
> [vdpau] Error when calling vdp_device_create_x11: 1
> Error opening/initializing the selected video_out (-vo) device.
> 
> Where can I get this file. Latest Debian does not seem to have it...

You need to build Mesa Git with at least --enable-vdpau. But note that
it's still rather experimental and may not be useful to you, e.g. it can
only decode MPEG 1/2 with the help of GPU shaders so far.


-- 
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer

^ permalink raw reply

* RE: [PATCH 2/2] video: s3c-fb: Convert to devm style allocation
From: Kukjin Kim @ 2011-12-06 12:04 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1322434268-25525-2-git-send-email-broonie@opensource.wolfsonmicro.com>

Mark Brown wrote:
> 
> Saves some code, especially useful as the code saved is mostly in the
> infrequently tested error paths.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
>  drivers/video/s3c-fb.c |   32 +++++---------------------------
>  1 files changed, 5 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c
> index 27971bc..c8e822b 100644
> --- a/drivers/video/s3c-fb.c
> +++ b/drivers/video/s3c-fb.c
> @@ -186,7 +186,6 @@ struct s3c_fb_vsync {
>   * struct s3c_fb - overall hardware state of the hardware
>   * @slock: The spinlock protection for this data sturcture.
>   * @dev: The device that we bound to, for printing, etc.
> - * @regs_res: The resource we claimed for the IO registers.
>   * @bus_clk: The clk (hclk) feeding our interface and possibly pixclk.
>   * @lcd_clk: The clk (sclk) feeding pixclk.
>   * @regs: The mapped hardware registers.
> @@ -201,7 +200,6 @@ struct s3c_fb_vsync {
>  struct s3c_fb {
>  	spinlock_t		slock;
>  	struct device		*dev;
> -	struct resource		*regs_res;
>  	struct clk		*bus_clk;
>  	struct clk		*lcd_clk;
>  	void __iomem		*regs;
> @@ -1341,7 +1339,7 @@ static int __devinit s3c_fb_probe(struct
> platform_device *pdev)
>  		return -EINVAL;
>  	}
> 
> -	sfb = kzalloc(sizeof(struct s3c_fb), GFP_KERNEL);
> +	sfb = devm_kzalloc(dev, sizeof(struct s3c_fb), GFP_KERNEL);
>  	if (!sfb) {
>  		dev_err(dev, "no memory for framebuffers\n");
>  		return -ENOMEM;
> @@ -1384,33 +1382,25 @@ static int __devinit s3c_fb_probe(struct
> platform_device *pdev)
>  		goto err_lcd_clk;
>  	}
> 
> -	sfb->regs_res = request_mem_region(res->start, resource_size(res),
> -					   dev_name(dev));
> -	if (!sfb->regs_res) {
> -		dev_err(dev, "failed to claim register region\n");
> -		ret = -ENOENT;
> -		goto err_lcd_clk;
> -	}
> -
> -	sfb->regs = ioremap(res->start, resource_size(res));
> +	sfb->regs = devm_request_and_ioremap(dev, res);
>  	if (!sfb->regs) {
>  		dev_err(dev, "failed to map registers\n");

Don't we need dev_err here because the devm_request_and_ioremap() includes
dev_err() for each error case?

And don't we need devm_release_mem_region() or devm_iounmap() in error
handling?

>  		ret = -ENXIO;
> -		goto err_req_region;
> +		goto err_lcd_clk;
>  	}
> 
>  	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
>  	if (!res) {
>  		dev_err(dev, "failed to acquire irq resource\n");
>  		ret = -ENOENT;
> -		goto err_ioremap;
> +		goto err_lcd_clk;
>  	}
>  	sfb->irq_no = res->start;
>  	ret = request_irq(sfb->irq_no, s3c_fb_irq,
>  			  0, "s3c_fb", sfb);
>  	if (ret) {
>  		dev_err(dev, "irq request failed\n");
> -		goto err_ioremap;
> +		goto err_lcd_clk;
>  	}
> 
>  	dev_dbg(dev, "got resources (regs %p), probing windows\n", sfb-
> >regs);
> @@ -1465,12 +1455,6 @@ static int __devinit s3c_fb_probe(struct
> platform_device *pdev)
>  err_irq:
>  	free_irq(sfb->irq_no, sfb);
> 
> -err_ioremap:
> -	iounmap(sfb->regs);
> -
> -err_req_region:
> -	release_mem_region(sfb->regs_res->start, resource_size(sfb-
> >regs_res));
> -
>  err_lcd_clk:
>  	if (!sfb->variant.has_clksel) {
>  		clk_disable(sfb->lcd_clk);
> @@ -1482,7 +1466,6 @@ err_bus_clk:
>  	clk_put(sfb->bus_clk);
> 
>  err_sfb:
> -	kfree(sfb);

Maybe we need devm_kfree here?

>  	return ret;
>  }
> 
> @@ -1506,8 +1489,6 @@ static int __devexit s3c_fb_remove(struct
> platform_device *pdev)
> 
>  	free_irq(sfb->irq_no, sfb);
> 
> -	iounmap(sfb->regs);
> -
>  	if (!sfb->variant.has_clksel) {
>  		clk_disable(sfb->lcd_clk);
>  		clk_put(sfb->lcd_clk);
> @@ -1516,12 +1497,9 @@ static int __devexit s3c_fb_remove(struct
> platform_device *pdev)
>  	clk_disable(sfb->bus_clk);
>  	clk_put(sfb->bus_clk);
> 
> -	release_mem_region(sfb->regs_res->start, resource_size(sfb-
> >regs_res));
> -
>  	pm_runtime_put_sync(sfb->dev);
>  	pm_runtime_disable(sfb->dev);
> 
> -	kfree(sfb);
>  	return 0;
>  }
> 
> --
> 1.7.7.3

Others, looks ok to me:
Acked-by: Kukjin Kim <kgene.kim@samsung.com>

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <kgene.kim@samsung.com>, Senior Engineer,
SW Solution Development Team, Samsung Electronics Co., Ltd.


^ permalink raw reply

* [BUGFIX] video/mxsfb: fix crash when unblanking the display
From: Lothar Waßmann @ 2011-12-06 12:27 UTC (permalink / raw)
  To: linux-arm-kernel

The VDCTRL4 register does not provide the MXS SET/CLR/TOGGLE feature.
The write in mxsfb_disable_controller() sets the data_cnt for the LCD
DMA to 0 which obviously means the max. count for the LCD DMA and
leads to overwriting arbitrary memory when the display is unblanked.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 drivers/video/mxsfb.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index d837d63..03cb95a 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -366,7 +366,8 @@ static void mxsfb_disable_controller(struct fb_info *fb_info)
 		loop--;
 	}
 
-	writel(VDCTRL4_SYNC_SIGNALS_ON, host->base + LCDC_VDCTRL4 + REG_CLR);
+	reg = readl(host->base + LCDC_VDCTRL4);
+	writel(reg & ~VDCTRL4_SYNC_SIGNALS_ON, host->base + LCDC_VDCTRL4);
 
 	clk_disable(host->clk);
 
-- 
1.5.6.5


^ 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