2 * Epson S1D13744/S1D13745 (Blizzard/Hailstorm/Tornado) LCD/TV controller.
4 * Copyright (C) 2008 Nokia Corporation
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 or
10 * (at your option) version 3 of the License.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "qemu/osdep.h"
22 #include "ui/console.h"
23 #include "hw/display/blizzard.h"
24 #include "ui/pixel_ops.h"
26 typedef void (*blizzard_fn_t)(uint8_t *, const uint8_t *, unsigned int);
72 blizzard_fn_t *line_fn_tab[2];
75 uint8_t hssi_config[3];
82 uint8_t tv_filter_config;
83 uint8_t tv_filter_idx;
84 uint8_t tv_filter_coeff[0x20];
90 uint8_t gamma_lut[0x100];
92 uint8_t matrix_coeff[0x12];
102 uint8_t gpio_edge[2];
118 blizzard_fn_t line_fn;
122 /* Bytes(!) per pixel */
123 static const int blizzard_iformat_bpp[0x10] = {
126 3, /* RGB 6:6:6 mode 1 */
127 3, /* RGB 8:8:8 mode 1 */
129 4, /* RGB 6:6:6 mode 2 */
130 4, /* RGB 8:8:8 mode 2 */
136 static void blizzard_window(BlizzardState *s)
138 DisplaySurface *surface = qemu_console_surface(s->con);
143 blizzard_fn_t fn = s->data.line_fn;
147 if (s->mx[0] > s->data.x)
148 s->mx[0] = s->data.x;
149 if (s->my[0] > s->data.y)
150 s->my[0] = s->data.y;
151 if (s->mx[1] < s->data.x + s->data.dx)
152 s->mx[1] = s->data.x + s->data.dx;
153 if (s->my[1] < s->data.y + s->data.dy)
154 s->my[1] = s->data.y + s->data.dy;
157 bypp[1] = surface_bytes_per_pixel(surface);
158 bypl[0] = bypp[0] * s->data.pitch;
159 bypl[1] = bypp[1] * s->x;
160 bypl[2] = bypp[0] * s->data.dx;
163 dst = s->fb + bypl[1] * s->data.y + bypp[1] * s->data.x;
164 for (y = s->data.dy; y > 0; y --, src += bypl[0], dst += bypl[1])
165 fn(dst, src, bypl[2]);
168 static int blizzard_transfer_setup(BlizzardState *s)
170 if (s->source > 3 || !s->bpp ||
171 s->ix[1] < s->ix[0] || s->iy[1] < s->iy[0])
174 s->data.angle = s->effect & 3;
175 s->data.line_fn = s->line_fn_tab[!!s->data.angle][s->iformat];
176 s->data.x = s->ix[0];
177 s->data.y = s->iy[0];
178 s->data.dx = s->ix[1] - s->ix[0] + 1;
179 s->data.dy = s->iy[1] - s->iy[0] + 1;
180 s->data.len = s->bpp * s->data.dx * s->data.dy;
181 s->data.pitch = s->data.dx;
182 if (s->data.len > s->data.buflen) {
183 s->data.buf = g_realloc(s->data.buf, s->data.len);
184 s->data.buflen = s->data.len;
186 s->data.ptr = s->data.buf;
187 s->data.data = s->data.buf;
192 static void blizzard_reset(BlizzardState *s)
203 s->memrefresh = 0x25c;
209 s->lcd_config = 0x74;
236 s->bpp = blizzard_iformat_bpp[s->iformat];
238 s->hssi_config[0] = 0x00;
239 s->hssi_config[1] = 0x00;
240 s->hssi_config[2] = 0x01;
242 s->tv_timing[0] = 0x00;
243 s->tv_timing[1] = 0x00;
244 s->tv_timing[2] = 0x00;
245 s->tv_timing[3] = 0x00;
250 s->tv_filter_config = 0x80;
251 s->tv_filter_idx = 0x00;
255 s->gamma_config = 0x00;
257 s->matrix_ena = 0x00;
258 memset(&s->matrix_coeff, 0, sizeof(s->matrix_coeff));
264 s->rgbgpio_dir = 0x00;
266 s->gpio_edge[0] = 0x00;
267 s->gpio_edge[1] = 0x00;
269 s->gpio_pdown = 0xff;
272 static inline void blizzard_invalidate_display(void *opaque) {
273 BlizzardState *s = (BlizzardState *) opaque;
278 static uint16_t blizzard_reg_read(void *opaque, uint8_t reg)
280 BlizzardState *s = (BlizzardState *) opaque;
283 case 0x00: /* Revision Code */
286 case 0x02: /* Configuration Readback */
287 return 0x83; /* Macrovision OK, CNF[2:0] = 3 */
289 case 0x04: /* PLL M-Divider */
290 return (s->pll - 1) | (1 << 7);
291 case 0x06: /* PLL Lock Range Control */
293 case 0x08: /* PLL Lock Synthesis Control 0 */
294 return s->pll_ctrl & 0xff;
295 case 0x0a: /* PLL Lock Synthesis Control 1 */
296 return s->pll_ctrl >> 8;
297 case 0x0c: /* PLL Mode Control 0 */
300 case 0x0e: /* Clock-Source Select */
303 case 0x10: /* Memory Controller Activate */
304 case 0x14: /* Memory Controller Bank 0 Status Flag */
307 case 0x18: /* Auto-Refresh Interval Setting 0 */
308 return s->memrefresh & 0xff;
309 case 0x1a: /* Auto-Refresh Interval Setting 1 */
310 return s->memrefresh >> 8;
312 case 0x1c: /* Power-On Sequence Timing Control */
314 case 0x1e: /* Timing Control 0 */
316 case 0x20: /* Timing Control 1 */
319 case 0x24: /* Arbitration Priority Control */
322 case 0x28: /* LCD Panel Configuration */
323 return s->lcd_config;
325 case 0x2a: /* LCD Horizontal Display Width */
327 case 0x2c: /* LCD Horizontal Non-display Period */
329 case 0x2e: /* LCD Vertical Display Height 0 */
331 case 0x30: /* LCD Vertical Display Height 1 */
333 case 0x32: /* LCD Vertical Non-display Period */
335 case 0x34: /* LCD HS Pulse-width */
337 case 0x36: /* LCd HS Pulse Start Position */
338 return s->skipx >> 3;
339 case 0x38: /* LCD VS Pulse-width */
341 case 0x3a: /* LCD VS Pulse Start Position */
344 case 0x3c: /* PCLK Polarity */
347 case 0x3e: /* High-speed Serial Interface Tx Configuration Port 0 */
348 return s->hssi_config[0];
349 case 0x40: /* High-speed Serial Interface Tx Configuration Port 1 */
350 return s->hssi_config[1];
351 case 0x42: /* High-speed Serial Interface Tx Mode */
352 return s->hssi_config[2];
353 case 0x44: /* TV Display Configuration */
355 case 0x46 ... 0x4c: /* TV Vertical Blanking Interval Data bits */
356 return s->tv_timing[(reg - 0x46) >> 1];
357 case 0x4e: /* VBI: Closed Caption / XDS Control / Status */
359 case 0x50: /* TV Horizontal Start Position */
361 case 0x52: /* TV Vertical Start Position */
363 case 0x54: /* TV Test Pattern Setting */
365 case 0x56: /* TV Filter Setting */
366 return s->tv_filter_config;
367 case 0x58: /* TV Filter Coefficient Index */
368 return s->tv_filter_idx;
369 case 0x5a: /* TV Filter Coefficient Data */
370 if (s->tv_filter_idx < 0x20)
371 return s->tv_filter_coeff[s->tv_filter_idx ++];
374 case 0x60: /* Input YUV/RGB Translate Mode 0 */
376 case 0x62: /* Input YUV/RGB Translate Mode 1 */
378 case 0x64: /* U Data Fix */
380 case 0x66: /* V Data Fix */
383 case 0x68: /* Display Mode */
386 case 0x6a: /* Special Effects */
389 case 0x6c: /* Input Window X Start Position 0 */
390 return s->ix[0] & 0xff;
391 case 0x6e: /* Input Window X Start Position 1 */
392 return s->ix[0] >> 3;
393 case 0x70: /* Input Window Y Start Position 0 */
394 return s->ix[0] & 0xff;
395 case 0x72: /* Input Window Y Start Position 1 */
396 return s->ix[0] >> 3;
397 case 0x74: /* Input Window X End Position 0 */
398 return s->ix[1] & 0xff;
399 case 0x76: /* Input Window X End Position 1 */
400 return s->ix[1] >> 3;
401 case 0x78: /* Input Window Y End Position 0 */
402 return s->ix[1] & 0xff;
403 case 0x7a: /* Input Window Y End Position 1 */
404 return s->ix[1] >> 3;
405 case 0x7c: /* Output Window X Start Position 0 */
406 return s->ox[0] & 0xff;
407 case 0x7e: /* Output Window X Start Position 1 */
408 return s->ox[0] >> 3;
409 case 0x80: /* Output Window Y Start Position 0 */
410 return s->oy[0] & 0xff;
411 case 0x82: /* Output Window Y Start Position 1 */
412 return s->oy[0] >> 3;
413 case 0x84: /* Output Window X End Position 0 */
414 return s->ox[1] & 0xff;
415 case 0x86: /* Output Window X End Position 1 */
416 return s->ox[1] >> 3;
417 case 0x88: /* Output Window Y End Position 0 */
418 return s->oy[1] & 0xff;
419 case 0x8a: /* Output Window Y End Position 1 */
420 return s->oy[1] >> 3;
422 case 0x8c: /* Input Data Format */
424 case 0x8e: /* Data Source Select */
426 case 0x90: /* Display Memory Data Port */
429 case 0xa8: /* Border Color 0 */
431 case 0xaa: /* Border Color 1 */
433 case 0xac: /* Border Color 2 */
436 case 0xb4: /* Gamma Correction Enable */
437 return s->gamma_config;
438 case 0xb6: /* Gamma Correction Table Index */
440 case 0xb8: /* Gamma Correction Table Data */
441 return s->gamma_lut[s->gamma_idx ++];
443 case 0xba: /* 3x3 Matrix Enable */
444 return s->matrix_ena;
445 case 0xbc ... 0xde: /* Coefficient Registers */
446 return s->matrix_coeff[(reg - 0xbc) >> 1];
447 case 0xe0: /* 3x3 Matrix Red Offset */
449 case 0xe2: /* 3x3 Matrix Green Offset */
451 case 0xe4: /* 3x3 Matrix Blue Offset */
454 case 0xe6: /* Power-save */
456 case 0xe8: /* Non-display Period Control / Status */
457 return s->status | (1 << 5);
458 case 0xea: /* RGB Interface Control */
459 return s->rgbgpio_dir;
460 case 0xec: /* RGB Interface Status */
462 case 0xee: /* General-purpose IO Pins Configuration */
464 case 0xf0: /* General-purpose IO Pins Status / Control */
466 case 0xf2: /* GPIO Positive Edge Interrupt Trigger */
467 return s->gpio_edge[0];
468 case 0xf4: /* GPIO Negative Edge Interrupt Trigger */
469 return s->gpio_edge[1];
470 case 0xf6: /* GPIO Interrupt Status */
472 case 0xf8: /* GPIO Pull-down Control */
473 return s->gpio_pdown;
476 fprintf(stderr, "%s: unknown register %02x\n", __func__, reg);
481 static void blizzard_reg_write(void *opaque, uint8_t reg, uint16_t value)
483 BlizzardState *s = (BlizzardState *) opaque;
486 case 0x04: /* PLL M-Divider */
487 s->pll = (value & 0x3f) + 1;
489 case 0x06: /* PLL Lock Range Control */
490 s->pll_range = value & 3;
492 case 0x08: /* PLL Lock Synthesis Control 0 */
493 s->pll_ctrl &= 0xf00;
494 s->pll_ctrl |= (value << 0) & 0x0ff;
496 case 0x0a: /* PLL Lock Synthesis Control 1 */
497 s->pll_ctrl &= 0x0ff;
498 s->pll_ctrl |= (value << 8) & 0xf00;
500 case 0x0c: /* PLL Mode Control 0 */
501 s->pll_mode = value & 0x77;
502 if ((value & 3) == 0 || (value & 3) == 3)
503 fprintf(stderr, "%s: wrong PLL Control bits (%i)\n",
504 __func__, value & 3);
507 case 0x0e: /* Clock-Source Select */
508 s->clksel = value & 0xff;
511 case 0x10: /* Memory Controller Activate */
512 s->memenable = value & 1;
514 case 0x14: /* Memory Controller Bank 0 Status Flag */
517 case 0x18: /* Auto-Refresh Interval Setting 0 */
518 s->memrefresh &= 0xf00;
519 s->memrefresh |= (value << 0) & 0x0ff;
521 case 0x1a: /* Auto-Refresh Interval Setting 1 */
522 s->memrefresh &= 0x0ff;
523 s->memrefresh |= (value << 8) & 0xf00;
526 case 0x1c: /* Power-On Sequence Timing Control */
527 s->timing[0] = value & 0x7f;
529 case 0x1e: /* Timing Control 0 */
530 s->timing[1] = value & 0x17;
532 case 0x20: /* Timing Control 1 */
533 s->timing[2] = value & 0x35;
536 case 0x24: /* Arbitration Priority Control */
537 s->priority = value & 1;
540 case 0x28: /* LCD Panel Configuration */
541 s->lcd_config = value & 0xff;
542 if (value & (1 << 7))
543 fprintf(stderr, "%s: data swap not supported!\n", __func__);
546 case 0x2a: /* LCD Horizontal Display Width */
549 case 0x2c: /* LCD Horizontal Non-display Period */
550 s->hndp = value & 0xff;
552 case 0x2e: /* LCD Vertical Display Height 0 */
554 s->y |= (value << 0) & 0x0ff;
556 case 0x30: /* LCD Vertical Display Height 1 */
558 s->y |= (value << 8) & 0x300;
560 case 0x32: /* LCD Vertical Non-display Period */
561 s->vndp = value & 0xff;
563 case 0x34: /* LCD HS Pulse-width */
564 s->hsync = value & 0xff;
566 case 0x36: /* LCD HS Pulse Start Position */
567 s->skipx = value & 0xff;
569 case 0x38: /* LCD VS Pulse-width */
570 s->vsync = value & 0xbf;
572 case 0x3a: /* LCD VS Pulse Start Position */
573 s->skipy = value & 0xff;
576 case 0x3c: /* PCLK Polarity */
577 s->pclk = value & 0x82;
578 /* Affects calculation of s->hndp, s->hsync and s->skipx. */
581 case 0x3e: /* High-speed Serial Interface Tx Configuration Port 0 */
582 s->hssi_config[0] = value;
584 case 0x40: /* High-speed Serial Interface Tx Configuration Port 1 */
585 s->hssi_config[1] = value;
586 if (((value >> 4) & 3) == 3)
587 fprintf(stderr, "%s: Illegal active-data-links value\n",
590 case 0x42: /* High-speed Serial Interface Tx Mode */
591 s->hssi_config[2] = value & 0xbd;
594 case 0x44: /* TV Display Configuration */
595 s->tv_config = value & 0xfe;
597 case 0x46 ... 0x4c: /* TV Vertical Blanking Interval Data bits 0 */
598 s->tv_timing[(reg - 0x46) >> 1] = value;
600 case 0x4e: /* VBI: Closed Caption / XDS Control / Status */
603 case 0x50: /* TV Horizontal Start Position */
606 case 0x52: /* TV Vertical Start Position */
607 s->tv_y = value & 0x7f;
609 case 0x54: /* TV Test Pattern Setting */
612 case 0x56: /* TV Filter Setting */
613 s->tv_filter_config = value & 0xbf;
615 case 0x58: /* TV Filter Coefficient Index */
616 s->tv_filter_idx = value & 0x1f;
618 case 0x5a: /* TV Filter Coefficient Data */
619 if (s->tv_filter_idx < 0x20)
620 s->tv_filter_coeff[s->tv_filter_idx ++] = value;
623 case 0x60: /* Input YUV/RGB Translate Mode 0 */
624 s->yrc[0] = value & 0xb0;
626 case 0x62: /* Input YUV/RGB Translate Mode 1 */
627 s->yrc[1] = value & 0x30;
629 case 0x64: /* U Data Fix */
632 case 0x66: /* V Data Fix */
636 case 0x68: /* Display Mode */
637 if ((s->mode ^ value) & 3)
639 s->mode = value & 0xb7;
640 s->enable = value & 1;
641 s->blank = (value >> 1) & 1;
642 if (value & (1 << 4))
643 fprintf(stderr, "%s: Macrovision enable attempt!\n", __func__);
646 case 0x6a: /* Special Effects */
647 s->effect = value & 0xfb;
650 case 0x6c: /* Input Window X Start Position 0 */
652 s->ix[0] |= (value << 0) & 0x0ff;
654 case 0x6e: /* Input Window X Start Position 1 */
656 s->ix[0] |= (value << 8) & 0x300;
658 case 0x70: /* Input Window Y Start Position 0 */
660 s->iy[0] |= (value << 0) & 0x0ff;
662 case 0x72: /* Input Window Y Start Position 1 */
664 s->iy[0] |= (value << 8) & 0x300;
666 case 0x74: /* Input Window X End Position 0 */
668 s->ix[1] |= (value << 0) & 0x0ff;
670 case 0x76: /* Input Window X End Position 1 */
672 s->ix[1] |= (value << 8) & 0x300;
674 case 0x78: /* Input Window Y End Position 0 */
676 s->iy[1] |= (value << 0) & 0x0ff;
678 case 0x7a: /* Input Window Y End Position 1 */
680 s->iy[1] |= (value << 8) & 0x300;
682 case 0x7c: /* Output Window X Start Position 0 */
684 s->ox[0] |= (value << 0) & 0x0ff;
686 case 0x7e: /* Output Window X Start Position 1 */
688 s->ox[0] |= (value << 8) & 0x300;
690 case 0x80: /* Output Window Y Start Position 0 */
692 s->oy[0] |= (value << 0) & 0x0ff;
694 case 0x82: /* Output Window Y Start Position 1 */
696 s->oy[0] |= (value << 8) & 0x300;
698 case 0x84: /* Output Window X End Position 0 */
700 s->ox[1] |= (value << 0) & 0x0ff;
702 case 0x86: /* Output Window X End Position 1 */
704 s->ox[1] |= (value << 8) & 0x300;
706 case 0x88: /* Output Window Y End Position 0 */
708 s->oy[1] |= (value << 0) & 0x0ff;
710 case 0x8a: /* Output Window Y End Position 1 */
712 s->oy[1] |= (value << 8) & 0x300;
715 case 0x8c: /* Input Data Format */
716 s->iformat = value & 0xf;
717 s->bpp = blizzard_iformat_bpp[s->iformat];
719 fprintf(stderr, "%s: Illegal or unsupported input format %x\n",
720 __func__, s->iformat);
722 case 0x8e: /* Data Source Select */
723 s->source = value & 7;
724 /* Currently all windows will be "destructive overlays". */
725 if ((!(s->effect & (1 << 3)) && (s->ix[0] != s->ox[0] ||
726 s->iy[0] != s->oy[0] ||
727 s->ix[1] != s->ox[1] ||
728 s->iy[1] != s->oy[1])) ||
729 !((s->ix[1] - s->ix[0]) & (s->iy[1] - s->iy[0]) &
730 (s->ox[1] - s->ox[0]) & (s->oy[1] - s->oy[0]) & 1))
731 fprintf(stderr, "%s: Illegal input/output window positions\n",
734 blizzard_transfer_setup(s);
737 case 0x90: /* Display Memory Data Port */
738 if (!s->data.len && !blizzard_transfer_setup(s))
741 *s->data.ptr ++ = value;
742 if (-- s->data.len == 0)
746 case 0xa8: /* Border Color 0 */
749 case 0xaa: /* Border Color 1 */
752 case 0xac: /* Border Color 2 */
756 case 0xb4: /* Gamma Correction Enable */
757 s->gamma_config = value & 0x87;
759 case 0xb6: /* Gamma Correction Table Index */
760 s->gamma_idx = value;
762 case 0xb8: /* Gamma Correction Table Data */
763 s->gamma_lut[s->gamma_idx ++] = value;
766 case 0xba: /* 3x3 Matrix Enable */
767 s->matrix_ena = value & 1;
769 case 0xbc ... 0xde: /* Coefficient Registers */
770 s->matrix_coeff[(reg - 0xbc) >> 1] = value & ((reg & 2) ? 0x80 : 0xff);
772 case 0xe0: /* 3x3 Matrix Red Offset */
775 case 0xe2: /* 3x3 Matrix Green Offset */
778 case 0xe4: /* 3x3 Matrix Blue Offset */
782 case 0xe6: /* Power-save */
783 s->pm = value & 0x83;
784 if (value & s->mode & 1)
785 fprintf(stderr, "%s: The display must be disabled before entering "
786 "Standby Mode\n", __func__);
788 case 0xe8: /* Non-display Period Control / Status */
789 s->status = value & 0x1b;
791 case 0xea: /* RGB Interface Control */
792 s->rgbgpio_dir = value & 0x8f;
794 case 0xec: /* RGB Interface Status */
795 s->rgbgpio = value & 0xcf;
797 case 0xee: /* General-purpose IO Pins Configuration */
800 case 0xf0: /* General-purpose IO Pins Status / Control */
803 case 0xf2: /* GPIO Positive Edge Interrupt Trigger */
804 s->gpio_edge[0] = value;
806 case 0xf4: /* GPIO Negative Edge Interrupt Trigger */
807 s->gpio_edge[1] = value;
809 case 0xf6: /* GPIO Interrupt Status */
810 s->gpio_irq &= value;
812 case 0xf8: /* GPIO Pull-down Control */
813 s->gpio_pdown = value;
817 fprintf(stderr, "%s: unknown register %02x\n", __func__, reg);
822 uint16_t s1d13745_read(void *opaque, int dc)
824 BlizzardState *s = (BlizzardState *) opaque;
825 uint16_t value = blizzard_reg_read(s, s->reg);
827 if (s->swallow -- > 0)
835 void s1d13745_write(void *opaque, int dc, uint16_t value)
837 BlizzardState *s = (BlizzardState *) opaque;
839 if (s->swallow -- > 0)
842 blizzard_reg_write(s, s->reg, value);
844 if (s->reg != 0x90 && s->reg != 0x5a && s->reg != 0xb8)
847 s->reg = value & 0xff;
850 void s1d13745_write_block(void *opaque, int dc,
851 void *buf, size_t len, int pitch)
853 BlizzardState *s = (BlizzardState *) opaque;
856 if (s->reg == 0x90 && dc &&
857 (s->data.len || blizzard_transfer_setup(s)) &&
858 len >= (s->data.len << 1)) {
859 len -= s->data.len << 1;
863 s->data.pitch = pitch;
865 s->data.data = s->data.buf;
869 s1d13745_write(opaque, dc, *(uint16_t *) buf);
875 static void blizzard_update_display(void *opaque)
877 BlizzardState *s = (BlizzardState *) opaque;
878 DisplaySurface *surface = qemu_console_surface(s->con);
879 int y, bypp, bypl, bwidth;
885 if (s->x != surface_width(surface) || s->y != surface_height(surface)) {
887 qemu_console_resize(s->con, s->x, s->y);
888 surface = qemu_console_surface(s->con);
895 bypp = surface_bytes_per_pixel(surface);
896 memset(surface_data(surface), 0, bypp * s->x * s->y);
906 if (s->mx[1] <= s->mx[0])
909 bypp = surface_bytes_per_pixel(surface);
911 bwidth = bypp * (s->mx[1] - s->mx[0]);
913 src = s->fb + bypl * y + bypp * s->mx[0];
914 dst = surface_data(surface) + bypl * y + bypp * s->mx[0];
915 for (; y < s->my[1]; y ++, src += bypl, dst += bypl)
916 memcpy(dst, src, bwidth);
918 dpy_gfx_update(s->con, s->mx[0], s->my[0],
919 s->mx[1] - s->mx[0], y - s->my[0]);
927 static void blizzard_draw_line16_32(uint32_t *dest,
928 const uint16_t *src, unsigned int width)
931 unsigned int r, g, b;
932 const uint16_t *end = (const void *) src + width;
935 b = (data & 0x1f) << 3;
937 g = (data & 0x3f) << 2;
939 r = (data & 0x1f) << 3;
941 *dest++ = rgb_to_pixel32(r, g, b);
945 static void blizzard_draw_line24mode1_32(uint32_t *dest,
946 const uint8_t *src, unsigned int width)
948 /* TODO: check if SDL 24-bit planes are not in the same format and
949 * if so, use memcpy */
950 unsigned int r[2], g[2], b[2];
951 const uint8_t *end = src + width;
957 *dest++ = rgb_to_pixel32(r[0], g[0], b[0]);
960 *dest++ = rgb_to_pixel32(r[1], g[1], b[1]);
964 static void blizzard_draw_line24mode2_32(uint32_t *dest,
965 const uint8_t *src, unsigned int width)
967 unsigned int r, g, b;
968 const uint8_t *end = src + width;
974 *dest++ = rgb_to_pixel32(r, g, b);
979 static blizzard_fn_t blizzard_draw_fn_32[0x10] = {
982 (blizzard_fn_t) blizzard_draw_line16_32,
983 /* RGB 6:6:6 mode 1 */
984 (blizzard_fn_t) blizzard_draw_line24mode1_32,
985 /* RGB 8:8:8 mode 1 */
986 (blizzard_fn_t) blizzard_draw_line24mode1_32,
988 /* RGB 6:6:6 mode 2 */
989 (blizzard_fn_t) blizzard_draw_line24mode2_32,
990 /* RGB 8:8:8 mode 2 */
991 (blizzard_fn_t) blizzard_draw_line24mode2_32,
996 NULL, NULL, NULL, NULL, NULL, NULL,
999 /* 90deg, 180deg and 270deg rotation */
1000 static blizzard_fn_t blizzard_draw_fn_r_32[0x10] = {
1005 static const GraphicHwOps blizzard_ops = {
1006 .invalidate = blizzard_invalidate_display,
1007 .gfx_update = blizzard_update_display,
1010 void *s1d13745_init(qemu_irq gpio_int)
1012 BlizzardState *s = (BlizzardState *) g_malloc0(sizeof(*s));
1013 DisplaySurface *surface;
1015 s->fb = g_malloc(0x180000);
1017 s->con = graphic_console_init(NULL, 0, &blizzard_ops, s);
1018 surface = qemu_console_surface(s->con);
1020 assert(surface_bits_per_pixel(surface) == 32);
1022 s->line_fn_tab[0] = blizzard_draw_fn_32;
1023 s->line_fn_tab[1] = blizzard_draw_fn_r_32;