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 v5 15/19] video: arm: rpi: Move the video settings out of the driver
Date: Sat,  1 Apr 2017 12:05:52 -0600	[thread overview]
Message-ID: <20170401180556.2416-16-sjg@chromium.org> (raw)
In-Reply-To: <20170401180556.2416-1-sjg@chromium.org>

Add a function to set the video parameters to the msg handler and remove
it from the video driver.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None

 arch/arm/mach-bcm283x/include/mach/msg.h | 17 ++++++++
 arch/arm/mach-bcm283x/msg.c              | 61 ++++++++++++++++++++++++++++
 drivers/video/bcm2835.c                  | 68 +++++---------------------------
 3 files changed, 88 insertions(+), 58 deletions(-)

diff --git a/arch/arm/mach-bcm283x/include/mach/msg.h b/arch/arm/mach-bcm283x/include/mach/msg.h
index c785c43a67..478b1f1c50 100644
--- a/arch/arm/mach-bcm283x/include/mach/msg.h
+++ b/arch/arm/mach-bcm283x/include/mach/msg.h
@@ -31,4 +31,21 @@ int bcm2835_get_mmc_clock(void);
  */
 int bcm2835_get_video_size(int *widthp, int *heightp);
 
+/**
+ * bcm2835_set_video_params() - set the video parameters
+ *
+ * @widthp: Video width to request (returns the actual width selected)
+ * @heightp: Video height to request (returns the actual height selected)
+ * @depth_bpp: Requested bit depth
+ * @pixel_order: Pixel order to use (BCM2835_MBOX_PIXEL_ORDER_...)
+ * @alpha_mode: Alpha transparency mode to use (BCM2835_MBOX_ALPHA_MODE_...)
+ * @fb_basep: Returns base address of frame buffer
+ * @fb_sizep: Returns size of frame buffer
+ * @pitchp: Returns number of bytes in each frame buffer line
+ * @return 0 if OK, -ve on error
+ */
+int bcm2835_set_video_params(int *widthp, int *heightp, int depth_bpp,
+			     int pixel_order, int alpha_mode, ulong *fb_basep,
+			     ulong *fb_sizep, int *pitchp);
+
 #endif
diff --git a/arch/arm/mach-bcm283x/msg.c b/arch/arm/mach-bcm283x/msg.c
index 17266c01a6..92e93ad9e5 100644
--- a/arch/arm/mach-bcm283x/msg.c
+++ b/arch/arm/mach-bcm283x/msg.c
@@ -27,6 +27,20 @@ struct msg_query {
 	u32 end_tag;
 };
 
+struct msg_setup {
+	struct bcm2835_mbox_hdr hdr;
+	struct bcm2835_mbox_tag_physical_w_h physical_w_h;
+	struct bcm2835_mbox_tag_virtual_w_h virtual_w_h;
+	struct bcm2835_mbox_tag_depth depth;
+	struct bcm2835_mbox_tag_pixel_order pixel_order;
+	struct bcm2835_mbox_tag_alpha_mode alpha_mode;
+	struct bcm2835_mbox_tag_virtual_offset virtual_offset;
+	struct bcm2835_mbox_tag_overscan overscan;
+	struct bcm2835_mbox_tag_allocate_buffer allocate_buffer;
+	struct bcm2835_mbox_tag_pitch pitch;
+	u32 end_tag;
+};
+
 int bcm2835_power_on_module(u32 module)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(struct msg_set_power_state, msg_pwr, 1);
@@ -91,3 +105,50 @@ int bcm2835_get_video_size(int *widthp, int *heightp)
 
 	return 0;
 }
