+static struct dcpu16_hw_ctl_cmd ctl_[] = {
+ { "blink_rate", "const unsigned int *rate", "unsigned int *rate", "sets or gets cycles per blink toggle" },
+ { "refresh_rate", "const unsigned int *rate", "unsigned int *rate", "sets or gets cycles per screen refresh" },
+#ifdef HAVE_LIBVNCSERVER
+ { "associate_rfbScreen", "rfbScreenInfoPtr", "NULL", "associates this lem1802 instance with an rfb display" },
+#endif /* HAVE_LIBVNCSERVER */
+ { "renderer", "const char *", "NULL", "sets this lem1802 instance to use renderer" },
+ { "renderer_data", "void *", "NULL", "sets renderer-specific data" },
+ { NULL, NULL, NULL, NULL }
+};
+int lem1802_data_ctl_(struct dcpu16_hw *hw, const char *cmd, void *data_in, void *data_out) {
+ if (strcmp(cmd, "blink_rate") == 0) {
+ struct lem1802_ *display = (struct lem1802_ *)hw->data;
+ const unsigned int *rate_in = (const unsigned int *)data_in;
+ unsigned int *rate_out = (unsigned int *)data_out;
+
+ if (rate_out) {
+ *rate_out = display->blink_rate;
+ }
+
+ if (rate_in) {
+ display->blink_rate = *rate_in;
+ }
+
+ return 0;
+ }
+
+ if (strcmp(cmd, "refresh_rate") == 0) {
+ struct lem1802_ *display = (struct lem1802_ *)hw->data;
+ const unsigned int *rate_in = (const unsigned int *)data_in;
+ unsigned int *rate_out = (unsigned int *)data_out;
+
+ if (rate_out) {
+ *rate_out = display->refresh_rate;
+ }
+
+ if (rate_in) {
+ display->refresh_rate = *rate_in;
+ }
+
+ return 0;
+ }
+
+#ifdef HAVE_LIBVNCSERVER
+ if (strcmp(cmd, "associate_rfbScreen") == 0) {
+ struct lem1802_ *display = (struct lem1802_ *)hw->data;
+ rfbScreenInfoPtr rfbScreen = (rfbScreenInfoPtr)data_out;
+ (void)data_in;
+
+ if (rfbScreen == NULL)
+ return -EFAULT;
+
+ rfbScreen->desktopName = "NYA ELEKTRISKA LEM1802";
+ rfbScreen->frameBuffer = (char *)display->pixbuf;
+
+ return 0;
+ }
+#endif /* HAVE_LIBVNCSERVER */
+
+ if (strcmp(cmd, "renderer") == 0) {
+ struct lem1802_ *display = (struct lem1802_ *)hw->data;
+ char *renderer = (char *)data_in;
+ (void)data_out;
+ struct renderer_ *r;
+
+ for (r = lem1802_renderers_; r->renderer; r++) {
+ if (strcmp(renderer, r->name) == 0) {
+ display->render = r->renderer;
+ TRACE("%s>> renderer set to %s", __func__, renderer);
+ return 0;
+ }
+ }
+
+ hw->vm->warn_cb_("unknown renderer '%s'", renderer);
+
+ return -ENOENT;
+ }
+
+ if (strcmp(cmd, "renderer_data") == 0) {
+ struct lem1802_ *display = (struct lem1802_ *)hw->data;
+ (void)data_out;
+
+ display->renderer_data = data_in;
+
+ return 0;
+ }
+
+ return -EINVAL;
+}
+