Skip to contentSkip to conversation

Framebuffer split

PATCH In review Vladimir 'phcoder' Serbinenko 4 participants 47 messages Jul 23, 2009 – Aug 14, 2009 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH 1/2 Framebuffer split

Hello. Here is a framebuffer split which has already been discussed. This patch contains some code by Collin D Bennett in addition to my code. Sorry for compression but maillist server doesn't accept it otherwise

--
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git

#3 lore raw
Quoted 3 lines · Vladimir 'phcoder' Serbinenko

Hello. Here is a framebuffer split which has already been discussed. This patch contains some code by Collin D Bennett in addition to my code. Sorry for compression but maillist server doesn't accept it otherwise

Please include an uncompressed ChangeLog entry. Even though the issue was discussed, it would help if you include a description of the changes to simplify reviewing. You can copy a previously posted description.

grub_video_vbe_set_viewport and grub_video_vbe_get_info_and_fini need to be declared static to avoid compiler warnings.

Apart from that, no warnings are introduced.

Please don't add trailing whitespace. Since you are using git, you can easily check it with STGit by running "stg edit -d".

grub_video_vbe_get_info_and_fini strikes as a weird name. The comment says:

/* Get information about active video mode. */

Likewise, all occurrences of "get_info_and_fini" should probably be replaced with something more descriptive.

Signature · 2 lines
Regards,
Pavel Roskin
#4 lore raw
Quoted 6 lines · Pavel Roskin
Quoted 3 lines · Vladimir 'phcoder' Serbinenko

Hello. Here is a framebuffer split which has already been discussed. This patch contains some code by Collin D Bennett in addition to my code. Sorry for compression but maillist server doesn't accept it otherwise

Please include an uncompressed ChangeLog entry.

Coming when I have a bit more time

Quoted 3 lines

grub_video_vbe_set_viewport and grub_video_vbe_get_info_and_fini need to be declared static to avoid compiler warnings.

Done

Quoted 5 lines

Apart from that, no warnings are introduced.

Please don't add trailing whitespace.  Since you are using git, you can easily check it with STGit by running "stg edit -d".

I used git diff --color but few whitespace slipped in

Quoted 8 lines

grub_video_vbe_get_info_and_fini strikes as a weird name.  The comment says:

/* Get information about active video mode.  */

Likewise, all occurrences of "get_info_and_fini" should probably be replaced with something more descriptive.

I don't see which comment you refer to but I added a comment to grub_video_get_info_and_fini explaining why it's needed

Quoted 10 lines

--
Regards,
Pavel Roskin

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#5 lore raw

Removed parts which are purely moving code around (of course it will be restored on commit).
2009-07-26 Vladimir Serbinenko <[email protected]> 2009-07-26 Colin D Bennett <[email protected]>

Framebuffer split and double buffering support.

* commands/i386/pc/vbetest.c (grub_cmd_vbetest): Restore video subsystem at the end.
* commands/i386/pc/videotest.c (grub_cmd_videotest): Swap doublebuffers.
* conf/common.rmk (pkglib_MODULES): Add video_fb.mod. (video_fb_mod_SOURCES): New variable. (video_fb_mod_CFLAGS): Likewise.
(video_fb_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (vbe_mod_SOURCES): Remove video/i386/pc/vbeblit.c, video/i386/pc/vbefill.c and video/i386/pc/vbeutil.c.
* video/i386/pc/vbeblit.c: Moved from here ...
* video/fb/fbblit.c: ..here. Replaced 'vbe' with 'fb'.
* video/i386/pc/vbefill.c: Moved from here ...
* video/fb/fbfill.c: ..here. Replaced 'vbe' with 'fb'.
* video/i386/pc/vbeutil.c: Moved from here ...
* video/fb/fbutil.c: ..here. Replaced 'vbe' with 'fb'.
* include/grub/i386/pc/vbeblit.h: Moved from here ...
* include/grub/fbblit.h: ... here. Replaced 'vbe' with 'fb'.
* include/grub/i386/pc/vbefill.h: Moved from here ...
* include/grub/fbfill.h: ... here. Replaced 'vbe' with 'fb'.
* include/grub/i386/pc/vbeutil.h: Moved from here ...
* include/grub/fbutil.h: ... here. Replaced 'vbe' with 'fb'.
* include/grub/i386/pc/vbe.h: Moved framebuffer part ...
* include/grub/video_fb.h: ... here. Replaced 'vbe' with 'fb'.
* include/grub/video.h (GRUB_VIDEO_RENDER_TARGET_FRONT_BUFFER): Removed. (GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER): Likewise. (grub_video_rect): New type.
(grub_video_adapter): Added get_info_and_fini and enable_double_buffering.
(grub_video_get_info_and_fini): New prototype. (grub_video_enable_double_buffering): Likewise. (grub_video_set_mode): make modestring const char *.
* loader/i386/linux.c (grub_linux_setup_video): Use grub_video_get_info_and_fini.
(grub_linux_boot): Move modesetting just before booting.
* loader/i386/pc/xnu.c (grub_xnu_set_video): Use grub_video_get_info_and_fini.
* term/gfxterm.c (redraw_screen_rect): Support double buffering. (dirty_region_redraw): Likewise.
(scroll_up): Likewise.
(grub_gfxterm_putchar): Likewise.
* video/i386/pc/vbe.c: Moved framebuffer part ...
* video/fb/video_fb.c: ... here. Replaced 'vbe' with 'fb'.
* video/i386/pc/vbe.c (doublebuf_state): New variable. (double_buffering_init): New prototype. (grub_vbe_set_video_mode): Use grub_video_fbstd_colors and grub_video_fb_set_palette.
(grub_video_vbe_init): Initialise double buffering and use grub_video_fb_init.
(grub_video_vbe_fini): Finalise double buffering and use grub_video_fb_fini.
(grub_video_vbe_setup): Use framebuffer.render_target instead of render_target and use grub_video_fb_set_active_render_target and grub_video_fb_set_palette.
(doublebuf_pageflipping_commit): New function. (doublebuf_pageflipping_update_screen): Likewise. (doublebuf_blit_update_screen): Likewise. (doublebuf_blit_init): Likewise. (doublebuf_null_update_screen): Likewise. (doublebuf_null_destroy): Likewise.
(doublebuf_null_init): Likewise.
(double_buffering_init): Likewise. (grub_video_vbe_enable_double_buffering): Likewise. (grub_video_vbe_set_palette): Use grub_video_fb_set_palette. (grub_video_vbe_set_viewport): Use grub_video_fb_set_viewport. (grub_video_vbe_swap_buffers): Use update_screen. (grub_video_vbe_adapter): Use framebuffer.
* video/video.c (grub_video_get_info_and_fini): New function. (grub_video_set_mode): Make modestring const char * and use double buffering.
(GRUB_MOD_INIT(video_video)): Don't set variables to 0 since these values are already initialised.

Quoted 19 lines
Quoted 10 lines

--
Regards,
Pavel Roskin

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

--
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
commands/i386/pc/vbetest.c +2 -0
index 3cbc301..314320d 100644
@@ -155,6 +155,8 @@ grub_cmd_vbetest (grub_command_t cmd __attribute__ ((unused)),
 
   grub_getkey ();
 
+  grub_video_restore ();
+
   /* Restore old video mode.  */
   grub_vbe_set_video_mode (old_mode, 0);
 
commands/videotest.c +2 -0
index 6fe4b9b..c4b315a 100644
@@ -160,6 +160,8 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
                                      0, 0, width, height);
     }
 
+ grub_video_swap_buffers ();
+
   grub_getkey ();
 
   grub_video_delete_render_target (text_layer);
conf/common.rmk +6 -1
index 032517f..5e93302 100644
@@ -535,13 +535,18 @@ lua_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # Common Video Subsystem specific modules.
 pkglib_MODULES += video.mod videotest.mod bitmap.mod tga.mod jpeg.mod	\
-	png.mod	font.mod gfxterm.mod
+	png.mod	font.mod gfxterm.mod video_fb.mod
 
 # For video.mod.
 video_mod_SOURCES = video/video.c
 video_mod_CFLAGS = $(COMMON_CFLAGS)
 video_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+video_fb_mod_SOURCES = video/fb/video_fb.c video/fb/fbblit.c \
+		  video/fb/fbfill.c video/fb/fbutil.c
+video_fb_mod_CFLAGS = $(COMMON_CFLAGS)
+video_fb_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 # For videotest.mod.
 videotest_mod_SOURCES = commands/videotest.c
 videotest_mod_CFLAGS = $(COMMON_CFLAGS)
conf/i386-pc.rmk +1 -2
index 798aee2..5b7b8c0 100644
@@ -273,8 +273,7 @@ multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
 multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
 
 # For vbe.mod.
-vbe_mod_SOURCES = video/i386/pc/vbe.c video/i386/pc/vbeblit.c \
-		  video/i386/pc/vbefill.c video/i386/pc/vbeutil.c
+vbe_mod_SOURCES = video/i386/pc/vbe.c
 vbe_mod_CFLAGS = $(COMMON_CFLAGS)
 vbe_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
include/grub/i386/pc/vbe.h +1 -53

65 lines not on this page · raw message

include/grub/video.h +30 -5
index c98731d..ad6dc6d 100644
@@ -48,10 +48,10 @@ struct grub_video_bitmap;
 #define GRUB_VIDEO_MODE_TYPE_DEPTH_MASK		0x0000ff00
 #define GRUB_VIDEO_MODE_TYPE_DEPTH_POS		8
 
-/* Defined predefined render targets.  */
-#define GRUB_VIDEO_RENDER_TARGET_DISPLAY	((struct grub_video_render_target *) 0)
-#define GRUB_VIDEO_RENDER_TARGET_FRONT_BUFFER	((struct grub_video_render_target *) 0)
-#define GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER	((struct grub_video_render_target *) 1)
+/* The basic render target representing the whole display.  This always
+   renders to the back buffer when double-buffering is in use.  */
+#define GRUB_VIDEO_RENDER_TARGET_DISPLAY \
+  ((struct grub_video_render_target *) 0)
 
 /* Defined blitting formats.  */
 enum grub_video_blit_format
@@ -161,6 +161,16 @@ struct grub_video_palette_data
   grub_uint8_t a; /* Reserved bits value (0-255).  */
 };
 
