LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: linux-fbdev-devel@lists.sourceforge.net,
	akonovalov@ru.mvista.com, linuxppc-dev@ozlabs.org,
	adaplas@gmail.com, jwboyer@linux.vnet.ibm.com
Subject: [PATCH 1/3] XilinxFB: use pdata to pass around framebuffer parameters.
Date: Wed, 10 Oct 2007 12:31:46 -0600	[thread overview]
Message-ID: <20071010183146.12852.73383.stgit@trillian.cg.shawcable.net> (raw)
In-Reply-To: <20071010182920.12852.41903.stgit@trillian.cg.shawcable.net>

From: Grant Likely <grant.likely@secretlab.ca>

The call to xilinxfb_assign is getting unwieldy when adding features
to the Xilinx framebuffer driver.  Change xilinxfb_assign() to accept
a pointer to a xilinxfb_platform_data structure to prepare for adding
additition configuration options.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---

 drivers/video/xilinxfb.c |   43 +++++++++++++++++++++++--------------------
 1 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c
index dec602c..b3b57f4 100644
--- a/drivers/video/xilinxfb.c
+++ b/drivers/video/xilinxfb.c
@@ -84,6 +84,12 @@
 #define PALETTE_ENTRIES_NO	16	/* passed to fb_alloc_cmap() */
 
 /*
+ * Default xilinxfb configuration
+ */
+static struct xilinxfb_platform_data xilinx_fb_default_pdata = {
+};
+
+/*
  * Here are the default fb_fix_screeninfo and fb_var_screeninfo structures
  */
 static struct fb_fix_screeninfo xilinx_fb_fix = {
@@ -207,7 +213,7 @@ static struct fb_ops xilinxfb_ops =
  */
 
 static int xilinxfb_assign(struct device *dev, unsigned long physaddr,
-			   int width_mm, int height_mm, int rotate)
+			   struct xilinxfb_platform_data *pdata)
 {
 	struct xilinxfb_drvdata *drvdata;
 	int rc;
@@ -253,7 +259,7 @@ static int xilinxfb_assign(struct device *dev, unsigned long physaddr,
 
 	/* Turn on the display */
 	drvdata->reg_ctrl_default = REG_CTRL_ENABLE;
-	if (rotate)
+	if (pdata->rotate_screen)
 		drvdata->reg_ctrl_default |= REG_CTRL_ROTATE;
 	xilinx_fb_out_be32(drvdata, REG_CTRL, drvdata->reg_ctrl_default);
 
@@ -267,8 +273,8 @@ static int xilinxfb_assign(struct device *dev, unsigned long physaddr,
 	drvdata->info.flags = FBINFO_DEFAULT;
 	drvdata->info.var = xilinx_fb_var;
 
-	xilinx_fb_var.height = height_mm;
-	xilinx_fb_var.width = width_mm;
+	xilinx_fb_var.height = pdata->screen_height_mm;
+	xilinx_fb_var.width = pdata->screen_width_mm;
 
 	/* Allocate a colour map */
 	rc = fb_alloc_cmap(&drvdata->info.cmap, PALETTE_ENTRIES_NO, 0);
@@ -349,9 +355,6 @@ xilinxfb_platform_probe(struct platform_device *pdev)
 {
 	struct xilinxfb_platform_data *pdata;
 	struct resource *res;
-	int width_mm = 0;
-	int height_mm = 0;
-	int rotate = 0;
 
 	/* Find the registers address */
 	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
@@ -361,15 +364,12 @@ xilinxfb_platform_probe(struct platform_device *pdev)
 	}
 
 	/* If a pdata structure is provided, then extract the parameters */
-	pdata = pdev->dev.platform_data;
-	if (pdata) {
-		height_mm = pdata->screen_height_mm;
-		width_mm = pdata->screen_width_mm;
-		rotate = pdata->rotate_screen ? 1 : 0;
-	}
+	if (pdev->dev.platform_data)
+		pdata = pdev->dev.platform_data;
+	else
+		pdata = &xilinx_fb_default_pdata;
 
-	return xilinxfb_assign(&pdev->dev, res->start, width_mm, height_mm,
-			       rotate);
+	return xilinxfb_assign(&pdev->dev, res->start, pdata);
 }
 
 static int
@@ -398,9 +398,12 @@ xilinxfb_of_probe(struct of_device *op, const struct of_device_id *match)
 {
 	struct resource res;
 	const u32 *prop;
-	int width = 0, height = 0, rotate = 0;
+	struct xilinxfb_platform_data pdata;
 	int size, rc;
 
+	/* Copy with the default pdata (not a ptr reference!) */
+	pdata = xilinx_fb_default_pdata;
+
 	dev_dbg(&op->dev, "xilinxfb_of_probe(%p, %p)\n", op, match);
 
 	rc = of_address_to_resource(op->node, 0, &res);
@@ -411,14 +414,14 @@ xilinxfb_of_probe(struct of_device *op, const struct of_device_id *match)
 
 	prop = of_get_property(op->node, "display-number", &size);
 	if ((prop) && (size >= sizeof(u32)*2)) {
-		width = prop[0];
-		height = prop[1];
+		pdata.screen_width_mm = prop[0];
+		pdata.screen_height_mm = prop[1];
 	}
 
 	if (of_find_property(op->node, "rotate-display", NULL))
-		rotate = 1;
+		pdata.rotate_screen = 1;
 
-	return xilinxfb_assign(&op->dev, res.start, width, height, rotate);
+	return xilinxfb_assign(&op->dev, res.start, &pdata);
 }
 
 static int __devexit xilinxfb_of_remove(struct of_device *op)

  reply	other threads:[~2007-10-10 18:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-10 18:31 [PATCH 0/3] More XilinxFB changes Grant Likely
2007-10-10 18:31 ` Grant Likely [this message]
2007-10-10 18:31 ` [PATCH 2/3] Xilinxfb: Add support for custom screen resolution Grant Likely
2007-10-10 18:31 ` [PATCH 3/3] XilinxFB: Allow fixed framebuffer base address Grant Likely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071010183146.12852.73383.stgit@trillian.cg.shawcable.net \
    --to=grant.likely@secretlab.ca \
    --cc=adaplas@gmail.com \
    --cc=akonovalov@ru.mvista.com \
    --cc=jwboyer@linux.vnet.ibm.com \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox