| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * QEMU JAZZ LED emulator. | 
					
						
							| 
									
										
										
										
											2007-09-16 21:08:06 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  |  * Copyright (c) 2007-2012 Herve Poussineau | 
					
						
							| 
									
										
										
										
											2007-09-16 21:08:06 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  |  * Permission is hereby granted, free of charge, to any person obtaining a copy | 
					
						
							|  |  |  |  * of this software and associated documentation files (the "Software"), to deal | 
					
						
							|  |  |  |  * in the Software without restriction, including without limitation the rights | 
					
						
							|  |  |  |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
					
						
							|  |  |  |  * copies of the Software, and to permit persons to whom the Software is | 
					
						
							|  |  |  |  * furnished to do so, subject to the following conditions: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The above copyright notice and this permission notice shall be included in | 
					
						
							|  |  |  |  * all copies or substantial portions of the Software. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
					
						
							|  |  |  |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
					
						
							|  |  |  |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | 
					
						
							|  |  |  |  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
					
						
							|  |  |  |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
					
						
							|  |  |  |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 
					
						
							|  |  |  |  * THE SOFTWARE. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-26 18:17:13 +00:00
										 |  |  | #include "qemu/osdep.h"
 | 
					
						
							| 
									
										
										
										
											2019-05-23 16:35:07 +02:00
										 |  |  | #include "qemu/module.h"
 | 
					
						
							| 
									
										
										
										
											2012-11-28 12:06:30 +01:00
										 |  |  | #include "ui/console.h"
 | 
					
						
							|  |  |  | #include "ui/pixel_ops.h"
 | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:15 +01:00
										 |  |  | #include "trace.h"
 | 
					
						
							| 
									
										
										
										
											2013-02-04 15:40:22 +01:00
										 |  |  | #include "hw/sysbus.h"
 | 
					
						
							| 
									
										
										
										
											2019-08-12 07:23:45 +02:00
										 |  |  | #include "migration/vmstate.h"
 | 
					
						
							| 
									
										
										
										
											2020-09-03 16:43:22 -04:00
										 |  |  | #include "qom/object.h"
 | 
					
						
							| 
									
										
										
										
											2010-07-31 11:05:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | typedef enum { | 
					
						
							|  |  |  |     REDRAW_NONE = 0, REDRAW_SEGMENTS = 1, REDRAW_BACKGROUND = 2, | 
					
						
							| 
									
										
										
										
											2009-10-01 16:12:16 -05:00
										 |  |  | } screen_state_t; | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-25 00:35:51 +02:00
										 |  |  | #define TYPE_JAZZ_LED "jazz-led"
 | 
					
						
							| 
									
										
										
										
											2020-09-16 14:25:19 -04:00
										 |  |  | OBJECT_DECLARE_SIMPLE_TYPE(LedState, JAZZ_LED) | 
					
						
							| 
									
										
										
										
											2013-07-25 00:35:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-03 16:43:22 -04:00
										 |  |  | struct LedState { | 
					
						
							| 
									
										
										
										
											2013-07-25 00:35:51 +02:00
										 |  |  |     SysBusDevice parent_obj; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-06 16:34:39 +02:00
										 |  |  |     MemoryRegion iomem; | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  |     uint8_t segments; | 
					
						
							| 
									
										
										
										
											2013-03-05 15:24:14 +01:00
										 |  |  |     QemuConsole *con; | 
					
						
							| 
									
										
										
										
											2009-10-01 16:12:16 -05:00
										 |  |  |     screen_state_t state; | 
					
						
							| 
									
										
										
										
											2020-09-03 16:43:22 -04:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-23 12:30:10 +02:00
										 |  |  | static uint64_t jazz_led_read(void *opaque, hwaddr addr, | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  |                               unsigned int size) | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     LedState *s = opaque; | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:15 +01:00
										 |  |  |     uint8_t val; | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  |     val = s->segments; | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:15 +01:00
										 |  |  |     trace_jazz_led_read(addr, val); | 
					
						
							| 
									
										
										
										
											2010-07-31 11:05:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  |     return val; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-23 12:30:10 +02:00
										 |  |  | static void jazz_led_write(void *opaque, hwaddr addr, | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  |                            uint64_t val, unsigned int size) | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     LedState *s = opaque; | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:15 +01:00
										 |  |  |     uint8_t new_val = val & 0xff; | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:15 +01:00
										 |  |  |     trace_jazz_led_write(addr, new_val); | 
					
						
							| 
									
										
										
										
											2010-07-31 11:05:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  |     s->segments = new_val; | 
					
						
							|  |  |  |     s->state |= REDRAW_SEGMENTS; | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-06 16:34:39 +02:00
										 |  |  | static const MemoryRegionOps led_ops = { | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  |     .read = jazz_led_read, | 
					
						
							|  |  |  |     .write = jazz_led_write, | 
					
						
							| 
									
										
										
										
											2011-10-06 16:34:39 +02:00
										 |  |  |     .endianness = DEVICE_NATIVE_ENDIAN, | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  |     .impl.min_access_size = 1, | 
					
						
							|  |  |  |     .impl.max_access_size = 1, | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /***********************************************************/ | 
					
						
							|  |  |  | /* jazz_led display */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 15:24:14 +01:00
										 |  |  | static void draw_horizontal_line(DisplaySurface *ds, | 
					
						
							|  |  |  |                                  int posy, int posx1, int posx2, | 
					
						
							|  |  |  |                                  uint32_t color) | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     uint8_t *d; | 
					
						
							|  |  |  |     int x, bpp; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 15:24:14 +01:00
										 |  |  |     bpp = (surface_bits_per_pixel(ds) + 7) >> 3; | 
					
						
							|  |  |  |     d = surface_data(ds) + surface_stride(ds) * posy + bpp * posx1; | 
					
						
							| 
									
										
										
										
											2019-12-06 14:58:03 +01:00
										 |  |  |     switch (bpp) { | 
					
						
							|  |  |  |     case 1: | 
					
						
							|  |  |  |         for (x = posx1; x <= posx2; x++) { | 
					
						
							|  |  |  |             *((uint8_t *)d) = color; | 
					
						
							|  |  |  |             d++; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case 2: | 
					
						
							|  |  |  |         for (x = posx1; x <= posx2; x++) { | 
					
						
							|  |  |  |             *((uint16_t *)d) = color; | 
					
						
							|  |  |  |             d += 2; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case 4: | 
					
						
							|  |  |  |         for (x = posx1; x <= posx2; x++) { | 
					
						
							|  |  |  |             *((uint32_t *)d) = color; | 
					
						
							|  |  |  |             d += 4; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         break; | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 15:24:14 +01:00
										 |  |  | static void draw_vertical_line(DisplaySurface *ds, | 
					
						
							|  |  |  |                                int posx, int posy1, int posy2, | 
					
						
							|  |  |  |                                uint32_t color) | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     uint8_t *d; | 
					
						
							|  |  |  |     int y, bpp; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 15:24:14 +01:00
										 |  |  |     bpp = (surface_bits_per_pixel(ds) + 7) >> 3; | 
					
						
							|  |  |  |     d = surface_data(ds) + surface_stride(ds) * posy1 + bpp * posx; | 
					
						
							| 
									
										
										
										
											2019-12-06 14:58:03 +01:00
										 |  |  |     switch (bpp) { | 
					
						
							|  |  |  |     case 1: | 
					
						
							|  |  |  |         for (y = posy1; y <= posy2; y++) { | 
					
						
							|  |  |  |             *((uint8_t *)d) = color; | 
					
						
							|  |  |  |             d += surface_stride(ds); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case 2: | 
					
						
							|  |  |  |         for (y = posy1; y <= posy2; y++) { | 
					
						
							|  |  |  |             *((uint16_t *)d) = color; | 
					
						
							|  |  |  |             d += surface_stride(ds); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case 4: | 
					
						
							|  |  |  |         for (y = posy1; y <= posy2; y++) { | 
					
						
							|  |  |  |             *((uint32_t *)d) = color; | 
					
						
							|  |  |  |             d += surface_stride(ds); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         break; | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void jazz_led_update_display(void *opaque) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     LedState *s = opaque; | 
					
						
							| 
									
										
										
										
											2013-03-05 15:24:14 +01:00
										 |  |  |     DisplaySurface *surface = qemu_console_surface(s->con); | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  |     uint8_t *d1; | 
					
						
							|  |  |  |     uint32_t color_segment, color_led; | 
					
						
							|  |  |  |     int y, bpp; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (s->state & REDRAW_BACKGROUND) { | 
					
						
							|  |  |  |         /* clear screen */ | 
					
						
							| 
									
										
										
										
											2013-03-05 15:24:14 +01:00
										 |  |  |         bpp = (surface_bits_per_pixel(surface) + 7) >> 3; | 
					
						
							|  |  |  |         d1 = surface_data(surface); | 
					
						
							|  |  |  |         for (y = 0; y < surface_height(surface); y++) { | 
					
						
							|  |  |  |             memset(d1, 0x00, surface_width(surface) * bpp); | 
					
						
							|  |  |  |             d1 += surface_stride(surface); | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (s->state & REDRAW_SEGMENTS) { | 
					
						
							|  |  |  |         /* set colors according to bpp */ | 
					
						
							| 
									
										
										
										
											2013-03-05 15:24:14 +01:00
										 |  |  |         switch (surface_bits_per_pixel(surface)) { | 
					
						
							| 
									
										
										
										
											2019-12-06 14:58:03 +01:00
										 |  |  |         case 8: | 
					
						
							|  |  |  |             color_segment = rgb_to_pixel8(0xaa, 0xaa, 0xaa); | 
					
						
							|  |  |  |             color_led = rgb_to_pixel8(0x00, 0xff, 0x00); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case 15: | 
					
						
							|  |  |  |             color_segment = rgb_to_pixel15(0xaa, 0xaa, 0xaa); | 
					
						
							|  |  |  |             color_led = rgb_to_pixel15(0x00, 0xff, 0x00); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case 16: | 
					
						
							|  |  |  |             color_segment = rgb_to_pixel16(0xaa, 0xaa, 0xaa); | 
					
						
							|  |  |  |             color_led = rgb_to_pixel16(0x00, 0xff, 0x00); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case 24: | 
					
						
							|  |  |  |             color_segment = rgb_to_pixel24(0xaa, 0xaa, 0xaa); | 
					
						
							|  |  |  |             color_led = rgb_to_pixel24(0x00, 0xff, 0x00); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case 32: | 
					
						
							|  |  |  |             color_segment = rgb_to_pixel32(0xaa, 0xaa, 0xaa); | 
					
						
							|  |  |  |             color_led = rgb_to_pixel32(0x00, 0xff, 0x00); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             return; | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         /* display segments */ | 
					
						
							| 
									
										
										
										
											2013-03-05 15:24:14 +01:00
										 |  |  |         draw_horizontal_line(surface, 40, 10, 40, | 
					
						
							|  |  |  |                              (s->segments & 0x02) ? color_segment : 0); | 
					
						
							|  |  |  |         draw_vertical_line(surface, 10, 10, 40, | 
					
						
							|  |  |  |                            (s->segments & 0x04) ? color_segment : 0); | 
					
						
							|  |  |  |         draw_vertical_line(surface, 10, 40, 70, | 
					
						
							|  |  |  |                            (s->segments & 0x08) ? color_segment : 0); | 
					
						
							|  |  |  |         draw_horizontal_line(surface, 70, 10, 40, | 
					
						
							|  |  |  |                              (s->segments & 0x10) ? color_segment : 0); | 
					
						
							|  |  |  |         draw_vertical_line(surface, 40, 40, 70, | 
					
						
							|  |  |  |                            (s->segments & 0x20) ? color_segment : 0); | 
					
						
							|  |  |  |         draw_vertical_line(surface, 40, 10, 40, | 
					
						
							|  |  |  |                            (s->segments & 0x40) ? color_segment : 0); | 
					
						
							|  |  |  |         draw_horizontal_line(surface, 10, 10, 40, | 
					
						
							|  |  |  |                              (s->segments & 0x80) ? color_segment : 0); | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         /* display led */ | 
					
						
							| 
									
										
										
										
											2019-12-06 14:58:03 +01:00
										 |  |  |         if (!(s->segments & 0x01)) { | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  |             color_led = 0; /* black */ | 
					
						
							| 
									
										
										
										
											2019-12-06 14:58:03 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-03-05 15:24:14 +01:00
										 |  |  |         draw_horizontal_line(surface, 68, 50, 50, color_led); | 
					
						
							|  |  |  |         draw_horizontal_line(surface, 69, 49, 51, color_led); | 
					
						
							|  |  |  |         draw_horizontal_line(surface, 70, 48, 52, color_led); | 
					
						
							|  |  |  |         draw_horizontal_line(surface, 71, 49, 51, color_led); | 
					
						
							|  |  |  |         draw_horizontal_line(surface, 72, 50, 50, color_led); | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     s->state = REDRAW_NONE; | 
					
						
							| 
									
										
										
										
											2018-08-10 15:28:56 +02:00
										 |  |  |     dpy_gfx_update_full(s->con); | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void jazz_led_invalidate_display(void *opaque) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     LedState *s = opaque; | 
					
						
							|  |  |  |     s->state |= REDRAW_SEGMENTS | REDRAW_BACKGROUND; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-01 16:12:16 -05:00
										 |  |  | static void jazz_led_text_update(void *opaque, console_ch_t *chardata) | 
					
						
							| 
									
										
										
										
											2008-02-10 16:33:14 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     LedState *s = opaque; | 
					
						
							| 
									
										
										
										
											2017-05-03 12:44:41 +02:00
										 |  |  |     char buf[3]; | 
					
						
							| 
									
										
										
										
											2008-02-10 16:33:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 15:24:14 +01:00
										 |  |  |     dpy_text_cursor(s->con, -1, -1); | 
					
						
							|  |  |  |     qemu_console_resize(s->con, 2, 1); | 
					
						
							| 
									
										
										
										
											2008-02-10 16:33:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* TODO: draw the segments */ | 
					
						
							| 
									
										
										
										
											2017-05-03 12:44:41 +02:00
										 |  |  |     snprintf(buf, 3, "%02hhx", s->segments); | 
					
						
							| 
									
										
										
										
											2015-11-29 22:28:24 +09:00
										 |  |  |     console_write_ch(chardata++, ATTR2CHTYPE(buf[0], QEMU_COLOR_BLUE, | 
					
						
							|  |  |  |                                              QEMU_COLOR_BLACK, 1)); | 
					
						
							|  |  |  |     console_write_ch(chardata++, ATTR2CHTYPE(buf[1], QEMU_COLOR_BLUE, | 
					
						
							|  |  |  |                                              QEMU_COLOR_BLACK, 1)); | 
					
						
							| 
									
										
										
										
											2008-02-10 16:33:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 15:24:14 +01:00
										 |  |  |     dpy_text_update(s->con, 0, 0, 2, 1); | 
					
						
							| 
									
										
										
										
											2008-02-10 16:33:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  | static int jazz_led_post_load(void *opaque, int version_id) | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  |     /* force refresh */ | 
					
						
							|  |  |  |     jazz_led_invalidate_display(opaque); | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  | static const VMStateDescription vmstate_jazz_led = { | 
					
						
							|  |  |  |     .name = "jazz-led", | 
					
						
							|  |  |  |     .version_id = 0, | 
					
						
							|  |  |  |     .minimum_version_id = 0, | 
					
						
							|  |  |  |     .post_load = jazz_led_post_load, | 
					
						
							|  |  |  |     .fields = (VMStateField[]) { | 
					
						
							|  |  |  |         VMSTATE_UINT8(segments, LedState), | 
					
						
							|  |  |  |         VMSTATE_END_OF_LIST() | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-13 14:04:18 +01:00
										 |  |  | static const GraphicHwOps jazz_led_ops = { | 
					
						
							|  |  |  |     .invalidate  = jazz_led_invalidate_display, | 
					
						
							|  |  |  |     .gfx_update  = jazz_led_update_display, | 
					
						
							|  |  |  |     .text_update = jazz_led_text_update, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-05 11:04:46 +08:00
										 |  |  | static void jazz_led_init(Object *obj) | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-05-05 11:04:46 +08:00
										 |  |  |     LedState *s = JAZZ_LED(obj); | 
					
						
							|  |  |  |     SysBusDevice *dev = SYS_BUS_DEVICE(obj); | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-05 11:04:46 +08:00
										 |  |  |     memory_region_init_io(&s->iomem, obj, &led_ops, s, "led", 1); | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  |     sysbus_init_mmio(dev, &s->iomem); | 
					
						
							| 
									
										
										
										
											2016-05-05 11:04:46 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-05 11:04:46 +08:00
										 |  |  | static void jazz_led_realize(DeviceState *dev, Error **errp) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     LedState *s = JAZZ_LED(dev); | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-05 11:04:46 +08:00
										 |  |  |     s->con = graphic_console_init(dev, 0, &jazz_led_ops, s); | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void jazz_led_reset(DeviceState *d) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-07-25 00:35:51 +02:00
										 |  |  |     LedState *s = JAZZ_LED(d); | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     s->segments = 0; | 
					
						
							|  |  |  |     s->state = REDRAW_SEGMENTS | REDRAW_BACKGROUND; | 
					
						
							| 
									
										
										
										
											2013-03-05 15:24:14 +01:00
										 |  |  |     qemu_console_resize(s->con, 60, 80); | 
					
						
							| 
									
										
										
										
											2007-06-25 10:57:10 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | static void jazz_led_class_init(ObjectClass *klass, void *data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     DeviceClass *dc = DEVICE_CLASS(klass); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     dc->desc = "Jazz LED display", | 
					
						
							|  |  |  |     dc->vmsd = &vmstate_jazz_led; | 
					
						
							|  |  |  |     dc->reset = jazz_led_reset; | 
					
						
							| 
									
										
										
										
											2016-05-05 11:04:46 +08:00
										 |  |  |     dc->realize = jazz_led_realize; | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-10 16:19:07 +01:00
										 |  |  | static const TypeInfo jazz_led_info = { | 
					
						
							| 
									
										
										
										
											2013-07-25 00:35:51 +02:00
										 |  |  |     .name          = TYPE_JAZZ_LED, | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  |     .parent        = TYPE_SYS_BUS_DEVICE, | 
					
						
							|  |  |  |     .instance_size = sizeof(LedState), | 
					
						
							| 
									
										
										
										
											2016-05-05 11:04:46 +08:00
										 |  |  |     .instance_init = jazz_led_init, | 
					
						
							| 
									
										
										
										
											2012-02-17 20:27:16 +01:00
										 |  |  |     .class_init    = jazz_led_class_init, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void jazz_led_register(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     type_register_static(&jazz_led_info); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type_init(jazz_led_register); |