+/* A 2D rectangle type.  */
+struct grub_video_rect
+{
+  int x;
+  int y;
+  int width;
+  int height;
+};
+typedef struct grub_video_rect grub_video_rect_t;
+
 struct grub_video_adapter
 {
   /* The video adapter name.  */
@@ -177,6 +187,9 @@ struct grub_video_adapter
 
   grub_err_t (*get_info) (struct grub_video_mode_info *mode_info);
 
+  grub_err_t (*get_info_and_fini) (struct grub_video_mode_info *mode_info,
+				   void **framebuffer);
+
   grub_err_t (*set_palette) (unsigned int start, unsigned int count,
                              struct grub_video_palette_data *palette_data);
 
@@ -218,6 +231,8 @@ struct grub_video_adapter
 
   grub_err_t (*swap_buffers) (void);
 
+  grub_err_t (*enable_double_buffering) (int enable);
+
   grub_err_t (*create_render_target) (struct grub_video_render_target **result,
                                       unsigned int width, unsigned int height,
                                       unsigned int mode_type);
@@ -241,6 +256,14 @@ grub_err_t grub_video_restore (void);
 
 grub_err_t grub_video_get_info (struct grub_video_mode_info *mode_info);
 
+/* Framebuffer address may change as a part of normal operation
+   (e.g. double buffering). That's why you need to stop video subsystem to be
+   sure that framebuffer address doesn't change. To ensure this abstraction
+   grub_video_get_info_and_fini is the only function supplying framebuffer
+   address. */
+grub_err_t grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info,
+					 void **framebuffer);
+
 enum grub_video_blit_format grub_video_get_blit_format (struct grub_video_mode_info *mode_info);
 
 grub_err_t grub_video_set_palette (unsigned int start, unsigned int count,
@@ -286,6 +309,8 @@ grub_err_t grub_video_scroll (grub_video_color_t color, int dx, int dy);
 
 grub_err_t grub_video_swap_buffers (void);
 
+grub_err_t grub_video_enable_double_buffering (int enable);
+
 grub_err_t grub_video_create_render_target (struct grub_video_render_target **result,
                                             unsigned int width,
                                             unsigned int height,
@@ -297,7 +322,7 @@ grub_err_t grub_video_set_active_render_target (struct grub_video_render_target
 
 grub_err_t grub_video_get_active_render_target (struct grub_video_render_target **target);
 
-grub_err_t grub_video_set_mode (char *modestring,
+grub_err_t grub_video_set_mode (const char *modestring,
 				int NESTED_FUNC_ATTR (*hook) (grub_video_adapter_t p,
 							      struct grub_video_mode_info *mode_info));
 
include/grub/video_fb.h new file +137 -0

137 lines not on this page · raw message

loader/i386/linux.c +39 -44

116 lines not on this page · raw message

loader/i386/pc/xnu.c +4 -9
index 037a713..69a9405 100644
@@ -21,8 +21,7 @@
 #include <grub/xnu.h>
 #include <grub/mm.h>
 #include <grub/cpu/xnu.h>
-#include <grub/machine/vbe.h>
-#include <grub/machine/vga.h>
+#include <grub/video_fb.h>
 
 #define min(a,b) (((a) < (b)) ? (a) : (b))
 #define max(a,b) (((a) > (b)) ? (a) : (b))
@@ -43,10 +42,10 @@ grub_err_t
 grub_xnu_set_video (struct grub_xnu_boot_params *params)
 {
   struct grub_video_mode_info mode_info;
-  struct grub_video_render_target *render_target;
   int ret;
   int x,y;
   char *tmp, *modevar;
+  void *framebuffer;
   grub_err_t err;
 
   modevar = grub_env_get ("gfxpayload");
@@ -67,11 +66,7 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params)
   if (err)
     return err;
 
-  ret = grub_video_get_info (&mode_info);
-  if (ret)
-    return grub_error (GRUB_ERR_IO, "couldn't retrieve video parameters");
-
-  ret = grub_video_get_active_render_target (&render_target);
+  ret = grub_video_get_info_and_fini (&mode_info, &framebuffer);
   if (ret)
     return grub_error (GRUB_ERR_IO, "couldn't retrieve video parameters");
 
@@ -102,7 +97,7 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params)
   params->lfb_depth = mode_info.bpp;
   params->lfb_line_len = mode_info.pitch;
 
-  params->lfb_base = PTR_TO_UINT32 (render_target->data);
+  params->lfb_base = PTR_TO_UINT32 (framebuffer);
   params->lfb_mode = grub_xnu_bitmap
     ? GRUB_XNU_VIDEO_SPLASH : GRUB_XNU_VIDEO_TEXT_IN_VIDEO;
 
term/gfxterm.c +7 -0
index 61cf0e7..775bc60 100644
@@ -397,6 +397,8 @@ redraw_screen_rect (unsigned int x, unsigned int y,
                                      y - virtual_screen.offset_y,
 				     width, height);
     }
+
+  grub_video_swap_buffers ();
 }
 
 static void
@@ -474,6 +476,7 @@ dirty_region_redraw (void)
   redraw_screen_rect (x, y, width, height);
 
   dirty_region_reset ();
+  grub_video_swap_buffers ();
 }
 
 static void
@@ -614,6 +617,8 @@ scroll_up (void)
       if (virtual_screen.cursor_state)
 	draw_cursor (1);
     }
+
+  grub_video_swap_buffers ();
 }
 
 static void
@@ -709,5 +714,7 @@ grub_gfxterm_putchar (grub_uint32_t c)
      above call to write_char is redundant when the cursor is showing.  */
   if (virtual_screen.cursor_state)
     draw_cursor (1);
+
+  grub_video_swap_buffers ();
 }
 
video/fb/video_fb.c new file +1100 -0

1,100 lines not on this page · raw message

video/i386/pc/vbe.c +242 -1057

1,391 lines not on this page · raw message

video/video.c +35 -3
index c22947b..b7df580 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#6 lore raw
Quoted 2 lines · Vladimir 'phcoder' Serbinenko

Removed parts which are purely moving code around (of course it will be restored on commit).

This is not a full review of the patch, just a quick overview. But I have a few comments:

- The "fb" naming is confusing. "framebuffer" refers to a Linux API exported to userland on GNU/Linux, but it seems to be used for referring to the backend. I think it's better if we call it just that ("backend"). Or maybe "driver" but that doesn't apply well to vbe.

- Some copyright years need updating (I noticed video_fb.h, but please review the other files as well).

- It'd help if the patch could actually be split in standalone parts that can be committed separately. Maybe this is not possible, but at least for some parts of it, it probably is.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#7 lore raw
Quoted 4 lines · Robert Millan
Quoted 2 lines · Vladimir 'phcoder' Serbinenko

Removed parts which are purely moving code around (of course it will be restored on commit).

Quoted 8 lines

This is not a full review of the patch, just a quick overview.  But I have a few comments:

 - The "fb" naming is confusing.  "framebuffer" refers to a Linux API exported to userland on GNU/Linux, but it seems to be used for referring to the backend.  I think it's better if we call it just that ("backend").  Or maybe "driver" but that doesn't apply well to vbe.

backend and driver aren't good names because it's neither a complete backend nor a driver. It's more like a functions library which can be used by drivers. Prefix video_fb was chosen deliberately to avoid names to become too long. I don't think that video_fb is of any more problem than video_vbe since FB is a widely used abbreviation when speaking about graphics.

Quoted 4 lines

 - Some copyright years need updating (I noticed video_fb.h, but please review the other files as well).

Thanks

Quoted 4 lines

 - It'd help if the patch could actually be split in standalone parts that can be committed separately.  Maybe this is not possible, but at least for some parts of it, it probably is.

Some parts yes but the main part of patch is dispatching functions from vbe.c and splitting it may cause intermediary states to be easily broken.

Quoted 13 lines

--
Robert Millan

 The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#8 lore raw
Quoted 8 lines · Vladimir 'phcoder' Serbinenko
Quoted 7 lines · Robert Millan
Quoted 2 lines · Vladimir 'phcoder' Serbinenko

Removed parts which are purely moving code around (of course it will be restored on commit).

This is not a full review of the patch, just a quick overview.  But I have a few comments:

Quoted 8 lines
Quoted 5 lines

 - The "fb" naming is confusing.  "framebuffer" refers to a Linux API exported to userland on GNU/Linux, but it seems to be used for referring to the backend.  I think it's better if we call it just that ("backend").  Or maybe "driver" but that doesn't apply well to vbe.

backend and driver aren't good names because it's neither a complete backend nor a driver. It's more like a functions library which can be used by drivers.

Well, that fits the definition of backend.

Quoted 4 lines

Prefix video_fb was chosen deliberately to avoid
names to become too long. I don't think that video_fb is of any more problem than video_vbe since FB is a widely used abbreviation when speaking about graphics.

Yes, but in this case we're speaking about the category where VBE belongs to. If people read "backend", that inmediately conveys an idea on what it does.

If they read "fb", they just know it has something to do with video, but they already knew that, so in practice it doesn't provide any information.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#9 lore raw
Quoted 2 lines

Well, that fits the definition of backend.

But there are other backends too - network backend, opengl backend, ... Framebuffer is a term often used to designated memory ranged which is mapped to the screen.
May we stop discussing about names and rather either commit or discuss technical details?

Quoted 14 lines

--
Robert Millan

 The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#10 lore raw
Quoted 5 lines · Vladimir 'phcoder' Serbinenko
Quoted 2 lines

Well, that fits the definition of backend.

But there are other backends too - network backend, opengl backend, ... Framebuffer is a term often used to designated memory ranged which is mapped to the screen.

Ok then. I think I got confused by the common usage of this term, which often refers to the whole thing. I'm fine with it, as long as it's used consistently.

Quoted 2 lines

May we stop discussing about names and rather either commit or discuss technical details?

Names are very important. When someone who's not familiar with the code is trying to figure it out, if the name of a function or an interface inmediately evokes an idea of what it does, that person won't have to check. It makes working with GRUB much more efficient.

I'll look at the technical part of the patch now.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#11 lore raw

2009/8/1 Robert Millan <[email protected]>:

Quoted 10 lines · Vladimir 'phcoder' Serbinenko
Quoted 5 lines
Quoted 2 lines

Well, that fits the definition of backend.

But there are other backends too - network backend, opengl backend, ... Framebuffer is a term often used to designated memory ranged which is mapped to the screen.

Ok then.  I think I got confused by the common usage of this term, which often refers to the whole thing.  I'm fine with it, as long as it's used consistently.

Yes, I can agree with "framebuffer" being used for the memory storing the display data, X has fb library, many other graphics libraries have bf handling routines but the most well known one is the Linux "framebuffer console" - the console using the Linux framebuffer library.

Quoted 9 lines
Quoted 3 lines

May we stop discussing about names and rather either commit or discuss technical details?

Names are very important.  When someone who's not familiar with the code is trying to figure it out, if the name of a function or an interface inmediately evokes an idea of what it does, that person won't have to check.  It makes working with GRUB much more efficient.

For me backend is just something generic that can do just about anything (even compilers have a backend) but framebuffer evokes the thought of rectangular memory area storing the picture shown on the screen.

Thanks

Michal

#12 lore raw
Quoted 28 lines · Michal Suchanek

2009/8/1 Robert Millan <[email protected]>:

Quoted 10 lines · Vladimir 'phcoder' Serbinenko
Quoted 5 lines
Quoted 2 lines

Well, that fits the definition of backend.

But there are other backends too - network backend, opengl backend, ... Framebuffer is a term often used to designated memory ranged which is mapped to the screen.

Ok then.  I think I got confused by the common usage of this term, which often refers to the whole thing.  I'm fine with it, as long as it's used consistently.

Yes, I can agree with "framebuffer" being used for the memory storing the display data, X has fb library, many other graphics libraries have bf handling routines but the most well known one is the Linux "framebuffer console" - the console using the Linux framebuffer library.

Quoted 9 lines
Quoted 3 lines

May we stop discussing about names and rather either commit or discuss technical details?

Names are very important.  When someone who's not familiar with the code is trying to figure it out, if the name of a function or an interface inmediately evokes an idea of what it does, that person won't have to check.  It makes working with GRUB much more efficient.

Quoted 4 lines

For me backend is just something generic that can do just about anything (even compilers have a backend) but framebuffer evokes the thought of rectangular memory area storing the picture shown on the screen.

I stand corrected.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#13 lore raw
In reply to Vladimir 'phcoder' Serbinenko
Quoted 4 lines · Vladimir 'phcoder' Serbinenko
   grub_err_t (*get_info) (struct grub_video_mode_info *mode_info);
include/grub/video.h +2 -0
+  grub_err_t (*get_info_and_fini) (struct grub_video_mode_info *mode_info,
+				   void **framebuffer);

include/grub/video.h grub_err_t grub_video_restore (void); · line 266

Quoted 10 lines
include/grub/video.h +9 -0
+
[...]
+/* Framebuffer address may change as a part of normal operation
+   (e.g. double buffering). That's why you need to stop video subsystem to be
+   sure that framebuffer address doesn't change. To ensure this abstraction
+   grub_video_get_info_and_fini is the only function supplying framebuffer
+   address. */
+grub_err_t grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info,
+					 void **framebuffer);
+

I see that returning framebuffer address and finishing the video subsystem must be together, but is there a reason to couple this with getting mode_info ?

If mode_info is also affected by this problem, or if getting mode info only makes sense in a situation in which we'd also want to obtain framebuffer address or finishing the subsystem, then the existing get_info() function is no longer necessary.

Otherwise, users who want both things can just invoke get_info() first and then the new function to obtain FB address.

Btw, if I understand correctly, we have a race condition right now. As a bugfix it'd be better to merge this separately from the interface redesign if possible.

Also, does finishing the video subsystem only affect GRUB internally, or result in any effect at the display level? I want to avoid having visual glitches when the payload is loaded without switching video mode.

loader/i386/linux.c grub_linux_boot (void) · line 486

Quoted 11 lines
loader/i386/linux.c +0 -10
-  modevar = grub_env_get ("gfxpayload");
-
-  /* Now all graphical modes are acceptable.
-     May change in future if we have modes without framebuffer.  */
[...]
-    {
-      params->have_vga = GRUB_VIDEO_TYPE_TEXT;
-      params->video_width = 80;
-      params->video_height = 25;
-    }
-

Why is this chunk of code moved down? AFAICS, this change only involves adding an additional layer between it and the video backend. Does this make it conflict with something else?

Quoted 1 line

+#define grub_video_render_target grub_video_fbrender_target

