All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 12/17] video: arm: rpi: Move the video query out of the driver
Date: Fri, 20 Jan 2017 07:07:47 -0700	[thread overview]
Message-ID: <20170120140752.16296-13-sjg@chromium.org> (raw)
In-Reply-To: <20170120140752.16296-1-sjg@chromium.org>

Add a function to get the video size to the msg handler and remove it from
the video driver.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v4: None
Changes in v3: None

 arch/arm/mach-bcm283x/include/mach/msg.h |  9 +++++++++
 arch/arm/mach-bcm283x/msg.c              | 26 ++++++++++++++++++++++++++
 drivers/video/bcm2835.c                  | 20 +++-----------------
 3 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-bcm283x/include/mach/msg.h b/arch/arm/mach-bcm283x/include/mach/msg.h
index 8fd4ace124d..c785c43a67a 100644
--- a/arch/arm/mach-bcm283x/include/mach/msg.h
+++ b/arch/arm/mach-bcm283x/include/mach/msg.h
@@ -22,4 +22,13 @@ int bcm2835_power_on_module(u32 module);
  */
 int bcm2835_get_mmc_clock(void);
 
+/**
+ * bcm2835_get_video_size() - get the current display size
+ *
+ * @widthp: Returns the width in pixels
+ * @heightp: Returns the height in pixels
+ * @return 0 if OK, -ve on error
+ */
+int bcm2835_get_video_size(int *widthp, int *heightp);
+
 #endif
diff --git a/arch/arm/mach-bcm283x/msg.c b/arch/arm/mach-bcm283x/msg.c
index facb916711c..17266c01a69 100644
--- a/arch/arm/mach-bcm283x/msg.c
+++ b/arch/arm/mach-bcm283x/msg.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <memalign.h>
+#include <phys2bus.h>
 #include <asm/arch/mbox.h>
 
 struct msg_set_power_state {
@@ -20,6 +21,12 @@ struct msg_get_clock_rate {
 	u32 end_tag;
 };
 
+struct msg_query {
+	struct bcm2835_mbox_hdr hdr;
+	struct bcm2835_mbox_tag_physical_w_h physical_w_h;
+	u32 end_tag;
+};
+
 int bcm2835_power_on_module(u32 module)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(struct msg_set_power_state, msg_pwr, 1);
@@ -65,3 +72,22 @@ int bcm2835_get_mmc_clock(void)
 
 	return msg_clk->get_clock_rate.body.resp.rate_hz;
 }
+
+int bcm2835_get_video_size(int *widthp, int *heightp)
+{
+	ALLOC_CACHE_ALIGN_BUFFER(struct msg_query, msg_query, 1);
+	int ret;
+
+	BCM2835_MBOX_INIT_HDR(msg_query);
+	BCM2835_MBOX_INIT_TAG_NO_REQ(&msg_query->physical_w_h,
+				     GET_PHYSICAL_W_H);
+	ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_query->hdr);
+	if (ret) {
+		printf("bcm2835: Could not query display resolution\n");
+		return ret;
+	}
+	*widthp = msg_query->physical_w_h.body.resp.width;
+	*heightp = msg_query->physical_w_h.body.resp.height;
+
+	return 0;
+}
diff --git a/drivers/video/bcm2835.c b/drivers/video/bcm2835.c
index cc6454f10d4..eb137be11ca 100644
--- a/drivers/video/bcm2835.c
+++ b/drivers/video/bcm2835.c
@@ -9,6 +9,7 @@
 #include <memalign.h>
 #include <phys2bus.h>
 #include <asm/arch/mbox.h>
+#include <asm/arch/msg.h>
 #include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -18,12 +19,6 @@ vidinfo_t panel_info;
 
 static u32 bcm2835_pitch;
 