+
+int bcm2835_set_video_params(int *widthp, int *heightp, int depth_bpp,
+			     int pixel_order, int alpha_mode, ulong *fb_basep,
+			     ulong *fb_sizep, int *pitchp)
+{
+	ALLOC_CACHE_ALIGN_BUFFER(struct msg_setup, msg_setup, 1);
+	int ret;
+
+	BCM2835_MBOX_INIT_HDR(msg_setup);
+	BCM2835_MBOX_INIT_TAG(&msg_setup->physical_w_h, SET_PHYSICAL_W_H);
+	msg_setup->physical_w_h.body.req.width = *widthp;
+	msg_setup->physical_w_h.body.req.height = *heightp;
+	BCM2835_MBOX_INIT_TAG(&msg_setup->virtual_w_h, SET_VIRTUAL_W_H);
+	msg_setup->virtual_w_h.body.req.width = *widthp;
+	msg_setup->virtual_w_h.body.req.height = *heightp;
+	BCM2835_MBOX_INIT_TAG(&msg_setup->depth, SET_DEPTH);
+	msg_setup->depth.body.req.bpp = 32;
+	BCM2835_MBOX_INIT_TAG(&msg_setup->pixel_order, SET_PIXEL_ORDER);
+	msg_setup->pixel_order.body.req.order = pixel_order;
+	BCM2835_MBOX_INIT_TAG(&msg_setup->alpha_mode, SET_ALPHA_MODE);
+	msg_setup->alpha_mode.body.req.alpha = alpha_mode;
+	BCM2835_MBOX_INIT_TAG(&msg_setup->virtual_offset, SET_VIRTUAL_OFFSET);
+	msg_setup->virtual_offset.body.req.x = 0;
+	msg_setup->virtual_offset.body.req.y = 0;
+	BCM2835_MBOX_INIT_TAG(&msg_setup->overscan, SET_OVERSCAN);
+	msg_setup->overscan.body.req.top = 0;
+	msg_setup->overscan.body.req.bottom = 0;
+	msg_setup->overscan.body.req.left = 0;
+	msg_setup->overscan.body.req.right = 0;
+	BCM2835_MBOX_INIT_TAG(&msg_setup->allocate_buffer, ALLOCATE_BUFFER);
+	msg_setup->allocate_buffer.body.req.alignment = 0x100;
+	BCM2835_MBOX_INIT_TAG_NO_REQ(&msg_setup->pitch, GET_PITCH);
+
+	ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_setup->hdr);
+	if (ret) {
+		printf("bcm2835: Could not configure display\n");
+		return ret;
+	}
+	*widthp = msg_setup->physical_w_h.body.resp.width;
+	*heightp = msg_setup->physical_w_h.body.resp.height;
+	*pitchp = msg_setup->pitch.body.resp.pitch;
+	*fb_basep = bus_to_phys(
+			msg_setup->allocate_buffer.body.resp.fb_address);
+	*fb_sizep = msg_setup->allocate_buffer.body.resp.fb_size;
+
+	return 0;
+}
diff --git a/drivers/video/bcm2835.c b/drivers/video/bcm2835.c
index eb137be11c..cd15f7f32a 100644
--- a/drivers/video/bcm2835.c
+++ b/drivers/video/bcm2835.c
@@ -17,28 +17,13 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Global variables that lcd.c expects to exist */
 vidinfo_t panel_info;
 
-static u32 bcm2835_pitch;
-
-struct msg_setup {
-	struct bcm2835_mbox_hdr hdr;
-	struct bcm2835_mbox_tag_physical_w_h physical_w_h;
-	struct bcm2835_mbox_tag_virtual_w_h virtual_w_h;
-	struct bcm2835_mbox_tag_depth depth;
-	struct bcm2835_mbox_tag_pixel_order pixel_order;
-	struct bcm2835_mbox_tag_alpha_mode alpha_mode;
-	struct bcm2835_mbox_tag_virtual_offset virtual_offset;
-	struct bcm2835_mbox_tag_overscan overscan;
-	struct bcm2835_mbox_tag_allocate_buffer allocate_buffer;
-	struct bcm2835_mbox_tag_pitch pitch;
-	u32 end_tag;
-};
+static int bcm2835_pitch;
 
 void lcd_ctrl_init(void *lcdbase)
 {
-	ALLOC_CACHE_ALIGN_BUFFER(struct msg_setup, msg_setup, 1);
 	int ret;
 	int w, h;
-	u32 fb_start, fb_end;
+	ulong fb_base, fb_size, fb_start, fb_end;
 
 	debug("bcm2835: Query resolution...\n");
 	ret = bcm2835_get_video_size(&w, &h);
@@ -48,42 +33,9 @@ void lcd_ctrl_init(void *lcdbase)
 	}
 
 	debug("bcm2835: Setting up display for %d x %d\n", w, h);
-
-	BCM2835_MBOX_INIT_HDR(msg_setup);
-	BCM2835_MBOX_INIT_TAG(&msg_setup->physical_w_h, SET_PHYSICAL_W_H);
-	msg_setup->physical_w_h.body.req.width = w;
-	msg_setup->physical_w_h.body.req.height = h;
-	BCM2835_MBOX_INIT_TAG(&msg_setup->virtual_w_h, SET_VIRTUAL_W_H);
-	msg_setup->virtual_w_h.body.req.width = w;
-	msg_setup->virtual_w_h.body.req.height = h;
-	BCM2835_MBOX_INIT_TAG(&msg_setup->depth, SET_DEPTH);
-	msg_setup->depth.body.req.bpp = 32;
-	BCM2835_MBOX_INIT_TAG(&msg_setup->pixel_order, SET_PIXEL_ORDER);
-	msg_setup->pixel_order.body.req.order = BCM2835_MBOX_PIXEL_ORDER_RGB;
-	BCM2835_MBOX_INIT_TAG(&msg_setup->alpha_mode, SET_ALPHA_MODE);
-	msg_setup->alpha_mode.body.req.alpha = BCM2835_MBOX_ALPHA_MODE_IGNORED;
-	BCM2835_MBOX_INIT_TAG(&msg_setup->virtual_offset, SET_VIRTUAL_OFFSET);
-	msg_setup->virtual_offset.body.req.x = 0;
-	msg_setup->virtual_offset.body.req.y = 0;
-	BCM2835_MBOX_INIT_TAG(&msg_setup->overscan, SET_OVERSCAN);
-	msg_setup->overscan.body.req.top = 0;
-	msg_setup->overscan.body.req.bottom = 0;
-	msg_setup->overscan.body.req.left = 0;
-	msg_setup->overscan.body.req.right = 0;
-	BCM2835_MBOX_INIT_TAG(&msg_setup->allocate_buffer, ALLOCATE_BUFFER);
-	msg_setup->allocate_buffer.body.req.alignment = 0x100;
-	BCM2835_MBOX_INIT_TAG_NO_REQ(&msg_setup->pitch, GET_PITCH);
-
-	ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_setup->hdr);
-	if (ret) {
-		printf("bcm2835: Could not configure display\n");
-		/* FIXME: How to disable the LCD to prevent errors? hang()? */
-		return;
-	}
-
-	w = msg_setup->physical_w_h.body.resp.width;
-	h = msg_setup->physical_w_h.body.resp.height;
-	bcm2835_pitch = msg_setup->pitch.body.resp.pitch;
+	ret = bcm2835_set_video_params(&w, &h, 32, BCM2835_MBOX_PIXEL_ORDER_RGB,
+				       BCM2835_MBOX_ALPHA_MODE_IGNORED,
+				       &fb_base, &fb_size, &bcm2835_pitch);
 
 	debug("bcm2835: Final resolution is %d x %d\n", w, h);
 