If we want to rename this function, I'd rather do it all the way than keeping a compatibility macro. But then, I'd also prefer if this is done separately from the rest (either before or after).

video/i386/pc/vbe.c grub_video_vbe_setup (unsigned int width, unsigned int height, · line 677

Quoted 3 lines
video/i386/pc/vbe.c +3 -0
+/* Select the best double buffering mode available.  */
+static void
+double_buffering_init (int enable)

This patch also seems to add double buffering support, which is a feature that wasn't yet implemented. I suppose it's good to have (I'm not very clued about graphics), but I'd prefer if we can merge this separately from the redesign changes.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#14 lore raw
Quoted 3 lines

I see that returning framebuffer address and finishing the video subsystem must be together, but is there a reason to couple this with getting mode_info ?

When designing this part I thought of accelerated graphics. Before loading the OS they would switch to standard framebuffer mode this may also affect the formats used so the info may be different from get_info

Quoted 4 lines

Btw, if I understand correctly, we have a race condition right now.  As a bugfix it'd be better to merge this separately from the interface redesign if possible.

race condition? We don't even have threads

Quoted 5 lines

Also, does finishing the video subsystem only affect GRUB internally, or result in any effect at the display level?  I want to avoid having visual glitches when the payload is loaded without switching video mode.

Other than addition of double buffering changes will not result in any visible effect.

Quoted 7 lines
Quoted 7 lines

-  modevar = grub_env_get ("gfxpayload");
-
-  /* Now all graphical modes are acceptable.
-     May change in future if we have modes without framebuffer.  */ [...]
-    {
-      params->have_vga = GRUB_VIDEO_TYPE_TEXT;

Quoted 9 lines
Quoted 4 lines

-      params->video_width = 80;
-      params->video_height = 25;
-    }
-

Why is this chunk of code moved down?  AFAICS, this change only involves adding an additional layer between it and the video backend.  Does this make it conflict with something else?

I wanted to keep normal grub_printf as long as possible and after get_mode_and_fini grub_printf may be unfunctional.

Quoted 6 lines
Quoted 1 line

+#define grub_video_render_target grub_video_fbrender_target

If we want to rename this function, I'd rather do it all the way than keeping a compatibility macro.  But then, I'd also prefer if this is done separately from the rest (either before or after).

It's not about renaming but to inform includes that grub_video_render_target is in fact grub_video_fbrender_target and so avoid warnings and casts.

Quoted 9 lines

video/i386/pc/vbe.c grub_video_vbe_setup (unsigned int width, unsigned int height, · line 677

Quoted 3 lines
video/i386/pc/vbe.c +3 -0
+/* Select the best double buffering mode available.  */
+static void
+double_buffering_init (int enable)

This patch also seems to add double buffering support, which is a feature that wasn't yet implemented.  I suppose it's good to have (I'm not very clued about graphics), but I'd prefer if we can merge this separately from the redesign changes.

Ok, I will try to split while keeping patch functional.

Quoted 13 lines

--
Robert Millan

 The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#15 lore raw
Quoted 1 line · Vladimir 'phcoder' Serbinenko

Ok, I will try to split while keeping patch functional.

Done

Quoted 22 lines
Quoted 8 lines

--
Robert Millan

 The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

Quoted 5 lines

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

--
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#16 lore raw

As requested a patch with moving of code omitted

Quoted 35 lines · Vladimir 'phcoder' Serbinenko
Quoted 1 line · Vladimir 'phcoder' Serbinenko

Ok, I will try to split while keeping patch functional.

Done

Quoted 16 lines
Quoted 8 lines

--
Robert Millan

 The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

Quoted 5 lines

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 6 lines

--
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git

--
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
ChangeLog +54 -0
index d7f219b..7713e29 100644
@@ -1,3 +1,57 @@
+2009-07-26  Vladimir Serbinenko  <[email protected]>
+
+	Framebuffer split.
+
+	* commands/i386/pc/vbetest.c (grub_cmd_vbetest): Restore video
+	subsystem at the end.
+	* conf/common.rmk (pkglib_MODULES): Add video_fb.mod.
+	(video_fb_mod_SOURCES): New variable.
+	(video_fb_mod_CFLAGS): Likewise.
+	(video_fb_mod_LDFLAGS): Likewise.
+	* conf/i386-pc.rmk (vbe_mod_SOURCES): Remove video/i386/pc/vbeblit.c,
+	video/i386/pc/vbefill.c and video/i386/pc/vbeutil.c.
+	* video/i386/pc/vbeblit.c: Moved from here ...
+	* video/fb/fbblit.c: ..here. Replaced 'vbe' with 'fb'.
+	* video/i386/pc/vbefill.c: Moved from here ...
+	* video/fb/fbfill.c: ..here. Replaced 'vbe' with 'fb'.
+	* video/i386/pc/vbeutil.c: Moved from here ...
+	* video/fb/fbutil.c: ..here. Replaced 'vbe' with 'fb'.
+	* include/grub/i386/pc/vbeblit.h: Moved from here ...
+	* include/grub/fbblit.h: ... here. Replaced 'vbe' with 'fb'.
+	* include/grub/i386/pc/vbefill.h: Moved from here ...
+	* include/grub/fbfill.h: ... here. Replaced 'vbe' with 'fb'.
+	* include/grub/i386/pc/vbeutil.h: Moved from here ...
+	* include/grub/fbutil.h: ... here. Replaced 'vbe' with 'fb'.
+	* include/grub/i386/pc/vbe.h: Moved framebuffer part ...
+	* include/grub/video_fb.h: ... here. Replaced 'vbe' with 'fb'.
+	* include/grub/video.h (GRUB_VIDEO_RENDER_TARGET_FRONT_BUFFER): Removed.
+	(GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER): Likewise.
+	(grub_video_adapter): Added 'get_info_and_fini'.
+	(grub_video_get_info_and_fini): New prototype.
+	(grub_video_set_mode): make modestring const char *.
+	* loader/i386/linux.c (grub_linux_setup_video): Use
+	grub_video_get_info_and_fini.
+	(grub_linux_boot): Move modesetting just before booting.
+	* loader/i386/pc/xnu.c (grub_xnu_set_video): Use
+	grub_video_get_info_and_fini.
+	* video/i386/pc/vbe.c: Moved framebuffer part ...
+	* video/fb/video_fb.c: ... here. Replaced 'vbe' with 'fb'.
+	* video/i386/pc/vbe.c (grub_vbe_set_video_mode): Use
+	grub_video_fbstd_colors and grub_video_fb_set_palette.
+	(grub_video_vbe_init): Clear 'framebuffer' variable and use
+	grub_video_fb_init.
+	(grub_video_vbe_fini): Use grub_video_fb_fini.
+	(grub_video_vbe_setup): Use framebuffer.render_target instead of
+	render_target and use grub_video_fb_set_active_render_target and
+	grub_video_fb_set_palette.
+	(grub_video_vbe_set_palette): Use grub_video_fb_set_palette.
+	(grub_video_vbe_set_viewport): Use grub_video_fb_set_viewport.
+	(grub_video_vbe_adapter): Use framebuffer.
+	* video/video.c (grub_video_get_info_and_fini): New function.
+	(grub_video_set_mode): Make modestring const char *.
+	(GRUB_MOD_INIT(video_video)): Don't set variables to 0 since these
+	values are already initialised.
+
 2009-08-01  Vladimir Serbinenko  <[email protected]>
 
 	* util/hostfs.c (grub_hostfs_dir): Don't use DT_DIR: It doesn't work
commands/i386/pc/vbetest.c +2 -0
index 3cbc301..314320d 100644
@@ -155,6 +155,8 @@ grub_cmd_vbetest (grub_command_t cmd __attribute__ ((unused)),
 
   grub_getkey ();
 
+  grub_video_restore ();
+
   /* Restore old video mode.  */
   grub_vbe_set_video_mode (old_mode, 0);
 
conf/common.rmk +6 -1
index 032517f..5e93302 100644
@@ -535,13 +535,18 @@ lua_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # Common Video Subsystem specific modules.
 pkglib_MODULES += video.mod videotest.mod bitmap.mod tga.mod jpeg.mod	\
-	png.mod	font.mod gfxterm.mod
+	png.mod	font.mod gfxterm.mod video_fb.mod
 
 # For video.mod.
 video_mod_SOURCES = video/video.c
 video_mod_CFLAGS = $(COMMON_CFLAGS)
 video_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+video_fb_mod_SOURCES = video/fb/video_fb.c video/fb/fbblit.c \
+		  video/fb/fbfill.c video/fb/fbutil.c
+video_fb_mod_CFLAGS = $(COMMON_CFLAGS)
+video_fb_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 # For videotest.mod.
 videotest_mod_SOURCES = commands/videotest.c
 videotest_mod_CFLAGS = $(COMMON_CFLAGS)
conf/i386-pc.rmk +1 -2
index 798aee2..5b7b8c0 100644
@@ -273,8 +273,7 @@ multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
 multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
 
 # For vbe.mod.
-vbe_mod_SOURCES = video/i386/pc/vbe.c video/i386/pc/vbeblit.c \
-		  video/i386/pc/vbefill.c video/i386/pc/vbeutil.c
+vbe_mod_SOURCES = video/i386/pc/vbe.c
 vbe_mod_CFLAGS = $(COMMON_CFLAGS)
 vbe_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
include/grub/i386/pc/vbe.h +1 -53

65 lines not on this page · raw message

include/grub/video.h +14 -5
index c98731d..4145db4 100644
@@ -48,10 +48,8 @@ struct grub_video_bitmap;
 #define GRUB_VIDEO_MODE_TYPE_DEPTH_MASK		0x0000ff00
 #define GRUB_VIDEO_MODE_TYPE_DEPTH_POS		8
 
-/* Defined predefined render targets.  */
-#define GRUB_VIDEO_RENDER_TARGET_DISPLAY	((struct grub_video_render_target *) 0)
-#define GRUB_VIDEO_RENDER_TARGET_FRONT_BUFFER	((struct grub_video_render_target *) 0)
-#define GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER	((struct grub_video_render_target *) 1)
+#define GRUB_VIDEO_RENDER_TARGET_DISPLAY \
+  ((struct grub_video_render_target *) 0)
 
 /* Defined blitting formats.  */
 enum grub_video_blit_format
@@ -177,6 +175,9 @@ struct grub_video_adapter
 
   grub_err_t (*get_info) (struct grub_video_mode_info *mode_info);
 
+  grub_err_t (*get_info_and_fini) (struct grub_video_mode_info *mode_info,
+				   void **framebuffer);
+
   grub_err_t (*set_palette) (unsigned int start, unsigned int count,
                              struct grub_video_palette_data *palette_data);
 
@@ -241,6 +242,14 @@ grub_err_t grub_video_restore (void);
 
 grub_err_t grub_video_get_info (struct grub_video_mode_info *mode_info);
 
+/* Framebuffer address may change as a part of normal operation
+   (e.g. double buffering). That's why you need to stop video subsystem to be
+   sure that framebuffer address doesn't change. To ensure this abstraction
+   grub_video_get_info_and_fini is the only function supplying framebuffer
+   address. */
+grub_err_t grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info,
+					 void **framebuffer);
+
 enum grub_video_blit_format grub_video_get_blit_format (struct grub_video_mode_info *mode_info);
 
 grub_err_t grub_video_set_palette (unsigned int start, unsigned int count,
@@ -297,7 +306,7 @@ grub_err_t grub_video_set_active_render_target (struct grub_video_render_target
 
 grub_err_t grub_video_get_active_render_target (struct grub_video_render_target **target);
 
-grub_err_t grub_video_set_mode (char *modestring,
+grub_err_t grub_video_set_mode (const char *modestring,
 				int NESTED_FUNC_ATTR (*hook) (grub_video_adapter_t p,
 							      struct grub_video_mode_info *mode_info));
 
include/grub/video_fb.h new file +137 -0

137 lines not on this page · raw message

loader/i386/linux.c +39 -44

116 lines not on this page · raw message

loader/i386/pc/xnu.c +4 -9
index 037a713..69a9405 100644
@@ -21,8 +21,7 @@
 #include <grub/xnu.h>
 #include <grub/mm.h>
 #include <grub/cpu/xnu.h>
-#include <grub/machine/vbe.h>
-#include <grub/machine/vga.h>
+#include <grub/video_fb.h>
 
 #define min(a,b) (((a) < (b)) ? (a) : (b))
 #define max(a,b) (((a) > (b)) ? (a) : (b))
@@ -43,10 +42,10 @@ grub_err_t
 grub_xnu_set_video (struct grub_xnu_boot_params *params)
 {
   struct grub_video_mode_info mode_info;
-  struct grub_video_render_target *render_target;
   int ret;
   int x,y;
   char *tmp, *modevar;
+  void *framebuffer;
   grub_err_t err;
 
   modevar = grub_env_get ("gfxpayload");
@@ -67,11 +66,7 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params)
   if (err)
     return err;
 
-  ret = grub_video_get_info (&mode_info);
-  if (ret)
-    return grub_error (GRUB_ERR_IO, "couldn't retrieve video parameters");
-
-  ret = grub_video_get_active_render_target (&render_target);
+  ret = grub_video_get_info_and_fini (&mode_info, &framebuffer);
   if (ret)
     return grub_error (GRUB_ERR_IO, "couldn't retrieve video parameters");
 
@@ -102,7 +97,7 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params)
   params->lfb_depth = mode_info.bpp;
   params->lfb_line_len = mode_info.pitch;
 
-  params->lfb_base = PTR_TO_UINT32 (render_target->data);
+  params->lfb_base = PTR_TO_UINT32 (framebuffer);
   params->lfb_mode = grub_xnu_bitmap
     ? GRUB_XNU_VIDEO_SPLASH : GRUB_XNU_VIDEO_TEXT_IN_VIDEO;
 
video/fb/video_fb.c new file +1100 -0

1,100 lines not on this page · raw message

video/i386/pc/vbe.c +84 -1098

1,322 lines not on this page · raw message

video/video.c +19 -3
index c22947b..36ebfd1 100644
@@ -93,6 +93,24 @@ grub_video_get_info (struct grub_video_mode_info *mode_info)
   return grub_video_adapter_active->get_info (mode_info);
 }
 
+/* Get information about active video mode.  */
+grub_err_t
+grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info,
+			      void **framebuffer)
+{
+  grub_err_t err;
+
+  if (! grub_video_adapter_active)
+    return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated");
+
+  err = grub_video_adapter_active->get_info_and_fini (mode_info, framebuffer);
+  if (err)
+    return err;
+
+  grub_video_adapter_active = 0;
+  return GRUB_ERR_NONE;
+}
+
 /* Determine optimized blitting formation for specified video mode info.  */
 enum grub_video_blit_format
 grub_video_get_blit_format (struct grub_video_mode_info *mode_info)
@@ -380,7 +398,7 @@ grub_video_get_active_render_target (struct grub_video_render_target **target)
 }
 
 grub_err_t
-grub_video_set_mode (char *modestring,
+grub_video_set_mode (const char *modestring,
 		     int NESTED_FUNC_ATTR (*hook) (grub_video_adapter_t p,
 						   struct grub_video_mode_info *mode_info))
 {
@@ -695,8 +713,6 @@ grub_video_set_mode (char *modestring,
 /* Initialize Video API module.  */
 GRUB_MOD_INIT(video_video)
 {
-  grub_video_adapter_active = 0;
-  grub_video_adapter_list = 0;
 }
 
 /* Finalize Video API module.  */
#17 lore raw

Hello

I cannot get any sense of these patches "with moving code around omitted" so I tried the git repository in Vladimir's signature.

Maybe I am missing something but the function of this code escapes me:

static grub_err_t
grub_video_vbe_set_viewport (unsigned int x, unsigned int y,
unsigned int width, unsigned int height)
{
/* Make sure viewport is withing screen dimensions. If viewport was set
to be out of the region, mark its size as zero. */
if (x > active_mode_info.x_resolution)

    {
      x = 0;
      width = 0;
    }
  if (y > active_mode_info.y_resolution)
    {
      y = 0;
      height = 0;
    }

  if (x + width > active_mode_info.x_resolution)
    width = active_mode_info.x_resolution - x;

if (y + height > active_mode_info.y_resolution)

    height = active_mode_info.y_resolution - y;

return grub_video_fb_set_viewport (x, y, width, height);
}

As I understand it the code checks the bounds against the active videomode and then sets the viewport on the active render target. Since the active render target can be arbitrarily set by the user (to, say an offscreen bitmap for rendering the terminal text) I do not see how these two parts match.

Thanks

Michal

#18 lore raw

2009/8/8 Michal Suchanek <[email protected]>:

Quoted 33 lines

Hello

I cannot get any sense of these patches "with moving code around omitted" so I tried the git repository in Vladimir's signature.

Maybe I am missing something but the function of this code escapes me:

static grub_err_t
grub_video_vbe_set_viewport (unsigned int x, unsigned int y, unsigned int width, unsigned int height) {
 /* Make sure viewport is withing screen dimensions.  If viewport was set to be out of the region, mark its size as zero.  */
 if (x > active_mode_info.x_resolution)
   {
     x = 0;
     width = 0;
   }

 if (y > active_mode_info.y_resolution)
   {
     y = 0;
     height = 0;
   }

 if (x + width > active_mode_info.x_resolution)
   width = active_mode_info.x_resolution - x;

 if (y + height > active_mode_info.y_resolution) height = active_mode_info.y_resolution - y; return grub_video_fb_set_viewport (x, y, width, height); }

Quoted 6 lines

As I understand it the code checks the bounds against the active videomode and then sets the viewport on the active render target. Since the active render target can be arbitrarily set by the user (to, say an offscreen bitmap for rendering the terminal text) I do not see how these two parts match.

It seems that this check should be done in grub_video_fb_set_viewport instead, and this function completely eliminated until viewport on non-active target can be set. The assumption about bounds being checked beforehand could break for the blit* functions in fbblit.c because the video_fb blit dispatcher only checks viewport on the target, and viewport is not checked against mode when set.

There is get_data_ptr in fbutil.c and grub_video_fb_get_video_ptr in video_fb.c that seem to do the same thing. They do not have the warning abut bounds checking which they do not do. This warning is also missing from get/set_pixel.

Perhaps there should also be get/set_pixel method for video adapters? The functions in fbutil.c probably should not be used from outside fb this library but there are no user counterparts in video_fb.c

Thanks

Michal

#19 lore raw
In reply to Michal Suchanek
Quoted 6 lines

As I understand it the code checks the bounds against the active videomode and then sets the viewport on the active render target. Since the active render target can be arbitrarily set by the user (to, say an offscreen bitmap for rendering the terminal text) I do not see how these two parts match.

Well this code was already there before my patch. I just restructured it. It basically requires viewport to be legal. For offscreen rendering use allocate_render_target
In my patch I tried not to modify the behaviour as far as possible. Your comments about improving the design are welcome but could you start a separate thread? If an improvement that you propose is small in code send a patch together with proposal - it allows to speak about something that is here rather something that could be. If it's bigger then discuss before implementing, perhaps send a small pseudo-patch which shows how it will be implemented. Pseudo patches don't have to work but are just for discussion.

Quoted 11 lines

Thanks

Michal

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#20 lore raw
In reply to Vladimir 'phcoder' Serbinenko

Hello,

both in the previous complete patch and Vladimir's git repository introduce a grub_video_rect_t type.

Is there some intention to change the interface to use this structure?

I was looking at the the various places that use points and rectangles. It's quite inconsistent and unclear now.

There is an anonymous viewport structure inside render target which is the same as the rectangle type. Many coordinates and sizes are signed and many are unsigned leading to numerous casts and/or signed vs unsigned comparison warnings.

The blit functions take a rectangle and a point specified as six separate integers which makes it somewhat unclear what is what.

The other thing that bothers me is that the video drivers fill in the render target structure during video initialization.

In my view the render target structure should not be public. The video driver should fill in the video mode structure and then call a function that fills in render target based on video mode and video data (framebuffer memory). This code is currently replicated needlessly in the vbe and sdl drivers.

Bitmaps could be created in the same way.

Thanks

Michal

#21 lore raw
Quoted 4 lines · Michal Suchanek

Hello,

both in the previous complete patch and Vladimir's git repository introduce a grub_video_rect_t type.

This is from Collin's double buffering patch.

Quoted 4 lines

The other thing that bothers me is that the video drivers fill in the render target structure during video initialization.

In my view the render target structure should not be public.

It isn't. If you read the code you'll see that video_render_target is anonymous structure except in drivers.

Quoted 5 lines

The video
driver should fill in the video mode structure and then call a function that fills in render target based on video mode and video data (framebuffer memory). This code is currently replicated needlessly in the vbe and sdl drivers.

I split on the most natural spot I found - render targets. Everything that works with render targets is moved to video_fb. Perhaps it's not the best spot but cutting at natural function ensures drivers won't have to undo something video_fb does. In future if drivers share code which can be moved to vide_fb then I'm ok with it but I prefer to see more real drivers first before fine-tuning split limit especially away fro ma natural spot
As for moving data from video info to render target the problem is that video_fb can't be aware about the structures used by drivers. and so I see no way around it

Quoted 13 lines

Bitmaps could be created in the same way.

Thanks

Michal

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#22 lore raw

2009/8/10 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 6 lines · Michal Suchanek
Quoted 4 lines

Hello,

both in the previous complete patch and Vladimir's git repository introduce a grub_video_rect_t type.

This is from Collin's double buffering patch.

OK, let's drop rectangles from here.

2009/8/10 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 8 lines
Quoted 6 lines

As I understand it the code checks the bounds against the active videomode and then sets the viewport on the active render target. Since the active render target can be arbitrarily set by the user (to, say an offscreen bitmap for rendering the terminal text) I do not see how these two parts match.

Well this code was already there before my patch. I just restructured it. It basically requires viewport to be legal. For offscreen

If the code works the way described above than it requires the viewport to be inside the videomode bounds for any render target for which viewport is set, including offscreen targets. This is not what legal veiwport is about.

If it was broken to start with then it should be perhaps fixed in a separate patch before the split.

Quoted 9 lines

rendering use allocate_render_target
In my patch I tried not to modify the behaviour as far as possible. Your comments about improving the design are welcome but could you start a separate thread? If an improvement that you propose is small in code send a patch together with proposal - it allows to speak about something that is here rather something that could be. If it's bigger then discuss before implementing, perhaps send a small pseudo-patch which shows how it will be implemented. Pseudo patches don't have to work but are just for discussion.

I can try to put together a patch that fixes this. It is not unrelated to the fb split, though. The driver code messes with the wrong structure here because it tries to do what should be done at the fb level.

2009/8/10 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 8 lines · Michal Suchanek
Quoted 5 lines

The other thing that bothers me is that the video drivers fill in the render target structure during video initialization.

In my view the render target structure should not be public.

It isn't. If you read the code you'll see that video_render_target is anonymous structure except in drivers.

Yes, but the driver that uses the fb library to handle rendering need not touch the render target.

Quoted 7 lines
Quoted 5 lines

The video
driver should fill in the video mode structure and then call a function that fills in render target based on video mode and video data (framebuffer memory). This code is currently replicated needlessly in the vbe and sdl drivers.

I split on the most natural spot I found - render targets. Everything that works with render targets is moved to video_fb. Perhaps it's not

That's the point here. There are two places in the driver that work with render targets but the code was not moved to video_fb.

One is the filling out of the render target structure, the other is the bounds checking for viewport.

Quoted 5 lines

the best spot but cutting at natural function ensures drivers won't have to undo something video_fb does. In future if drivers share code which can be moved to vide_fb then I'm ok with it but I prefer to see more real drivers first before fine-tuning split limit especially away fro ma natural spot

What I want to do here is the split to be exactly at the natural spot
- video_fb works with render targets, everything outside of there uses them as opaque structures.

If other drivers used different (accelerated) rendering methods but implemented only some of the rendering functions then sharing of the framebuffer might be possible by using two render targets - one for the accelerated operations, the other for video_fb operations. Making that work with things like doublebufferenig might be somewhat challenging, though.

Quoted 3 lines

As for moving data from video info to render target the problem is that video_fb can't be aware about the structures used by drivers. and so I see no way around it

I do not want to move any data here.

Thanks

Michal

#23 lore raw
Quoted 12 lines

2009/8/10 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 8 lines
Quoted 6 lines

As I understand it the code checks the bounds against the active videomode and then sets the viewport on the active render target. Since the active render target can be arbitrarily set by the user (to, say an offscreen bitmap for rendering the terminal text) I do not see how these two parts match.

Well this code was already there before my patch. I just restructured it. It basically requires viewport to be legal. For offscreen

Quoted 8 lines

If the code works the way described above than it requires the viewport to be inside the videomode bounds for any render target for which viewport is set, including offscreen targets. This is not what legal veiwport is about.

If it was broken to start with then it should be perhaps fixed in a separate patch before the split.

Nothing is broken here. Just we don't use the things like setting viewport outside the real screen. For offscreen rendering use grub_video_create_render_target and then blit it later on. I like this way. Unlike setting viewport to invisible coordinates it's clean and doesn't create any issues if two parts of code decide to use the same invisible offset. If you want us to consider to change this way of doing you need to provide a useful testcase. Just tearing downing existing, working and tested code without benefit isn't good.

Quoted 4 lines

I can try to put together a patch that fixes this. It is not unrelated to the fb split, though. The driver code messes with the wrong structure here because it tries to do what should be done at the fb level.

Retrieving framebuffer address and parameters has to be done in driver. Using any special functions to encapsulate this information just leads to more calls and troubles for double buffering. The design of video_fb.c is that it does only what it's explicitly asked to do and doesn't try to be complete driver

Quoted 5 lines
Quoted 2 lines

It isn't. If you read the code you'll see that video_render_target is anonymous structure except in drivers.

Yes, but the driver that uses the fb library to handle rendering need not touch the render target.

Why not? It just passes parameters to values this way

Quoted 5 lines

That's the point here. There are two places in the driver that work with render targets but the code was not moved to video_fb.

One is the filling out of the render target structure, the other is the bounds checking for viewport.

Both pieces of code check against the current mode. It's just because vbe does most of job for us that this code is a bunch of assignments but it may be more complex. I don't see what your problem with filling render target about screen parameters is

Quoted 4 lines

What I want to do here is the split to be exactly at the natural spot
- video_fb works with render targets, everything outside of there uses them as opaque structures.

Then you pass video mode info which is just a screen render target

Quoted 5 lines

If other drivers used different (accelerated) rendering methods but implemented only some of the rendering functions then sharing of the framebuffer might be possible by using two render targets - one for the accelerated operations, the other for video_fb operations.

Actually this is another point why driver should be able to manipulate framebuffer render targets. If you use acceleration then you may have something different than a normal framebuffer. Trying to use framebuffer on a screen as whole will cause strange effects. The driver may however ask video_fb to do operations on some parts of screen which are framebuffers even when the whole screen isn't. In this case it's the responsibility of driver to determine which accelerated render target corresponds to which framebuffer render target

Quoted 6 lines
Quoted 4 lines

As for moving data from video info to render target the problem is that video_fb can't be aware about the structures used by drivers. and so I see no way around it

I do not want to move any data here.

Well it's exactly what you ask.

Quoted 11 lines

Thanks

Michal

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#24 lore raw

2009/8/10 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 17 lines
Quoted 17 lines

2009/8/10 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 8 lines
Quoted 6 lines

As I understand it the code checks the bounds against the active videomode and then sets the viewport on the active render target. Since the active render target can be arbitrarily set by the user (to, say an offscreen bitmap for rendering the terminal text) I do not see how these two parts match.

Well this code was already there before my patch. I just restructured it. It basically requires viewport to be legal. For offscreen

If the code works the way described above than it requires the viewport to be inside the videomode bounds for any render target for which viewport is set, including offscreen targets. This is not what legal veiwport is about.

Quoted 6 lines
Quoted 3 lines

If it was broken to start with then it should be perhaps fixed in a separate patch before the split.

Nothing is broken here. Just we don't use the things like setting viewport outside the real screen. For offscreen rendering use grub_video_create_render_target and then blit it later on. I like this

Yes, but set_viewport works on the active target. You create an offscreen target and set it as the active target and want to set the viewport on it. Depending on its size this function either needlessly limits you to the current screen mode or allows illegal viewport to be set.

It simply compares apples and oranges.

Quoted 5 lines

way. Unlike setting viewport to invisible coordinates it's clean and doesn't create any issues if two parts of code decide to use the same invisible offset. If you want us to consider to change this way of doing you need to provide a useful testcase. Just tearing downing existing, working and tested code without benefit isn't good.

I do not want to tear it down - just move the check to video_fb and check against the video mode info provided with the target rather than the active video mode which should do the right thing for the screen framebuffer as well as offscreen targets.

It might just happen to do the right thing now because nobody uses render targets larger than the screen and everybody sets the viewport sane so the check is not needed but it's broken nonetheless.

Quoted 10 lines
Quoted 5 lines

I can try to put together a patch that fixes this. It is not unrelated to the fb split, though. The driver code messes with the wrong structure here because it tries to do what should be done at the fb level.

Retrieving framebuffer address and parameters has to be done in driver. Using any special functions to encapsulate this information just leads to more calls and troubles for double buffering. The design of video_fb.c is that it does only what it's explicitly asked to do and doesn't try to be complete driver

That's completely fine.

I just want the drivers not touch the render target structure so that it is possible to add features to video_fb (such as framebuffer rotation) later without breaking the drivers that do not use them.

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

It isn't. If you read the code you'll see that video_render_target is anonymous structure except in drivers.

Yes, but the driver that uses the fb library to handle rendering need not touch the render target.

Why not? It just passes parameters to values this way

Because it breaks encapsulation and needlessly duplicates code.

Quoted 9 lines
Quoted 5 lines

That's the point here. There are two places in the driver that work with render targets but the code was not moved to video_fb.

One is the filling out of the render target structure, the other is the bounds checking for viewport.

Both pieces of code check against the current mode. It's just because vbe does most of job for us that this code is a bunch of assignments but it may be more complex. I don't see what your problem with filling render target about screen parameters is

Exactly that it may get more complex. You have to change the code in all drivers then.

Quoted 5 lines
Quoted 4 lines

What I want to do here is the split to be exactly at the natural spot
- video_fb works with render targets, everything outside of there uses them as opaque structures.

Then you pass video mode info which is just a screen render target

Yes, without any needless redundancy.

Quoted 5 lines
Quoted 5 lines

If other drivers used different (accelerated) rendering methods but implemented only some of the rendering functions then sharing of the framebuffer might be possible by using two render targets - one for the accelerated operations, the other for video_fb operations.

Quoted 9 lines

Actually this is another point why driver should be able to manipulate framebuffer render targets. If you use acceleration then you may have something different than a normal framebuffer. Trying to use framebuffer on a screen as whole will cause strange effects. The driver may however ask video_fb to do operations on some parts of screen which are framebuffers even when the whole screen isn't. In this case it's the responsibility of driver to determine which accelerated render target corresponds to which framebuffer render target

For that they should be able to create and use render targets but not manipulate them directly.

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

As for moving data from video info to render target the problem is that video_fb can't be aware about the structures used by drivers. and so I see no way around it

I do not want to move any data here.

Well it's exactly what you ask.

Where?

The mode_info is already part of the framebuffer so I only ask that the driver fills in the mode_info and has a render target created from that rather than creating a render target itself.
If features are later added to the render target (such as rotation) this code needs to be aware of them. However, if the structure was filled out in fb_video then these new features are transparent.

Thanks

Michal

#25 lore raw
Quoted 8 lines · Michal Suchanek

Yes, but set_viewport works on the active target. You create an offscreen target and set it as the active target and want to set the viewport on it. Depending on its size this function either needlessly limits you to the current screen mode or allows illegal viewport to be set.

It simply compares apples and oranges.

Fixed in repo. New patch is coming after testing

Quoted 5 lines

I just want the drivers not touch the render target structure so that it is possible to add features to video_fb (such as framebuffer rotation) later without breaking the drivers that do not use them.

Because it breaks encapsulation and needlessly duplicates code.

I'm not sure that encapsulation is good in this particular case. Clearly the driver should take the lead and not the framebuffer library. Now it's coded with "library of functions" concept and changing concept will put strains on drivers. I don't know which approach is better in a long run

Quoted 7 lines
Quoted 4 lines

Both pieces of code check against the current mode. It's just because vbe does most of job for us that this code is a bunch of assignments but it may be more complex. I don't see what your problem with filling render target about screen parameters is

Exactly that it may get more complex. You have to change the code in all drivers then.

Why? Driver just sets fields framebuf? In which cases does it need to be modified?

Quoted 3 lines
Quoted 1 line

Then you pass video mode info which is just a screen render target

Yes, without any needless redundancy.

Passing framebuffer parameters one way or another you have redundancy

Quoted 3 lines

For that they should be able to create and use render targets but not manipulate them directly.

They do. They need to say "this render target is at ... with these parameters"

Quoted 4 lines

The mode_info is already part of the framebuffer so I only ask that the driver fills in the mode_info and has a render target created from that rather than creating a render target itself.

mode_info lacks crucial data like framebuffer address.

Quoted 4 lines

If features are later added to the render target (such as rotation) this code needs to be aware of them. However, if the structure was filled out in fb_video then these new features are transparent.

But if a driver partially accelerates rotation it needs to tell which buffers are rotated and which aren't. Basically we have 2 possible benefits but I'm not sure which one is better. What do others think?

Quoted 10 lines

Thanks

Michal

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#26 lore raw

2009/8/10 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 10 lines · Michal Suchanek
Quoted 8 lines

Yes, but set_viewport works on the active target. You create an offscreen target and set it as the active target and want to set the viewport on it. Depending on its size this function either needlessly limits you to the current screen mode or allows illegal viewport to be set.

It simply compares apples and oranges.

Fixed in repo. New patch is coming after testing

Thanks

Quoted 26 lines
Quoted 5 lines

I just want the drivers not touch the render target structure so that it is possible to add features to video_fb (such as framebuffer rotation) later without breaking the drivers that do not use them.

Because it breaks encapsulation and needlessly duplicates code.

I'm not sure that encapsulation is good in this particular case. Clearly the driver should take the lead and not the framebuffer library. Now it's coded with "library of functions" concept and changing concept will put strains on drivers. I don't know which approach is better in a long run

Quoted 7 lines
Quoted 4 lines

Both pieces of code check against the current mode. It's just because vbe does most of job for us that this code is a bunch of assignments but it may be more complex. I don't see what your problem with filling render target about screen parameters is

Exactly that it may get more complex. You have to change the code in all drivers then.

Why? Driver just sets fields framebuf? In which cases does it need to be modified?

Quoted 3 lines
Quoted 1 line

Then you pass video mode info which is just a screen render target

Yes, without any needless redundancy.

Passing framebuffer parameters one way or another you have redundancy

Quoted 3 lines

For that they should be able to create and use render targets but not manipulate them directly.

Quoted 6 lines

They do. They need to say "this render target is at ... with these parameters"

Quoted 4 lines

The mode_info is already part of the framebuffer so I only ask that the driver fills in the mode_info and has a render target created from that rather than creating a render target itself.

mode_info lacks crucial data like framebuffer address.

Yes, it does.

I would like a video_fb function like grub_video_fb_create_render_target_from_buffer(void * buffer, int allocated, const grub_video_mode_info_t * mode_info)

Quoted 6 lines
Quoted 4 lines

If features are later added to the render target (such as rotation) this code needs to be aware of them. However, if the structure was filled out in fb_video then these new features are transparent.

But if a driver partially accelerates rotation it needs to tell which buffers are rotated and which aren't. Basically we have 2 possible

Yes, and it can create them rotated or not as appropriate (and specify that in the mode_info). If the rotation is done in hardware then it should be transparent and the buffer is effectively non-rotated as far as video_fb cares.

Quoted 1 line

benefits but I'm not sure which one is better. What do others think?

I am sure that for doing transparent rotation in video_fb encapsulation is good. I can do without it or patch it in with the rotation if I get it into working state.

The only other users of the render_target structure are drivers and from what I have seen so far they should better be kept at good distance from it.

However, an opinion of somebody else who looks at the graphics subsystem would be welcome.

Thanks

Michal

#27 lore raw
Quoted 3 lines

I would like a video_fb function like grub_video_fb_create_render_target_from_buffer(void * buffer, int allocated, const grub_video_mode_info_t * mode_info)

Well this is pretty much what we do directly. New fields can be added to fbrender_target with no problem. (btw currently driver manages only screen render target and completely delegates other functions to video_fb)

Quoted 3 lines

I am sure that for doing transparent rotation in video_fb encapsulation is good. I can do without it or patch it in with the rotation if I get it into working state.

Actually it's enough to follow simple rules like
blitting target on target isn't rotated but coordinates are adjusted blitting non-target on target is rotated.
This way video adapter doesn't have to know about nature of blitting operations. Anyway you need to adjust width and height returned by mode_info. A function video_fb_transform_coordinates can do this. This way framebuffer can apply any transformation, not just rotation w/o driver to know.

Quoted 10 lines

Thanks

Michal

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#28 lore raw

2009/8/10 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 7 lines
Quoted 3 lines

I would like a video_fb function like grub_video_fb_create_render_target_from_buffer(void * buffer, int allocated, const grub_video_mode_info_t * mode_info)

Well this is pretty much what we do directly. New fields can be added to fbrender_target with no problem. (btw currently driver manages only screen render target and completely delegates other functions to video_fb)

Quoted 5 lines
Quoted 3 lines

I am sure that for doing transparent rotation in video_fb encapsulation is good. I can do without it or patch it in with the rotation if I get it into working state.

Actually it's enough to follow simple rules like
blitting target on target isn't rotated but coordinates are adjusted

Why would it not be rotated?

Depending on the direction of the two targets a transformation may apply.

Quoted 1 line

blitting non-target on target is rotated.

If non-target does not support rotation then there is no other possibility, obviously.

Quoted 3 lines

This way video adapter doesn't have to know about nature of blitting operations. Anyway you need  to adjust width and height returned by mode_info. A function video_fb_transform_coordinates can do this. This way

Yes, it can. However, driver unaware of rotation won't use it which is why I want it to be internal to video_fb at least for drivers that do not implement any operations themselves.

Quoted 2 lines

framebuffer can apply any transformation, not just rotation w/o driver to know.

Obviously, the video_fb can do anything (within reason - it needs to follow the current interface) behind the driver's back as long as there is working encapsulation in place.

Thanks

Michal

#29 lore raw
Quoted 14 lines · Michal Suchanek

2009/8/10 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 12 lines
Quoted 3 lines

I would like a video_fb function like grub_video_fb_create_render_target_from_buffer(void * buffer, int allocated, const grub_video_mode_info_t * mode_info)

Well this is pretty much what we do directly. New fields can be added to fbrender_target with no problem. (btw currently driver manages only screen render target and completely delegates other functions to video_fb)

Quoted 3 lines

I am sure that for doing transparent rotation in video_fb encapsulation is good. I can do without it or patch it in with the rotation if I get it into working state.

Actually it's enough to follow simple rules like
blitting target on target isn't rotated but coordinates are adjusted

Quoted 6 lines
Quoted 2 lines

framebuffer can apply any transformation, not just rotation w/o driver to know.

Obviously, the video_fb can do anything (within reason - it needs to follow the current interface) behind the driver's back as long as there is working encapsulation in place.

Considering that vbe.c and sdl.c currently aren't affected a lot whether there is or there isn't encapsulation in place, I'm ok tih encapsulating it but if any driver needs the breach of encapsulation it will be broken and I'll post no opposition to it.
I'll do the encapsulation tomorrow.

Quoted 11 lines

Thanks

Michal

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#30 lore raw
Quoted 5 lines

Considering that vbe.c and sdl.c currently aren't affected a lot whether there is or there isn't encapsulation in place, I'm ok tih encapsulating it but if any driver needs the breach of encapsulation it will be broken and I'll post no opposition to it.
I'll do the encapsulation tomorrow.

Patch attached. One incremental version (for review) and one complete (for patching)

Quoted 20 lines
Quoted 11 lines

Thanks

Michal

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

--
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
include/grub/fbfill.h +23 -0
index 11e22c6..08cd7b8 100644
@@ -24,6 +24,29 @@
 
 struct grub_video_fbblit_info;
 
+struct grub_video_fbrender_target
+{
+  /* Copy of the screen's mode info structure, except that width, height and
+     mode_type has been re-adjusted to requested render target settings.  */
+  struct grub_video_mode_info mode_info;
+
+  struct
+  {
+    unsigned int x;
+    unsigned int y;
+    unsigned int width;
+    unsigned int height;
+  } viewport;
+
+  /* Indicates whether the data has been allocated by us and must be freed
+     when render target is destroyed.  */
+  int is_allocated;
+
+  /* Pointer to data.  Can either be in video card memory or in local host's
+     memory.  */
+  void *data;
+};
+
 void
 grub_video_fbfill (struct grub_video_fbblit_info *dst,
 		   grub_video_color_t color, int x, int y,
include/grub/video_fb.h +6 -22
index 9ae4101..03ef385 100644
@@ -28,28 +28,7 @@
 
 struct grub_video_fbblit_info;
 
-struct grub_video_fbrender_target
-{
-  /* Copy of the screen's mode info structure, except that width, height and
-     mode_type has been re-adjusted to requested render target settings.  */
-  struct grub_video_mode_info mode_info;
-
-  struct
-  {
-    unsigned int x;
-    unsigned int y;
-    unsigned int width;
-    unsigned int height;
-  } viewport;
-
-  /* Indicates whether the data has been allocated by us and must be freed
-     when render target is destroyed.  */
-  int is_allocated;
-
-  /* Pointer to data.  Can either be in video card memory or in local host's
-     memory.  */
-  void *data;
-};
+struct grub_video_fbrender_target;
 
 #define GRUB_VIDEO_FBSTD_NUMCOLORS 16
 extern struct grub_video_palette_data grub_video_fbstd_colors[GRUB_VIDEO_FBSTD_NUMCOLORS];
@@ -126,6 +105,11 @@ grub_video_fb_create_render_target (struct grub_video_fbrender_target **result,
 				    unsigned int mode_type __attribute__ ((unused)));
 
 grub_err_t
+grub_video_fb_create_render_target_from_pointer (struct grub_video_fbrender_target **result,
+						 const struct grub_video_mode_info *mode_info,
+						 void *ptr);
+
+grub_err_t
 grub_video_fb_delete_render_target (struct grub_video_fbrender_target *target);
 
 grub_err_t
video/fb/video_fb.c +39 -0
index f97d7ac..e4f8f6d 100644
@@ -1081,6 +1081,45 @@ grub_video_fb_create_render_target (struct grub_video_fbrender_target **result,
 }
 
 grub_err_t
+grub_video_fb_create_render_target_from_pointer (struct grub_video_fbrender_target **result,
+						 const struct grub_video_mode_info *mode_info,
+						 void *ptr)
+{
+  struct grub_video_fbrender_target *target;
+  unsigned y;
+
+  /* Allocate memory for render target.  */
+  target = grub_malloc (sizeof (struct grub_video_fbrender_target));
+  if (! target)
+    return grub_errno;
+
+  /* Mark render target as unallocated.  */
+  target->is_allocated = 0;
+  target->data = ptr;
+
+  grub_memcpy (&(target->mode_info), mode_info, sizeof (target->mode_info));
+
+  /* Reset viewport to match new mode.  */
+  target->viewport.x = 0;
+  target->viewport.y = 0;
+  target->viewport.width = mode_info->width;
+  target->viewport.height = mode_info->height;
+
+  /* Mark framebuffer memory as non allocated.  */
+  target->is_allocated = 0;
+
+  /* Clear render target with black and maximum transparency.  */
+  for (y = 0; y < mode_info->height; y++)
+    grub_memset (target->data + mode_info->pitch * y, 0,
+		 mode_info->bytes_per_pixel * mode_info->width);
+
+  /* Save result to caller.  */
+  *result = target;
+
+  return GRUB_ERR_NONE;
+}
+
+grub_err_t
 grub_video_fb_delete_render_target (struct grub_video_fbrender_target *target)
 {
   /* If there is no target, then just return without error.  */
video/i386/pc/vbe.c +35 -38

108 lines not on this page · raw message

#31 lore raw
Quoted 7 lines · Vladimir 'phcoder' Serbinenko
Quoted 5 lines

Considering that vbe.c and sdl.c currently aren't affected a lot whether there is or there isn't encapsulation in place, I'm ok tih encapsulating it but if any driver needs the breach of encapsulation it will be broken and I'll post no opposition to it.
I'll do the encapsulation tomorrow.

Patch attached. One incremental version (for review) and one complete (for patching)

Please go ahead (I assume it raises no warnings and it's well tested).

One small detail:

video/i386/pc/vbe.c static grub_err_t · line 564

Quoted 2 lines
video/i386/pc/vbe.c +2 -0
+  grub_free (mode_list);
+  mode_list = 0;

I would prefer if we used NULL for pointers. I know we don't do that everywhere, but it makes code easier to understand.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#32 lore raw
Quoted 1 line

Please go ahead (I assume it raises no warnings and it's well tested).

I tested the latest version with gfxterm and xnu loader. I use previous version in my daily bootloader. I'll run another series of tests before comitting.

Quoted 8 lines

One small detail:

Quoted 2 lines

+  grub_free (mode_list);
+  mode_list = 0;

I would prefer if we used NULL for pointers.  I know we don't do that everywhere, but it makes code easier to understand.

From GCS: "Zero without a cast is perfectly fine as a null pointer constant, except when calling a varargs function. "

Quoted 14 lines

--
Robert Millan

 The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#33 lore raw
Quoted 7 lines · Vladimir 'phcoder' Serbinenko
Quoted 1 line

Please go ahead (I assume it raises no warnings and it's well tested).

I tested the latest version with gfxterm and xnu loader. I use previous version in my daily bootloader. I'll run another series of tests before comitting.

Quoted 3 lines

One small detail:

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

+  grub_free (mode_list);
+  mode_list = 0;

I would prefer if we used NULL for pointers.  I know we don't do that everywhere, but it makes code easier to understand.
From GCS: "Zero without a cast is perfectly fine as a null pointer

constant, except when calling a varargs function. "

Even if it's not mandated by GCS, it does make the code easier to read, because of the loaded meaning in this expression (just like 'A' can be more meaningful than 0x41).

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#34 lore raw
In reply to Vladimir 'phcoder' Serbinenko

2009/8/13 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 7 lines
Quoted 5 lines

Considering that vbe.c and sdl.c currently aren't affected a lot whether there is or there isn't encapsulation in place, I'm ok tih encapsulating it but if any driver needs the breach of encapsulation it will be broken and I'll post no opposition to it.
I'll do the encapsulation tomorrow.

Patch attached. One incremental version (for review) and one complete (for patching)

The patch as presented here works for me.

However, I wonder some of the changes:

In the latest round of patches struct grub_video_fbrender_target declaration was needlessly and somewhat illogically moved from video_fb.h to fbfill.h.

I am not sure if this is to hide the structure from other code but it logically belongs to video_fb.h.

In grub_video_vbe_setup function in vbe.c the default palette is loaded before the created render target is set as active. I guess this would be a problem if the palette was actually needed/supported. Changing the order to create, set_active, set_palette makes the code fail for me,though.

In this same code struct grub_video_mode_info mode_info is added in the last round of patches but I cannot find where the changed code touches the variable. This is somewhat odd.

In create_render_target_from_pointer the is_allocated is set to 0 twice.

Thanks

Michal

#35 lore raw

2009/8/14 Michal Suchanek <[email protected]>:

Quoted 15 lines

2009/8/13 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 6 lines
Quoted 5 lines

Considering that vbe.c and sdl.c currently aren't affected a lot whether there is or there isn't encapsulation in place, I'm ok tih encapsulating it but if any driver needs the breach of encapsulation it will be broken and I'll post no opposition to it.
I'll do the encapsulation tomorrow.

Patch attached. One incremental version (for review) and one complete

In grub_video_vbe_setup function in vbe.c the default palette is loaded before the created render target is set as active. I guess this would be a problem if the palette was actually needed/supported. Changing the order to create, set_active, set_palette makes the code fail for me,though.

Quoted 3 lines

In this same code struct grub_video_mode_info mode_info is added in the last round of patches but I cannot find where the changed code touches the variable. This is somewhat odd.

Looking at grub_video_vbe_setup I think this could get some more decrufting but this is outside of the scope of framebuffer split and can be looked at once the split is in.

Thanks

Michal

#36 lore raw
In reply to Michal Suchanek
Quoted 9 lines · Michal Suchanek

2009/8/13 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 7 lines
Quoted 5 lines

Considering that vbe.c and sdl.c currently aren't affected a lot whether there is or there isn't encapsulation in place, I'm ok tih encapsulating it but if any driver needs the breach of encapsulation it will be broken and I'll post no opposition to it.
I'll do the encapsulation tomorrow.

Patch attached. One incremental version (for review) and one complete (for patching)

Quoted 7 lines

The patch as presented here works for me.

However, I wonder some of the changes:

In the latest round of patches struct grub_video_fbrender_target declaration was needlessly and somewhat illogically moved from video_fb.h to fbfill.h.

fbfill.h is a private header whereas video_fb.h is public one. You're the one who requested encapsulation

Quoted 4 lines

I am not sure if this is to hide the structure from other code but it logically belongs to video_fb.h.

Again, you're the one who requested encapsulation.

Quoted 5 lines

In grub_video_vbe_setup function in vbe.c the default palette is loaded before the created render target is set as active. I guess this would be a problem if the palette was actually needed/supported. Changing the order to create, set_active, set_palette makes the code fail for me,though.

Works for me. Have you forgotten about 'return' ?

Quoted 4 lines

In this same code struct grub_video_mode_info mode_info is added in the last round of patches but I cannot find where the changed code touches the variable. This is somewhat odd.

grep is your friend:

      framebuffer.mode_info.width = active_mode_info.x_resolution;

and follows. Since now vbe.c can't manipulate directly the target. Again, you're the one who requested encapsulation.

Quoted 2 lines

In create_render_target_from_pointer the is_allocated is set to 0 twice.

Fixed

Quoted 1 line

I'm running the series of tests now and when I'm finished I'll commit it. After that you're welcome to submit patches for the problems you spot (you already talked about few)

Quoted 10 lines

Thanks

Michal

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#37 lore raw

2009/8/14 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 12 lines · Michal Suchanek
Quoted 11 lines

2009/8/13 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 7 lines
Quoted 5 lines

Considering that vbe.c and sdl.c currently aren't affected a lot whether there is or there isn't encapsulation in place, I'm ok tih encapsulating it but if any driver needs the breach of encapsulation it will be broken and I'll post no opposition to it.
I'll do the encapsulation tomorrow.

Patch attached. One incremental version (for review) and one complete (for patching)

The patch as presented here works for me.

Quoted 7 lines
Quoted 5 lines

However, I wonder some of the changes:

In the latest round of patches struct grub_video_fbrender_target declaration was needlessly and somewhat illogically moved from video_fb.h to fbfill.h.

fbfill.h is a private header whereas video_fb.h is public one. You're the one who requested encapsulation

OK, I did not get why fbfill.h of the three private headers.

Perhaps fbutil.h which already declares blit_info would be a better place then.

Quoted 6 lines
Quoted 5 lines

In grub_video_vbe_setup function in vbe.c the default palette is loaded before the created render target is set as active. I guess this would be a problem if the palette was actually needed/supported. Changing the order to create, set_active, set_palette makes the code fail for me,though.

Works for me. Have you forgotten about 'return' ?

Yes, perhaps I did something wrong when reordering the calls for the first time.

Quoted 8 lines
Quoted 4 lines

In this same code struct grub_video_mode_info mode_info is added in the last round of patches but I cannot find where the changed code touches the variable. This is somewhat odd.

grep is your friend:
     framebuffer.mode_info.width = active_mode_info.x_resolution; and follows. Since now vbe.c can't manipulate directly the target. Again, you're the one who requested encapsulation.

Sorry, I just confused the
grub_video_mode_info mode_info
with the
grub_vbe_mode_info_block mode_info

Perhaps a more distinctive name for the latter would be helpful, though.

Quoted 7 lines
Quoted 2 lines

In create_render_target_from_pointer the is_allocated is set to 0 twice.

Fixed

Quoted 1 line

I'm running the series of tests now and when I'm finished I'll commit it. After that you're welcome to submit patches for the problems you spot (you already talked about few)

This is a patch against the current (as far as git knows) framebuf branch:

* move video_fb_fender_target structure declaration to fbutil.h
* remove duplicate assignment in create_render_target_from_pointer
+ quiet warning
* rename local variable in grub_video_vbe_setup
* remove grub_video_fb_get_video_ptr from video_fb.c (dup in fbutil.c)

Take which you want

Thanks

Michal

include/grub/fbfill.h +0 -23
index 08cd7b8..11e22c6 100644
@@ -24,29 +24,6 @@
 
 struct grub_video_fbblit_info;
 
-struct grub_video_fbrender_target
-{
-  /* Copy of the screen's mode info structure, except that width, height and
-     mode_type has been re-adjusted to requested render target settings.  */
-  struct grub_video_mode_info mode_info;
-
-  struct
-  {
-    unsigned int x;
-    unsigned int y;
-    unsigned int width;
-    unsigned int height;
-  } viewport;
-
-  /* Indicates whether the data has been allocated by us and must be freed
-     when render target is destroyed.  */
-  int is_allocated;
-
-  /* Pointer to data.  Can either be in video card memory or in local host's
-     memory.  */
-  void *data;
-};
-
 void
 grub_video_fbfill (struct grub_video_fbblit_info *dst,
 		   grub_video_color_t color, int x, int y,
include/grub/fbutil.h +24 -1
index 76e1e57..fc1e885 100644
@@ -25,13 +25,36 @@
 #include <grub/types.h>
 #include <grub/video.h>
 
+struct grub_video_fbrender_target
+{
+  /* Copy of the screen's mode info structure, except that width, height and
+     mode_type has been re-adjusted to requested render target settings.  */
+  struct grub_video_mode_info mode_info;
+
+  struct
+  {
+    unsigned int x;
+    unsigned int y;
+    unsigned int width;
+    unsigned int height;
+  } viewport;
+
+  /* Indicates whether the data has been allocated by us and must be freed
+     when render target is destroyed.  */
+  int is_allocated;
+
+  /* Pointer to data.  Can either be in video card memory or in local host's
+     memory.  */
+  void *data;
+};
+
 struct grub_video_fbblit_info
 {
   struct grub_video_mode_info *mode_info;
   void *data;
 };
 
-grub_uint8_t *get_data_ptr (struct grub_video_fbblit_info *source,
+grub_uint8_t *grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source,
                             unsigned int x, unsigned int y);
 
 grub_video_color_t get_pixel (struct grub_video_fbblit_info *source,
include/grub/video_fb.h +0 -3
index 03ef385..17debd6 100644
@@ -33,9 +33,6 @@ struct grub_video_fbrender_target;
 #define GRUB_VIDEO_FBSTD_NUMCOLORS 16
 extern struct grub_video_palette_data grub_video_fbstd_colors[GRUB_VIDEO_FBSTD_NUMCOLORS];
 
-grub_uint8_t * grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source,
-                                             grub_uint32_t x, grub_uint32_t y);
-
 grub_err_t
 grub_video_fb_init (void);
 
video/fb/fbblit.c +28 -28

140 lines not on this page · raw message

video/fb/fbutil.c +20 -9
index 09cbb12..1fa48ec 100644
@@ -16,12 +16,23 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/* SPECIAL NOTES!
+
+   Please note following when reading the code below:
+
+   - In this driver we assume that every memory can be accessed by same memory
+     bus.  If there are different address spaces do not use this code as a base
+     code for other archs.
+
+   - Every function in this code assumes that bounds checking has been done in
+     previous phase and they are opted out in here.  */
+
 #include <grub/fbutil.h>
 #include <grub/types.h>
 #include <grub/video.h>
 
 grub_uint8_t *
-get_data_ptr (struct grub_video_fbblit_info *source,
+grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source,
               unsigned int x, unsigned int y)
 {
   grub_uint8_t *ptr = 0;
@@ -72,24 +83,24 @@ get_pixel (struct grub_video_fbblit_info *source,
   switch (source->mode_info->bpp)
     {
     case 32:
-      color = *(grub_uint32_t *)get_data_ptr (source, x, y);
+      color = *(grub_uint32_t *)grub_video_fb_get_video_ptr (source, x, y);
       break;
 
     case 24:
       {
         grub_uint8_t *ptr;
-        ptr = get_data_ptr (source, x, y);
+        ptr = grub_video_fb_get_video_ptr (source, x, y);
         color = ptr[0] | (ptr[1] << 8) | (ptr[2] << 16);
       }
       break;
 
     case 16:
     case 15:
-      color = *(grub_uint16_t *)get_data_ptr (source, x, y);
+      color = *(grub_uint16_t *)grub_video_fb_get_video_ptr (source, x, y);
       break;
 
     case 8:
-      color = *(grub_uint8_t *)get_data_ptr (source, x, y);
+      color = *(grub_uint8_t *)grub_video_fb_get_video_ptr (source, x, y);
       break;
 
     case 1:
@@ -120,7 +131,7 @@ set_pixel (struct grub_video_fbblit_info *source,
       {
         grub_uint32_t *ptr;
 
-        ptr = (grub_uint32_t *)get_data_ptr (source, x, y);
+        ptr = (grub_uint32_t *)grub_video_fb_get_video_ptr (source, x, y);
 
         *ptr = color;
       }
@@ -131,7 +142,7 @@ set_pixel (struct grub_video_fbblit_info *source,
         grub_uint8_t *ptr;
         grub_uint8_t *colorptr = (grub_uint8_t *)&color;
 
-        ptr = get_data_ptr (source, x, y);
+        ptr = grub_video_fb_get_video_ptr (source, x, y);
 
         ptr[0] = colorptr[0];
         ptr[1] = colorptr[1];
@@ -144,7 +155,7 @@ set_pixel (struct grub_video_fbblit_info *source,
       {
         grub_uint16_t *ptr;
 
-        ptr = (grub_uint16_t *)get_data_ptr (source, x, y);
+        ptr = (grub_uint16_t *)grub_video_fb_get_video_ptr (source, x, y);
 
         *ptr = (grub_uint16_t) (color & 0xFFFF);
       }
@@ -154,7 +165,7 @@ set_pixel (struct grub_video_fbblit_info *source,
       {
         grub_uint8_t *ptr;
 
-        ptr = (grub_uint8_t *)get_data_ptr (source, x, y);
+        ptr = (grub_uint8_t *)grub_video_fb_get_video_ptr (source, x, y);
 
         *ptr = (grub_uint8_t) (color & 0xFF);
       }
video/fb/video_fb.c +1 -42

57 lines not on this page · raw message

video/i386/pc/vbe.c +22 -22

115 lines not on this page · raw message

#38 lore raw

Framebuffer patch comitted and I removed framebuf branch on my repo.

Quoted 5 lines

OK, I did not get why fbfill.h of the three private headers.

Perhaps fbutil.h which already declares blit_info would be a better place then.

I haven't looked in depth how private headers were organised, I just moved the same layout to fb*. Perhaps we need only one framebuffer private header now

Quoted 9 lines
Quoted 6 lines
Quoted 5 lines

In grub_video_vbe_setup function in vbe.c the default palette is loaded before the created render target is set as active. I guess this would be a problem if the palette was actually needed/supported. Changing the order to create, set_active, set_palette makes the code fail for me,though.

Works for me. Have you forgotten about 'return' ?

Yes, perhaps I did something wrong when reordering the calls for the first time.

It's already reordered in comitted version

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

In this same code struct grub_video_mode_info mode_info is added in the last round of patches but I cannot find where the changed code touches the variable. This is somewhat odd.

grep is your friend:
     framebuffer.mode_info.width = active_mode_info.x_resolution; and follows. Since now vbe.c can't manipulate directly the target. Again, you're the one who requested encapsulation.

Quoted 7 lines

Sorry, I just confused the
grub_video_mode_info mode_info
with the
grub_vbe_mode_info_block mode_info

Perhaps a more distinctive name for the latter would be helpful, though.

I'm ok with rename.

Quoted 1 line

This is a patch against the current (as far as git knows) framebuf branch:

This branch doesn't exist anymore since it's upstream ;)

Quoted 2 lines

   * move video_fb_fender_target structure declaration to fbutil.h

Requires me to looks at how three headers are organised.

Quoted 2 lines

   * remove duplicate assignment in create_render_target_from_pointer
      + quiet warning

Is already done in committed version

Quoted 1 line

   * rename local variable in grub_video_vbe_setup

Good

Quoted 1 line

   * remove grub_video_fb_get_video_ptr from video_fb.c (dup in fbutil.c)

Good patch too

Quoted 3 lines

Take which you want

Could you send them as separate patches with changelogs? It's especially important in your case since you have no copyright assignment yet and we have to decide which patches can go in without such. I'm not maintainer so I need explicit consent from them to apply your patches before you sign copyright assignment

Quoted 10 lines

Thanks

Michal

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#39 lore raw
Quoted 49 lines · Vladimir 'phcoder' Serbinenko

Framebuffer patch comitted and I removed framebuf branch on my repo.

Quoted 5 lines

OK, I did not get why fbfill.h of the three private headers.

Perhaps fbutil.h which already declares blit_info would be a better place then.

I haven't looked in depth how private headers were organised, I just moved the same layout to fb*. Perhaps we need only one framebuffer private header now

Quoted 9 lines
Quoted 6 lines
Quoted 5 lines

In grub_video_vbe_setup function in vbe.c the default palette is loaded before the created render target is set as active. I guess this would be a problem if the palette was actually needed/supported. Changing the order to create, set_active, set_palette makes the code fail for me,though.

Works for me. Have you forgotten about 'return' ?

Yes, perhaps I did something wrong when reordering the calls for the first time.

It's already reordered in comitted version

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

In this same code struct grub_video_mode_info mode_info is added in the last round of patches but I cannot find where the changed code touches the variable. This is somewhat odd.

grep is your friend:
     framebuffer.mode_info.width = active_mode_info.x_resolution; and follows. Since now vbe.c can't manipulate directly the target. Again, you're the one who requested encapsulation.

Quoted 7 lines

Sorry, I just confused the
grub_video_mode_info mode_info
with the
grub_vbe_mode_info_block mode_info

Perhaps a more distinctive name for the latter would be helpful, though.

I'm ok with rename.

Quoted 1 line

This is a patch against the current (as far as git knows) framebuf branch:

This branch doesn't exist anymore since it's upstream ;)

Quoted 2 lines

   * move video_fb_fender_target structure declaration to fbutil.h

Requires me to looks at how three headers are organised.

Quoted 2 lines

   * remove duplicate assignment in create_render_target_from_pointer
      + quiet warning

Is already done in committed version

Quoted 1 line

   * rename local variable in grub_video_vbe_setup

Good

Quoted 1 line

   * remove grub_video_fb_get_video_ptr from video_fb.c (dup in fbutil.c)

Good patch too

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

Take which you want

Could you send them as separate patches with changelogs? It's especially important in your case since you have no copyright assignment yet and we have to decide which patches can go in without such. I'm not maintainer so I need explicit consent from them to apply your patches before you sign copyright assignment

And please consider this thread closed and post your patches in a new thread

Quoted 19 lines
Quoted 10 lines

Thanks

Michal

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

--
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#40 lore raw
In reply to Vladimir 'phcoder' Serbinenko

2009/8/10 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 10 lines · Michal Suchanek
Quoted 8 lines

Yes, but set_viewport works on the active target. You create an offscreen target and set it as the active target and want to set the viewport on it. Depending on its size this function either needlessly limits you to the current screen mode or allows illegal viewport to be set.

It simply compares apples and oranges.

Fixed in repo. New patch is coming after testing

Does not build.

Otherwise it works as expected. I can build a rescue CD with gfxterm and a lame background image.

Thanks

Michal

video/fb/video_fb.c +0 -0
index ac9eb4b..f97d7ac 100644
@@ -160,23 +160,23 @@ grub_video_fb_set_viewport (unsigned int x,

unsigned int y,
{
/* Make sure viewport is withing screen dimensions. If viewport was set
to be out of the region, mark its size as zero. */
- if (x > render_target->mode_info.x_resolution)
+ if (x > render_target->mode_info.width)

     {
       x = 0;
       width = 0;
     }

- if (y > render_target->mode_info.y_resolution)
+ if (y > render_target->mode_info.height)

     {
       y = 0;
       height = 0;
     }

- if (x + width > render_target->mode_info.x_resolution)
- width = render_target->mode_info.x_resolution - x;
+ if (x + width > render_target->mode_info.width)
+ width = render_target->mode_info.width - x;

- if (y + height > render_target->mode_info.y_resolution)
- height = render_target->mode_info.y_resolution - y;
+ if (y + height > render_target->mode_info.height)
+ height = render_target->mode_info.height - y;

   render_target->viewport.x = x;
   render_target->viewport.y = y;
#41 lore raw
Quoted 8 lines · Michal Suchanek

2009/8/10 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 7 lines · Michal Suchanek
Quoted 6 lines

Yes, but set_viewport works on the active target. You create an offscreen target and set it as the active target and want to set the viewport on it. Depending on its size this function either needlessly limits you to the current screen mode or allows illegal viewport to be set.

Quoted 9 lines
Quoted 3 lines
Quoted 2 lines

It simply compares apples and oranges.

Fixed in repo. New patch is coming after testing

Does not build.

Otherwise it works as expected. I can build a rescue CD with gfxterm and a lame background image.

Thank you for testing (unfortunately I didn't come to this yet). Your fix is applied to my repo

Quoted 6 lines

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#42 lore raw

2009/8/12 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 13 lines · Michal Suchanek
Quoted 12 lines

2009/8/10 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 10 lines · Michal Suchanek
Quoted 8 lines

Yes, but set_viewport works on the active target. You create an offscreen target and set it as the active target and want to set the viewport on it. Depending on its size this function either needlessly limits you to the current screen mode or allows illegal viewport to be set.

It simply compares apples and oranges.

Fixed in repo. New patch is coming after testing

Quoted 7 lines
Quoted 5 lines

Does not build.

Otherwise it works as expected. I can build a rescue CD with gfxterm and a lame background image.

Thank you for testing (unfortunately I didn't come to this yet). Your fix is applied to my repo

There is the same broken code (although unused) in master/util/sdl.c

Thanks

Michal

util/sdl.c +0 -0
index 3d0a637..72abac5 100644
@@ -165,32 +165,6 @@ grub_video_sdl_set_palette (unsigned int start,

unsigned int count,
return grub_video_fb_set_palette (start, count, palette_data);
}

-grub_err_t
-grub_video_sdl_set_viewport (unsigned int x, unsigned int y,
- unsigned int width, unsigned int height)
-{
- /* Make sure viewport is withing screen dimensions. If viewport was set
- to be out of the region, mark its size as zero. */
- if (x > (unsigned) window->w)
- {
- x = 0;
- width = 0;
- }
-
- if (y > (unsigned) window->h)
- {
- y = 0;
- height = 0;
- }
-
- if (x + width > (unsigned) window->w)
- width = window->w - x;
-
- if (y + height > (unsigned) window->h)
- height = window->h - y;
- return grub_video_fb_set_viewport (x, y, width, height);
-}
-
static grub_err_t
grub_video_sdl_swap_buffers (void)
{

#43 lore raw
In reply to Vladimir 'phcoder' Serbinenko
Quoted 4 lines · Vladimir 'phcoder' Serbinenko
Quoted 3 lines

Btw, if I understand correctly, we have a race condition right now.  As a bugfix it'd be better to merge this separately from the interface redesign if possible.

race condition? We don't even have threads

Well, we have the possibility that video drivers are doing stuff in background, but that's something entirely different I had in mind. Please bear with me, I missunderstood what you wrote :-)

Quoted 6 lines
Quoted 4 lines

Why is this chunk of code moved down?  AFAICS, this change only involves adding an additional layer between it and the video backend.  Does this make it conflict with something else?

I wanted to keep normal grub_printf as long as possible and after get_mode_and_fini grub_printf may be unfunctional.

Ok

Quoted 9 lines
Quoted 6 lines
Quoted 1 line

+#define grub_video_render_target grub_video_fbrender_target

If we want to rename this function, I'd rather do it all the way than keeping a compatibility macro.  But then, I'd also prefer if this is done separately from the rest (either before or after).

It's not about renaming but to inform includes that grub_video_render_target is in fact grub_video_fbrender_target and so avoid warnings and casts.

I don't understand this. If we want to settle with grub_video_render_target why don't we just provide that function directly? Or is this making room for an additional layer later on?

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#44 lore raw
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

+#define grub_video_render_target grub_video_fbrender_target

If we want to rename this function, I'd rather do it all the way than keeping a compatibility macro.  But then, I'd also prefer if this is done separately from the rest (either before or after).

Quoted 7 lines
Quoted 3 lines

It's not about renaming but to inform includes that grub_video_render_target is in fact grub_video_fbrender_target and so avoid warnings and casts.

I don't understand this.  If we want to settle with grub_video_render_target why don't we just provide that function directly?  Or is this making room for an additional layer later on?

It's for abstraction we already have. Most of video subsystem doesn't care whether render_target is framebuffer, OpenGL or network commands. In this particular case we know that we're rendering to a framebuffer and so function
do_something (grub_video_render_target *my_render_target); like it's used by upper layers is inded the same as do_something (grub_video_fbrender_target *my_render_target); and not e.g.
do_something (grub_video_glrender_target *my_render_target);

Quoted 14 lines

--
Robert Millan

 The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#45 lore raw
In reply to Robert Millan

2009/8/1 Robert Millan <[email protected]>:

Quoted 27 lines · Vladimir 'phcoder' Serbinenko
Quoted 4 lines

   grub_err_t (*get_info) (struct grub_video_mode_info *mode_info);

+  grub_err_t (*get_info_and_fini) (struct grub_video_mode_info *mode_info,
+                                void **framebuffer);

include/grub/video.h grub_err_t grub_video_restore (void); · line 266

Quoted 10 lines
include/grub/video.h +9 -0
+
[...]
+/* Framebuffer address may change as a part of normal operation
+   (e.g. double buffering). That's why you need to stop video subsystem to be
+   sure that framebuffer address doesn't change. To ensure this abstraction
+   grub_video_get_info_and_fini is the only function supplying framebuffer
+   address. */
+grub_err_t grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info,
+                                      void **framebuffer);
+

I see that returning framebuffer address and finishing the video subsystem must be together, but is there a reason to couple this with getting mode_info ?

If mode_info is also affected by this problem, or if getting mode info only makes sense in a situation in which we'd also want to obtain framebuffer address or finishing the subsystem, then the existing get_info() function is no longer necessary.

Otherwise, users who want both things can just invoke get_info() first and then the new function to obtain FB address.

Quoted 8 lines

Btw, if I understand correctly, we have a race condition right now.  As a bugfix it'd be better to merge this separately from the interface redesign if possible.

Also, does finishing the video subsystem only affect GRUB internally, or result in any effect at the display level?  I want to avoid having visual glitches when the payload is loaded without switching video mode.

I guess the current initialization is somewhat fishy. I haven't looked at the code so far but the way it works is odd. When I change output to gfxterm it apparently tries to initialize the vbe graphics but it fails to find any videomode unless I run vbetest before starting gfxterm.

The situation is the same both pre- and post- split.

Thanks

Michal

#46 lore raw
Quoted 8 lines · Michal Suchanek

2009/8/1 Robert Millan <[email protected]>:
I guess the current initialization is somewhat fishy. I haven't looked at the code so far but the way it works is odd. When I change output to gfxterm it apparently tries to initialize the vbe graphics but it fails to find any videomode unless I run vbetest before starting gfxterm.

The situation is the same both pre- and post- split.

insmod vbe

Autoload right driver would be nice. Perhaps having a list of pairs (PCI vendor; driver) ?

Quoted 11 lines

Thanks

Michal

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#47 lore raw

2009/8/1 Vladimir 'phcoder' Serbinenko <[email protected]>:

Quoted 8 lines · Michal Suchanek
Quoted 7 lines

2009/8/1 Robert Millan <[email protected]>:
I guess the current initialization is somewhat fishy. I haven't looked at the code so far but the way it works is odd. When I change output to gfxterm it apparently tries to initialize the vbe graphics but it fails to find any videomode unless I run vbetest before starting gfxterm.

Quoted 6 lines
Quoted 1 line

The situation is the same both pre- and post- split.

insmod vbe

Autoload right driver would be nice. Perhaps having a list of pairs (PCI vendor; driver) ?

The PCI id list for vbe would be quite long ;-)

However, vbe and vga (if/when implemented) could be used as fallback.

Thanks

Michal

#48 lore raw
In reply to Vladimir 'phcoder' Serbinenko
Quoted 8 lines · Vladimir 'phcoder' Serbinenko
Quoted 7 lines · Michal Suchanek

2009/8/1 Robert Millan <[email protected]>:
I guess the current initialization is somewhat fishy. I haven't looked at the code so far but the way it works is odd. When I change output to gfxterm it apparently tries to initialize the vbe graphics but it fails to find any videomode unless I run vbetest before starting gfxterm.

Quoted 6 lines
Quoted 1 line

The situation is the same both pre- and post- split.

insmod vbe

Autoload right driver would be nice. Perhaps having a list of pairs (PCI vendor; driver) ?

I suppose this will make sense when we have hardware drivers for video.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."