-struct msg_query {
-	struct bcm2835_mbox_hdr hdr;
-	struct bcm2835_mbox_tag_physical_w_h physical_w_h;
-	u32 end_tag;
-};
-
 struct msg_setup {
 	struct bcm2835_mbox_hdr hdr;
 	struct bcm2835_mbox_tag_physical_w_h physical_w_h;
@@ -40,27 +35,18 @@ struct msg_setup {
 
 void lcd_ctrl_init(void *lcdbase)
 {
-	ALLOC_CACHE_ALIGN_BUFFER(struct msg_query, msg_query, 1);
 	ALLOC_CACHE_ALIGN_BUFFER(struct msg_setup, msg_setup, 1);
 	int ret;
-	u32 w, h;
+	int w, h;
 	u32 fb_start, fb_end;
 
 	debug("bcm2835: Query resolution...\n");
-
-	BCM2835_MBOX_INIT_HDR(msg_query);
-	BCM2835_MBOX_INIT_TAG_NO_REQ(&msg_query->physical_w_h,
-					GET_PHYSICAL_W_H);
-	ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_query->hdr);
+	ret = bcm2835_get_video_size(&w, &h);
 	if (ret) {
-		printf("bcm2835: Could not query display resolution\n");
 		/* FIXME: How to disable the LCD to prevent errors? hang()? */
 		return;
 	}
 
-	w = msg_query->physical_w_h.body.resp.width;
-	h = msg_query->physical_w_h.body.resp.height;
-
 	debug("bcm2835: Setting up display for %d x %d\n", w, h);
 
 	BCM2835_MBOX_INIT_HDR(msg_setup);
-- 
2.11.0.483.g087da7b7c-goog

  parent reply	other threads:[~2017-01-20 14:07 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20 14:07 [U-Boot] [PATCH v4 00/17] arm: rpi: Enable USB, Ethernet, MMC, Video driver model on Raspberry Pi Simon Glass
2017-01-20 14:07 ` [U-Boot] [PATCH v4 01/17] dm: mmc: Set up the MMC device when controller is probed Simon Glass
2017-01-24  6:21   ` Jaehoon Chung
2017-01-20 14:07 ` [U-Boot] [PATCH v4 02/17] dm: video: Correct line clearing code Simon Glass
2017-01-24 14:55   ` Anatolij Gustschin
2017-01-20 14:07 ` [U-Boot] [PATCH v4 03/17] string: Use memcpy() within memmove() when we can Simon Glass
2017-01-23 18:13   ` Tom Rini
2017-01-20 14:07 ` [U-Boot] [PATCH v4 04/17] arm: rpi: Drop the GPIO device addresses Simon Glass
2017-01-20 14:07 ` [U-Boot] [PATCH v4 05/17] arm: rpi: Drop CONFIG_CONS_INDEX Simon Glass
2017-01-20 14:07 ` [U-Boot] [PATCH v4 06/17] dm: arm: rpi: Move to driver model for USB Simon Glass
2017-01-20 14:07 ` [U-Boot] [PATCH v4 07/17] dm: arm: rpi: Use driver model for Ethernet Simon Glass
2017-01-20 14:07 ` [U-Boot] [PATCH v4 08/17] arm: rpi: Add a file to handle messages Simon Glass
2017-01-20 14:07 ` [U-Boot] [PATCH v4 09/17] arm: rpi: Add a function to obtain the MMC clock Simon Glass
2017-01-20 14:07 ` [U-Boot] [PATCH v4 10/17] dm: mmc: rpi: Convert Raspberry Pi to driver model for MMC Simon Glass
2017-01-24  6:51   ` Jaehoon Chung
2017-01-20 14:07 ` [U-Boot] [PATCH v4 11/17] dm: arm: rpi: Drop CONFIG_OF_EMBED Simon Glass
2017-01-20 14:07 ` Simon Glass [this message]
2017-01-24 14:51   ` [U-Boot] [PATCH v4 12/17] video: arm: rpi: Move the video query out of the driver Anatolij Gustschin
2017-01-20 14:07 ` [U-Boot] [PATCH v4 13/17] video: arm: rpi: Move the video settings " Simon Glass
2017-01-24 14:52   ` Anatolij Gustschin
2017-01-20 14:07 ` [U-Boot] [PATCH v4 14/17] dm: video: Refactor lcd_simplefb to prepare for driver model Simon Glass
2017-01-24 14:20   ` Anatolij Gustschin
2017-01-20 14:07 ` [U-Boot] [PATCH v4 15/17] dm: video: Add driver-model support to lcd_simplefb Simon Glass
2017-01-24 14:23   ` Anatolij Gustschin
2017-01-20 14:07 ` [U-Boot] [PATCH v4 16/17] dm: video: arm: rpi: Convert to use driver model for video Simon Glass
2017-01-24 14:29   ` Anatolij Gustschin
2017-01-20 14:07 ` [U-Boot] [PATCH v4 17/17] arm: rpi: Add a TODO to move all messages into the msg handler Simon Glass
2017-01-23 18:22 ` [U-Boot] [PATCH v4 00/17] arm: rpi: Enable USB, Ethernet, MMC, Video driver model on Raspberry Pi Tom Rini
2017-02-06 15:32   ` Simon Glass
2017-04-01  4:19     ` Simon Glass
2017-04-01  4:34       ` Simon Glass
2017-04-05 13:41         ` Tom Rini
2017-04-05 22:25           ` Simon Glass

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=20170120140752.16296-13-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.