DAC palette width retrieval
PATCH 1/1 DAC palette width retrieval
When using packed color modes, Linux expects we fill the color sizes with the value obtained from the DAC. If we give it zeroes (like we currently do) it displays a blank screen.
This can be reproduced by attempting to boot Linux with a 8-bit color mode (e.g. set gfxpayload=800x600x8).
Now I'm not completely sure where does this belong. I think it's somewhat generic and we can reasonably expect other OSes to want this information too, but I'm not completely sure.
An alternative would be to do this query in the Linux loader, but this has the disadvantage that we're putting backend-specific code in the loader which aims to be completely backend-independant someday.
Also, tell me what you think about the "getset" hack. It looks like a clean way of providing both functions in less space, but then I'm not sure if we really want both functions. For now we only use the "set" one. Then again, once you have "set" getting "get" comes really cheap.
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."
i386/pc/startup.S +46 -0
@@ -1733,6 +1733,52 @@ ret /* + * grub_vbe_status_t grub_vbe_bios_getset_dac_palette_width (int set, int *dac_mask_size) + * + * Register allocations for parameters: + * %eax set + * %edx *dac_mask_size + */ +FUNCTION(grub_vbe_bios_getset_dac_palette_width) + pushl %ebp + pushl %ebx + + xorl %ebx, %ebx + + /* If we only want to fetch the value, set %bl to 1. */ + testl %eax, %eax + jne 1f + incb %bl +1: + + /* Put desired width in %bh. */ + movl (%edx), %eax + movb %al, %bh + + call prot_to_real + .code16 + + movw $0x4f08, %ax + int $0x10 + + movw %ax, %dx /* real_to_prot destroys %eax. */ + + DATA32 call real_to_prot + .code32 + + /* Move result back to *dac_mask_size. */ + movb %bh, %al + movl %eax, (%edx) + + /* Return value in %eax. */ + xorl %eax, %eax + movw %dx, %ax + + popl %ebx + popl %ebp + ret + +/* * grub_vbe_status_t grub_vbe_bios_set_memory_window (grub_uint32_t window, * grub_uint32_t position); *
i386/pc/vbe.c +18 -0
@@ -300,6 +300,24 @@/* Make copy of mode info block. */ grub_memcpy (mode_info, mi_tmp,sizeof (*mode_info)); + +/* Packed mode. Query DAC Palette width for color sizes. */ +if (mode_info->bits_per_pixel <=8 ) + { +int width =8 ; + status =0 ; + +if (controller_info.capabilities &GRUB_VBE_CAPABILITY_DACWIDTH ) + status =grub_vbe_bios_set_dac_palette_width (& width); + +if (status !=0x004F ) +/* 6 is default after mode reset. */ + width =6 ; + + mode_info->red_mask_size = mode_info->green_mask_size + = mode_info->blue_mask_size = mode_info->rsvd_mask_size + = width; + } }else /* Just clear mode info block if it isn't a VESA mode. */
grub/i386/pc/vbe.h +7 -0
@@ -30,6 +30,8 @@/* VBE status codes. */ #define GRUB_VBE_STATUS_OK 0x004f +#define GRUB_VBE_CAPABILITY_DACWIDTH (1 << 0) +/* Bits from the GRUB_VBE "mode_attributes" field in the mode info struct. */ #define GRUB_VBE_MODEATTR_SUPPORTED (1 << 0)#define GRUB_VBE_MODEATTR_RESERVED_1 (1 << 1)
@@ -181,6 +183,11 @@grub_vbe_status_t EXPORT_FUNC (grub_vbe_bios_get_mode_info ) (grub_uint32_t mode,struct grub_vbe_mode_info_block *mode_info); +grub_vbe_status_t EXPORT_FUNC (grub_vbe_bios_getset_dac_palette_width ) (int set,int *width); + +#define grub_vbe_bios_get_dac_palette_width (width) grub_vbe_bios_getset_dac_palette_width(0, (width)) +#define grub_vbe_bios_set_dac_palette_width (width) grub_vbe_bios_getset_dac_palette_width(1, (width)) +/* Call VESA BIOS 0x4f02 to set video mode, return status. */ grub_vbe_status_t EXPORT_FUNC (grub_vbe_bios_set_mode ) (grub_uint32_t mode,struct grub_vbe_crtc_info_block *crtc_info);
Quoted 3 lines
Now I'm not completely sure where does this belong. I think it's somewhat generic and we can reasonably expect other OSes to want this information too, but I'm not completely sure.
For me putting these values to *_mask is ok but it may put some limits for future cards but as payloads have no way to tell them more info it should be a problem. Do any payloads need *_mask_offset? Even if so it shouldn't stop the patch from going in if it fixes problems for linux since only other payload where grub currently gives video info is xnu and Darwin doesn't boot in anything with depth different from 32 anyway (or I couldn't figure out how to do it).*_mask normally shouldn't be used in index color by internal grub functions anyway. And if payload needs a special convention for passing color info for indexed modes it should be handled by loader Check however that this patch doesn't break gfxterm
Quoted 5 lines
An alternative would be to do this query in the Linux loader, but this has the disadvantage that we're putting backend-specific code in the loader which aims to be completely backend-independant someday.
It is backend-independent with my framebuffer patch and I don't want to go backwards.
Quoted 5 lines
Also, tell me what you think about the "getset" hack. It looks like a clean way of providing both functions in less space, but then I'm not sure if we really want both functions. For now we only use the "set" one. Then again, once you have "set" getting "get" comes really cheap.
It's ok but once we get my mm functions in and move this part to vbe.mod splitting get and set will be a good idea
+ if (status != 0x004F)
It should be GRUB_VBE_STATUS_OK
+ /* 6 is default after mode reset. */
+ width = 6;
Looks like a hack and some boards may have different value. Is there a better way?
+ mode_info->red_mask_size = mode_info->green_mask_size
+ = mode_info->blue_mask_size = mode_info->rsvd_mask_size
+ = width;
Perhaps mode_info->rsvd_mask_size could be left at 0?
I don't think index colors have any alpha
Signature · 4 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
Quoted 10 lines · Vladimir 'phcoder' Serbinenko
Quoted 3 lines
Now I'm not completely sure where does this belong. I think it's somewhat generic and we can reasonably expect other OSes to want this information too, but I'm not completely sure.
For me putting these values to
*_maskis ok but it may put some limits for future cards but as payloads have no way to tell them more info it should be a problem. Do any payloads need*_mask_offset? Even if so it shouldn't stop the patch from going in if it fixes problems for linux since only other payload where grub currently gives video info is xnu and Darwin doesn't boot in anything with depth different from 32 anyway (or I couldn't figure out how to do it).
Ok. I'll wait a few days to see if someone objects. I'd specially like Colin to have a look, since he's familiar with the graphics subsystem too.
Quoted 3 lines
*_masknormally shouldn't be used in index color by internal grub functions anyway. And if payload needs a special convention for passing color info for indexed modes it should be handled by loader
Ok. But if we decide that *_mask should go away, this is quite independant from this patch.
Quoted 1 line
Check however that this patch doesn't break gfxterm
I can't right now, because of the regression I mentioned on IRC, but I will.
Quoted 7 lines
Quoted 5 lines
Also, tell me what you think about the "getset" hack. It looks like a clean way of providing both functions in less space, but then I'm not sure if we really want both functions. For now we only use the "set" one. Then again, once you have "set" getting "get" comes really cheap.
It's ok but once we get my mm functions in and move this part to vbe.mod splitting get and set will be a good idea
Actually, my disjunctive was between providing getset or only set. I don't see the point of two separate functions.
Quoted 2 lines
i386/pc/vbe.c +1
-0+if (status !=0x004F )It should be
GRUB_VBE_STATUS_OK
I see. I copied this from somewhere else, I'll see about fixing that too.
Quoted 4 lines
i386/pc/vbe.c +2
-0+/* 6 is default after mode reset. */ + width =6 ;Looks like a hack and some boards may have different value. Is there a better way?
It is 6 according to the VBE spec (Linux is also consistent with that).
Quoted 5 lines
i386/pc/vbe.c +3
-0+ mode_info->red_mask_size = mode_info->green_mask_size + = mode_info->blue_mask_size = mode_info->rsvd_mask_size + = width;Perhaps
mode_info->rsvd_mask_sizecould be left at 0? I don't think index colors have any alpha
I suppose it's fine. Does anyone see a problem with zeroed rsvd_mask_size?
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."
Quoted 6 lines
Quoted 3 lines
*_masknormally shouldn't be used in index color by internal grub functions anyway. And if payload needs a special convention for passing color info for indexed modes it should be handled by loaderOk. But if we decide that
*_maskshould go away, this is quite independant from this patch.
For RGB modes masks are needed anyway. Idk why linux needs DAC width but it may potentially need something analogous to *_mask_offset for indexed modes too.
Quoted 5 lines
Quoted 2 lines
It's ok but once we get my mm functions in and move this part to vbe.mod splitting get and set will be a good idea
Actually, my disjunctive was between providing getset or only set. I don't see the point of two separate functions.
Separate functions seem to be a bit clearer but it's not that important
Quoted 7 lines
Quoted 4 lines
+ /* 6 is default after mode reset. */
+ width = 6;
Looks like a hack and some boards may have different value. Is there a better way?It is 6 according to the VBE spec (Linux is also consistent with that).
Then ok
Quoted 13 lines
--
Robert MillanThe 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
Committed.
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."