From: Shin-ichiro KAWASAKI <kawasaki@juno.dti.ne.jp>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] SM501 emulation for R2D-SH4
Date: Tue, 04 Nov 2008 23:31:25 +0900 [thread overview]
Message-ID: <49105CBD.8050501@juno.dti.ne.jp> (raw)
In-Reply-To: <fb249edb0811012027h4d84e8eepc44e0fbcd24b28eb@mail.gmail.com>
Thank you for your review!
>> I'm not sure about following two points.
>>
>> - Register definitions were copied from Linux : include/linux/sm501-regs.h
>
> I'd try to suck it into the .c file because the definitions are not
> going to be used anywhere else in qemu.
OK. I'll include it in sm501.c.
>> +#include "vga_int.h"
>
> I think <vga_int.h> isn't needed?
Right. Will be deleted.
>> +static void sm501_draw_crt(SM501State * s)
>> +{
>> + int x, y;
>> + uint32_t crt_width = (s->dc_crt_h_total & 0x00000FFF) + 1;
>> + uint32_t crt_height = (s->dc_crt_v_total & 0x00000FFF) + 1;
>> + uint8_t * buf = s->local_mem;
>> + uint32_t * palette = (uint32_t *)s->dc_crt_palette;
>> +
>> + /* adjust console size */
>> + if (s->last_width != crt_width || s->last_height != crt_height) {
>> + qemu_console_resize(s->console, crt_width, crt_height);
>> + s->last_width = crt_width;
>> + s->last_height = crt_height;
>> + }
>> +
>> + switch (s->dc_crt_control & 3) {
>> + case SM501_DC_CRT_CONTROL_8BPP:
>> + for (y = 0; y < crt_height; y++) {
>> + for (x = 0; x < crt_width; x++) {
>> + int i = (y * crt_width + x) * 4;
>> + *(uint32_t *)&s->ds->data[i] = palette[*buf];
>> + buf++;
>> + }
>> + }
>> + break;
>> + case SM501_DC_CRT_CONTROL_16BPP:
>> + for (y = 0; y < crt_height; y++) {
>> + for (x = 0; x < crt_width; x++) {
>> + int i = (y * crt_width + x) * 4;
>> + uint32_t rgb565 = *(uint16_t*)buf;
>> + int r = ((rgb565 >> 11) & 0x1f) << 3;
>> + int g = ((rgb565 >> 5) & 0x3f) << 2;
>> + int b = ((rgb565 >> 0) & 0x1f) << 3;
>> + s->ds->data[i + 0] = b;
>> + s->ds->data[i + 1] = g;
>> + s->ds->data[i + 2] = r;
>> + s->ds->data[i + 3] = 0;
>> + buf += 2;
>> + }
>> + }
>> + break;
>> + case SM501_DC_CRT_CONTROL_32BPP:
>> + for (y = 0; y < crt_height; y++) {
>> + for (x = 0; x < crt_width; x++) {
>> + int i = (y * crt_width + x) * 4;
>> + *(uint32_t *)&s->ds->data[i] = *(uint32_t*)buf;
>> + buf += 4;
>> + }
>> + }
>> + break;
>
> All the cases assume the host is using 32 bpp colours, which is rare I
> think. Because s->ds->depth is not checked, it will likely segfault.
Right. I will introduce templates like hw/vga_template.h to fit
s->ds->depth variety.
Thanks!
Shin-ichiro KAWASAKI
next prev parent reply other threads:[~2008-11-04 14:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-02 2:12 [Qemu-devel] [PATCH] SM501 emulation for R2D-SH4 Shin-ichiro KAWASAKI
2008-11-02 3:27 ` andrzej zaborowski
2008-11-04 14:31 ` Shin-ichiro KAWASAKI [this message]
2008-11-02 6:52 ` Blue Swirl
2008-11-04 15:10 ` Shin-ichiro KAWASAKI
2008-11-04 19:11 ` Blue Swirl
2008-11-05 17:09 ` [Qemu-devel] [PATCH] [RESEND] " Shin-ichiro KAWASAKI
2008-11-05 18:25 ` Blue Swirl
2008-11-05 20:13 ` andrzej zaborowski
2008-11-05 20:26 ` Blue Swirl
2008-11-04 15:27 ` [Qemu-devel] When should I use qemu_ram_alloc(), and how? takasi-y
2008-11-04 19:14 ` [Qemu-devel] " Blue Swirl
2008-11-04 19:32 ` Anthony Liguori
2008-11-05 13:29 ` takasi-y
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49105CBD.8050501@juno.dti.ne.jp \
--to=kawasaki@juno.dti.ne.jp \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).