@@ -91,15 +43,14 @@ void lcd_ctrl_init(void *lcdbase)
 	panel_info.vl_row = h;
 	panel_info.vl_bpix = LCD_COLOR32;
 
-	gd->fb_base = bus_to_phys(
-		msg_setup->allocate_buffer.body.resp.fb_address);
+	gd->fb_base = fb_base;
 
 	/* Enable dcache for the frame buffer */
-	fb_start = gd->fb_base & ~(MMU_SECTION_SIZE - 1);
-	fb_end = gd->fb_base + msg_setup->allocate_buffer.body.resp.fb_size;
+	fb_start = fb_base & ~(MMU_SECTION_SIZE - 1);
+	fb_end = fb_base + fb_size;
 	fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT);
 	mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start,
-		DCACHE_WRITEBACK);
+					DCACHE_WRITEBACK);
 	lcd_set_flush_dcache(1);
 }
 
@@ -110,5 +61,6 @@ void lcd_enable(void)
 int lcd_get_size(int *line_length)
 {
 	*line_length = bcm2835_pitch;
+
 	return *line_length * panel_info.vl_row;
 }
-- 
2.12.2.564.g063fe858b8-goog

  parent reply	other threads:[~2017-04-01 18:05 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-01 18:05 [U-Boot] [PATCH v5 00/19] arm: rpi: Enable USB, Ethernet, MMC, Video driver model on Raspberry Pi Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 01/19] net: smsc95xx: Correct free_pkt() implementation Simon Glass
2017-04-02 17:46   ` Joe Hershberger
2017-04-01 18:05 ` [U-Boot] [PATCH v5 02/19] usb: dwc2: Use separate input and output buffers Simon Glass
2017-04-01 20:15   ` Marek Vasut
2017-04-01 23:40     ` Simon Glass
2017-04-02  3:01       ` Marek Vasut
2017-04-02 13:10         ` Stefan Bruens
2017-04-02 15:43           ` Simon Glass
2017-04-02 21:34             ` Stefan Bruens
2017-04-02 23:23               ` Simon Glass
2017-04-03 14:26                 ` Brüns, Stefan
2017-04-03 15:38                   ` Simon Glass
2017-04-03 18:18                     ` Brüns, Stefan
2017-04-03 18:24                       ` Brüns, Stefan
2017-04-03 20:10                         ` Simon Glass
2017-04-03 20:10                       ` Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 03/19] dm: mmc: Set up the MMC device when controller is probed Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 04/19] dm: video: Correct line clearing code Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 05/19] string: Use memcpy() within memmove() when we can Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 06/19] arm: rpi: Drop the GPIO device addresses Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 07/19] arm: rpi: Drop CONFIG_CONS_INDEX Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 08/19] dm: arm: rpi: Move to driver model for USB Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 09/19] dm: arm: rpi: Use driver model for Ethernet Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 10/19] arm: rpi: Add a file to handle messages Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 11/19] arm: rpi: Add a function to obtain the MMC clock Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 12/19] dm: mmc: rpi: Convert Raspberry Pi to driver model for MMC Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 13/19] dm: arm: rpi: Drop CONFIG_OF_EMBED Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 14/19] video: arm: rpi: Move the video query out of the driver Simon Glass
2017-04-01 18:05 ` Simon Glass [this message]
2017-04-01 18:05 ` [U-Boot] [PATCH v5 16/19] dm: video: Refactor lcd_simplefb to prepare for driver model Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 17/19] dm: video: Add driver-model support to lcd_simplefb Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 18/19] dm: video: arm: rpi: Convert to use driver model for video Simon Glass
2017-04-01 18:05 ` [U-Boot] [PATCH v5 19/19] arm: rpi: Add a TODO to move all messages into the msg handler Simon Glass
2017-04-01 19:05 ` [U-Boot] [PATCH v5 00/19] arm: rpi: Enable USB, Ethernet, MMC, Video driver model on Raspberry Pi Stefan Bruens

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=20170401180556.2416-16-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.