static void zipit_lcd_realize(SSISlave *dev, Error **errp) { ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev); z->selected = 0; z->enabled = 0; z->pos = 0; }
static uint32_t zipit_lcd_transfer(SSISlave *dev, uint32_t value) { ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev); uint16_t val; if (z->selected) { z->buf[z->pos] = value & 0xff; z->pos++; } if (z->pos == 3) { switch (z->buf[0]) { case 0x74: DPRINTF("%s: reg: 0x%.2x\n", __func__, z->buf[2]); z->cur_reg = z->buf[2]; break; case 0x76: val = z->buf[1] << 8 | z->buf[2]; DPRINTF("%s: value: 0x%.4x\n", __func__, val); if (z->cur_reg == 0x22 && val == 0x0000) { z->enabled = 1; printf("%s: LCD enabled\n", __func__); } else if (z->cur_reg == 0x10 && val == 0x0000) { z->enabled = 0; printf("%s: LCD disabled\n", __func__); } break; default: DPRINTF("%s: unknown command!\n", __func__); break; } z->pos = 0; } return 0; }
static int sm_lcd_init(SSISlave *dev) { lcd_state *s = FROM_SSI_SLAVE(lcd_state, dev); s->brightness = 0.0; s->con = graphic_console_init(DEVICE(dev), 0, &sm_lcd_ops, s); qemu_console_resize(s->con, NUM_COLS, NUM_ROWS); /* This callback informs us that brightness control is enabled */ qdev_init_gpio_in_named(DEVICE(dev), sm_lcd_backlight_enable_cb, "backlight_enable", 1); /* This callback informs us of the brightness level (from 0 to 255) */ qdev_init_gpio_in_named(DEVICE(dev), sm_lcd_set_backlight_level_cb, "backlight_level", 1); /* This callback informs us that the vibrate is on/orr */ qdev_init_gpio_in_named(DEVICE(dev), sm_lcd_vibe_ctl, "vibe_ctl", 1); /* This callback informs us that power is on/off */ qdev_init_gpio_in_named(DEVICE(dev), sm_lcd_power_ctl, "power_ctl", 1); return 0; }
static int zipit_lcd_init(SSISlave *dev) { ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev); z->selected = 0; z->enabled = 0; z->pos = 0; return 0; }
static uint32_t sm_lcd_transfer(SSISlave *dev, uint32_t data) { lcd_state *s = FROM_SSI_SLAVE(lcd_state, dev); /* XXX QEMU's SPI infrastructure is implicitly MSB-first */ data = bitswap(data); switch(s->state) { case COMMAND: data &= 0xfd; /* Mask VCOM bit */ switch(data) { case 0x01: /* Write Line */ s->state = LINENO; break; case 0x04: /* Clear Screen */ memset(s->framebuffer, 0, sizeof(*s->framebuffer)); s->redraw = true; break; case 0x00: /* Toggle VCOM */ break; default: /* Simulate confused display controller. */ memset(s->framebuffer, 0x55, sizeof(*s->framebuffer)); s->redraw = true; break; } break; case LINENO: if (data == 0) { s->state = COMMAND; } else { s->fbindex = (data - 1) * NUM_COL_BYTES; s->state = DATA; } break; case DATA: s->framebuffer[s->fbindex++] = data; if (s->fbindex % NUM_COL_BYTES == 0) { s->state = TRAILER; } break; case TRAILER: if (data != 0) { qemu_log_mask(LOG_GUEST_ERROR, "ls013 memory lcd received non-zero data in TRAILER\n"); } s->state = LINENO; s->redraw = true; break; } return 0; }
static int max111x_init(SSISlave *dev, int inputs) { MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, dev); qdev_init_gpio_out(&dev->qdev, &s->interrupt, 1); s->inputs = inputs; /* TODO: add a user interface for setting these */ s->input[0] = 0xf0; s->input[1] = 0xe0; s->input[2] = 0xd0; s->input[3] = 0xc0; s->input[4] = 0xb0; s->input[5] = 0xa0; s->input[6] = 0x90; s->input[7] = 0x80; s->com = 0; vmstate_register(&dev->qdev, -1, &vmstate_max111x, s); return 0; }
static uint32_t max111x_transfer(SSISlave *dev, uint32_t value) { MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, dev); max111x_write(s, value); return max111x_read(s); }
void max111x_set_input(DeviceState *dev, int line, uint8_t value) { MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, SSI_SLAVE_FROM_QDEV(dev)); assert(line >= 0 && line < s->inputs); s->input[line] = value; }