further reorg of module abstraction and control interface
[dcpu16] / hw_lem1802.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <errno.h>
5 #include <sys/time.h>
6
7 #ifdef HAVE_LIBPNG
8 #include <setjmp.h>
9 #include <png.h>
10 #endif /* HAVE_LIBPNG */
11
12 #ifdef HAVE_LIBVNCSERVER
13 #include <rfb/rfb.h>
14 #include <rfb/keysym.h>
15 #endif /* HAVE_LIBVNCSERVER */
16
17 #include "dcpu16.h"
18 #include "chargen-4x8.h"
19 #include "hw_lem1802.h"
20
21 /* lem1802
22 *
23 * TODO:
24 * multiple vnc displays
25 */
26
27 #ifdef DEBUG
28 #define TRACE(...) do { printf("[debug] "); printf(__VA_ARGS__); printf("\n"); } while (0)
29 #else /* DEBUG */
30 #define TRACE(...) do {} while (0)
31 #endif /* DEBUG */
32
33 #ifdef WANT_VARIADIC_VOIDP_CAST
34 #define VOIDP(__x__) ((void *)(__x__))
35 #define VOIDFP(__x__) ((void *)(size_t)(__x__))
36 #else
37 #define VOIDP(__x__) (__x__)
38 #define VOIDFP(__x__) (__x__)
39 #endif
40
41 #define LEM1802_POWER_ON_CYCLES 100000 /* this should vary by, let us say, 10% */
42
43 #define PIX_X 160 /* pixels in display */
44 #define PIX_Y 128 /* pixels in display */
45 #define PIX_BORDER 16 /* border pixels from edge to first tile */
46 #define CELL_X_SZ 4
47 #define CELL_Y_SZ 8
48 #define CELL_X ((PIX_X - (2 * PIX_BORDER)) / CELL_X_SZ) /* tiles in display */
49 #define CELL_Y ((PIX_Y - (2 * PIX_BORDER)) / CELL_Y_SZ) /* tiles in display */
50
51 #define PALETTE_ENTRIES 16
52 static const DCPU16_WORD palette_default_[PALETTE_ENTRIES] = {
53 0x0000, /* black */
54 0x000a, /* blue */
55 0x00a0, /* green */
56 0x00aa, /* cyan */
57 0x0a05, /* red */
58 0x0a0f, /* magenta */
59 0x0aa5, /* yellow */
60 0x0aaf, /* pale blue */
61 0x0555, /* grey */
62 0x055f, /* light blue */
63 0x05f5, /* light green*/
64 0x05ff, /* light cyan */
65 0x0f55, /* light red */
66 0x0f5f, /* light magenta */
67 0x0ff5, /* light yellow */
68 0x0fff /* white */
69 };
70
71 struct pixel_ {
72 unsigned char r;
73 unsigned char g;
74 unsigned char b;
75 unsigned char a;
76 };
77
78 struct lem1802_ {
79 long long cycle_activated; /* running since */
80 long long cycles_until_active_; /* for tracking power-up delay */
81
82 DCPU16_WORD video_base;
83 DCPU16_WORD font_base;
84 DCPU16_WORD palette_base;
85 DCPU16_WORD border_color;
86 struct pixel_ *pixbuf;
87
88 unsigned int refresh_rate; /* redraw every n cycles */
89 unsigned int refresh_tally_; /* tick */
90
91 unsigned int blink_rate; /* toggle every n cycles? still figuring this out.. */
92 unsigned int blink_tally_; /* tick */
93 unsigned int blink_state;
94
95 enum cycle_state_ {
96 CYCLE_IDLE,
97 CYCLE_COPY_TO_RAM,
98 } cycle_state_;
99 const DCPU16_WORD *cycle_state_copy_src_ptr_;
100 DCPU16_WORD cycle_state_copy_dst_addr_;
101 size_t cycle_state_copy_words_;
102
103 int (*render)(void *, struct pixel_ *, size_t, size_t);
104 void *renderer_data;
105 };
106
107 static
108 long long power_on_cycles_(void) {
109 struct tv;
110 long long r = 0;
111
112 #if WANT_DELAY_START
113 gettimeofday(&tv, NULL);
114 r += LEM1802_POWER_ON_CYCLES - (LEM1802_POWER_ON_CYCLES / 10);
115 r += tv.tv_usec % (LEM1802_POWER_ON_CYCLES / 5);
116 #endif
117
118 return r;
119 }
120
121 static inline
122 void pixel_color_(struct pixel_ *pix, DCPU16_WORD color) {
123 unsigned char x;
124
125 x = (color >> 0) & 0x000f;
126 pix->r = x | (x << 4);
127
128 x = (color >> 4) & 0x000f;
129 pix->g = x | (x << 4);
130
131 x = (color >> 8) & 0x000f;
132 pix->b = x | (x << 4);
133
134 x = (color >> 12) & 0x000f;
135 pix->a = x | (x << 4);
136 }
137
138 static
139 void pixbuf_border_paint_(struct pixel_ *pixbuf, struct pixel_ *border) {
140 size_t x, y, i;
141
142 TRACE("%s>> painted border", __func__);
143
144 /* top */
145 for (y = 0; y < PIX_BORDER; y++) {
146 for (x = 0; x < PIX_X; x++) {
147 i = (y * PIX_X) + x;
148 pixbuf[i] = *border;
149 i = ((PIX_Y - y) * PIX_X) + x;
150 pixbuf[i] = *border;
151 }
152 }
153
154 /* sides */
155 for (y = PIX_BORDER; y < (PIX_Y - PIX_BORDER + 1); y++)
156 for (x = 0; x < PIX_BORDER; x++) {
157 i = (y * PIX_X) + x;
158 pixbuf[i] = *border;
159 pixbuf[i + (PIX_X - PIX_BORDER)] = *border;
160 }
161 }
162
163 static
164 void font_tile_paint_(struct pixel_ *p, struct pixel_ *fg, struct pixel_ *bg, DCPU16_WORD *tile) {
165 size_t pix_x, pix_y;
166 unsigned char *font_bitmap = (unsigned char *)tile;
167
168 #if 0
169 TRACE("%s>> fg:(%u,%u,%u) bg:(%u,%u,%u) font_bitmap:%02x %02x %02x %02x", __func__,
170 fg->r, fg->g, fg->b,
171 bg->r, bg->g, bg->b,
172 font_bitmap[0], font_bitmap[1], font_bitmap[2], font_bitmap[3]);
173 #endif
174
175 for (pix_x = 0; pix_x < CELL_X_SZ; pix_x++) {
176 for (pix_y = 0; pix_y < CELL_Y_SZ; pix_y++) {
177 if ((font_bitmap[pix_x] >> pix_y) & 0x01)
178 p[((CELL_Y_SZ - pix_y - 1) * PIX_X) + pix_x] = *fg;
179 else
180 p[((CELL_Y_SZ - pix_y - 1) * PIX_X) + pix_x] = *bg;
181 }
182 }
183 }
184
185 static
186 void pixbuf_addr_paint_(struct pixel_ *pixbuf, DCPU16_WORD *mem, DCPU16_WORD base, DCPU16_WORD addr, DCPU16_WORD *palette, DCPU16_WORD *tiles, unsigned int blink_state) {
187 struct pixel_ *tilestart = pixbuf; /* start of display */
188 unsigned int cell_x = addr % (PIX_X / CELL_X_SZ),
189 cell_y = addr / (PIX_X / CELL_X_SZ);
190 struct pixel_ fg, bg;
191 DCPU16_WORD *font_bitmap;
192 int blink;
193
194 cell_x = (addr - base) % CELL_X;
195 cell_y = (addr - base) / CELL_X;
196
197 #if 0
198 TRACE("%s>> addr:0x%04x col:%u row:%u v:%hu",
199 __func__,
200 addr,
201 cell_x, cell_y, mem[addr]);
202 #endif
203
204 blink = mem[addr] & 0x0080;
205
206 /* tiles take two words each */
207 font_bitmap = tiles + (2 * (mem[addr] & 0x7f));
208
209 pixel_color_(&bg, palette[(mem[addr] >> 8) & 0x0f]);
210 if (blink && blink_state)
211 pixel_color_(&fg, palette[(mem[addr] >> 8) & 0x0f]);
212 else
213 pixel_color_(&fg, palette[(mem[addr] >> 12) & 0x0f]);
214
215 tilestart += (PIX_X * PIX_BORDER); /* skip top border */
216 tilestart += (CELL_Y_SZ * PIX_X) * cell_y; /* skip down to row */
217
218 tilestart += PIX_BORDER; /* skip side border */
219 tilestart += (CELL_X_SZ) * cell_x; /* skip to column */
220
221 font_tile_paint_(tilestart, &fg, &bg, font_bitmap);
222 }
223
224 static
225 void lem1802_pixbuf_refresh_full_(struct lem1802_ *display, DCPU16_WORD *mem) {
226 struct pixel_ border;
227 size_t tile;
228
229 #if 0
230 TRACE("%s>> video_base:0x%04x", __func__, display->video_base);
231 #endif
232
233 if (display->cycles_until_active_) {
234 /* show cute power-up sequence.. */
235 memset(display->pixbuf, 0, PIX_X * PIX_Y * sizeof *display->pixbuf);
236 return;
237 }
238
239 if (display->video_base == 0) {
240 /* disconnected, blank display */
241 memset(display->pixbuf, 0, PIX_X * PIX_Y * sizeof *display->pixbuf);
242 return;
243 }
244
245 pixel_color_(&border, display->border_color);
246 pixbuf_border_paint_(display->pixbuf, &border);
247
248 for (tile = 0; tile < CELL_X * CELL_Y; tile++) {
249 pixbuf_addr_paint_(display->pixbuf,
250 mem,
251 display->video_base,
252 display->video_base + tile,
253 display->palette_base ? mem + display->palette_base : (DCPU16_WORD *)palette_default_,
254 display->font_base ? mem + display->font_base : (DCPU16_WORD *)chargen_4x8_glyphs,
255 display->blink_state);
256 }
257 }
258
259 static
260 int pixbuf_render_pnm_(void *data, struct pixel_ *pixbuf, size_t x, size_t y) {
261 FILE *f = (FILE *)data;
262 size_t i;
263 fprintf(f, "P6\n"
264 "%lu %lu\n"
265 "255\n",
266 x, y);
267 for (i = 0; i < x * y; i++) {
268 fwrite(&pixbuf[i].r, 1, 1, f);
269 fwrite(&pixbuf[i].g, 1, 1, f);
270 fwrite(&pixbuf[i].b, 1, 1, f);
271 }
272 fclose(f);
273
274 return 0;
275 }
276
277 #ifdef HAVE_LIBPNG
278 static
279 int pixbuf_render_png_(void *data, struct pixel_ *pixbuf, size_t x, size_t y) {
280 FILE *f = (FILE *)data;
281 int retval = 0;
282 png_structp png;
283 png_infop info;
284 size_t i;
285
286 png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
287 if (png == NULL) {
288 goto f_done;
289 }
290
291 info = png_create_info_struct(png);
292 if (info == NULL) {
293 png_destroy_write_struct(&png, (png_infopp)NULL);
294 goto f_done;
295 }
296
297 if (setjmp(png_jmpbuf(png))) {
298 png_destroy_write_struct(&png, &info);
299 goto f_done;
300 }
301
302 png_init_io(png, f);
303 png_set_IHDR(png, info, x, y, 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
304 png_set_invert_alpha(png);
305 png_write_info(png, info);
306 for (i = 0; i < y; i++) {
307 png_write_row(png, (unsigned char *)(pixbuf + (i * x)));
308 }
309 png_write_end(png, info);
310
311 png_destroy_write_struct(&png, &info);
312
313 f_done:
314 fclose(f);
315
316 return retval;
317 }
318 #endif /* HAVE_LIBPNG */
319
320 #ifdef HAVE_LIBVNCSERVER
321 /* create and return a new screen, easiest to do here because we know the screen dimensions */
322 rfbScreenInfoPtr lem1802_rfb_new(int argc, char *argv[]) {
323 rfbScreenInfoPtr s;
324 int paddedWidth = PIX_X + ( (PIX_X & 3) ? (4 - (PIX_X & 3)) : 0 );
325 int height = PIX_Y;
326 int bitsPerSample = 8;
327 int samplesPerPixel = 3;
328 int bytesPerPixel = 4;
329
330 s = rfbGetScreen(&argc, argv, paddedWidth, height, bitsPerSample, samplesPerPixel, bytesPerPixel);
331 if (s == NULL)
332 return NULL;
333
334 s->alwaysShared = TRUE;
335
336 #if 0
337 s->httpDir = "../classes";
338 #endif
339
340 TRACE("%s>> s:%p", __func__, VOIDP(s));
341 TRACE("%s>> s->kbdAddEvent:%p s->frameBuffer:%p", __func__, VOIDFP(s->kbdAddEvent), s->frameBuffer);
342
343 return s;
344 }
345
346
347 /* notify rfb server that pixels may have changed */
348 static
349 int pixbuf_render_vnc_(void *data, struct pixel_ *pixbuf, size_t x, size_t y) {
350 rfbScreenInfoPtr s = (rfbScreenInfoPtr)data;
351 int retval = 0;
352
353 (void)pixbuf;
354
355 /* derp */
356 if (s)
357 rfbMarkRectAsModified(s, 0, 0, x, y);
358
359 TRACE("%s>>", __func__);
360
361 return retval;
362 }
363 #endif /* HAVE_LIBVNCSERVER */
364
365
366 static
367 void lem1802_reset_(struct dcpu16 *vm, struct dcpu16_hw *hw) {
368 struct lem1802_ *display = (struct lem1802_ *)hw->data;
369
370 (void)vm;
371
372 display->cycle_activated = 0;
373 display->video_base = 0;
374 display->font_base = 0;
375 display->palette_base = 0;
376 display->border_color = 0;
377
378 memset(display->pixbuf, 0, PIX_X * PIX_Y * sizeof *display->pixbuf);
379
380 display->refresh_tally_ = 0;
381 display->blink_tally_ = 0;
382 display->blink_state = 0;
383
384 display->cycle_state_ = 0;
385
386 #if DEBUG
387 vm->trace_cb_("%s>>", __func__);
388 #endif /* DEBUG */
389 }
390
391 static
392 void lem1802_cycle_(struct dcpu16 *vm, struct dcpu16_hw *hw) {
393 struct lem1802_ *display = (struct lem1802_ *)hw->data;
394
395 (void)vm;
396 /*
397 for more cycle-accuracy, could step through video memory, if set,
398 one word per clock..
399 for now just count cycles and issue a full refresh/render
400 every so often
401 */
402
403 display->blink_tally_++;
404 if (display->blink_tally_ >= display->blink_rate) {
405 display->blink_tally_ = 0;
406 display->blink_state ^= 1;
407 TRACE("%s>> blink:%u (%u cycles)", __func__, display->blink_state, display->blink_rate);
408 }
409
410 display->refresh_tally_++;
411 if (display->refresh_tally_ >= display->refresh_rate) {
412 display->refresh_tally_ = 0;
413 if (display->render)
414 TRACE("%s>> refresh", __func__);
415 lem1802_pixbuf_refresh_full_(display, vm->ram);
416 display->render(display->renderer_data, display->pixbuf, PIX_X, PIX_Y);
417 }
418
419 switch (display->cycle_state_) {
420 case CYCLE_IDLE:
421 break;
422
423 case CYCLE_COPY_TO_RAM:
424 TRACE("%s>> copy_to_ram words:%zu src:%p dst_addr:0x%04x",
425 __func__,
426 display->cycle_state_copy_words_,
427 VOIDP(display->cycle_state_copy_src_ptr_),
428 display->cycle_state_copy_dst_addr_);
429 vm->ram[display->cycle_state_copy_dst_addr_] = *display->cycle_state_copy_src_ptr_;
430 display->cycle_state_copy_dst_addr_++;
431 display->cycle_state_copy_src_ptr_++;
432 display->cycle_state_copy_words_--;
433 if (display->cycle_state_copy_words_ == 0) {
434 display->cycle_state_ = CYCLE_IDLE;
435 }
436 break;
437 }
438
439 if (display->cycles_until_active_) {
440 display->cycles_until_active_--;
441 if (display->cycles_until_active_ == 0) {
442 TRACE("%s>> display now active", __func__);
443 }
444 }
445 }
446
447 static
448 void lem1802_hwi_(struct dcpu16 *vm, struct dcpu16_hw *hw) {
449 struct lem1802_ *display = (struct lem1802_ *)hw->data;
450 DCPU16_WORD reg_a = vm->reg[DCPU16_REG_A];
451 DCPU16_WORD reg_b = vm->reg[DCPU16_REG_B];
452
453 TRACE("%s>> A:0x%04x B:0x%04x", __func__, reg_a, reg_b);
454
455 switch (reg_a) {
456 case 0: /* MEM_MAP_SCREEN */
457 if (display->cycle_activated == 0 && reg_b) {
458 display->cycle_activated = vm->cycle_;
459 display->cycles_until_active_ = power_on_cycles_();
460 }
461 display->video_base = reg_b;
462 if (reg_b == 0)
463 display->cycle_activated = 0;
464 break;
465
466 case 1: /* MEM_MAP_FONT */
467 display->font_base = reg_b;
468 break;
469
470 case 2: /* MEM_MAP_PALETTE */
471 display->palette_base = reg_b;
472 break;
473
474 case 3: /* SET_BORDER_COLOR */
475 display->border_color = reg_b & 0x000f;
476 break;
477
478 case 4: /* MEM_DUMP_FONT */
479 display->cycle_state_copy_src_ptr_ = (DCPU16_WORD *)chargen_4x8_glyphs;
480 display->cycle_state_copy_dst_addr_ = reg_b;
481 display->cycle_state_copy_words_ = 256;
482 display->cycle_state_ = CYCLE_COPY_TO_RAM;
483 dcpu16_cycle_inc(vm, 256);
484 break;
485
486 case 5: /* MEM_DUMP_PALETTE */
487 display->cycle_state_copy_src_ptr_ = palette_default_;
488 display->cycle_state_copy_dst_addr_ = reg_b;
489 display->cycle_state_copy_words_ = 16;
490 display->cycle_state_ = CYCLE_COPY_TO_RAM;
491 dcpu16_cycle_inc(vm, 16);
492 break;
493 }
494 }
495
496 static struct renderer_ {
497 char *name;
498 char *args;
499 int (*renderer)(void *, struct pixel_ *, size_t, size_t);
500 } lem1802_renderers_[] = {
501 { "pnm", "filename", pixbuf_render_pnm_ },
502 #ifdef HAVE_LIBPNG
503 { "png", "filename", pixbuf_render_png_ },
504 #endif /* HAVE_LIBPNG */
505 #ifdef HAVE_LIBVNCSERVER
506 { "vnc", "", pixbuf_render_vnc_ },
507 #endif /* HAVE_LIBVNCSERVER */
508 { "none", "", NULL },
509 { NULL, NULL, NULL }
510 };
511
512
513 char *lem1802_renderers_iter(void **iterp, char **name, char **args) {
514 struct renderer_ **r = (struct renderer_ **)iterp;
515
516 if (*r == NULL)
517 *r = lem1802_renderers_;
518 else
519 (*r)++;
520
521 if ((*r)->name == NULL) {
522 *r = NULL;
523 return NULL;
524 }
525
526 *name = (*r)->name;
527 *args = (*r)->args;
528
529 return (*r)->name;
530 }
531
532 int lem1802_data_init_(struct dcpu16_hw *hw, void *data) {
533 (void)data;
534
535 hw->data = calloc(1, sizeof(struct lem1802_));
536 if (hw->data == NULL) {
537 hw->vm->warn_cb_("%s():%s", "calloc", strerror(errno));
538 return -1;
539 }
540
541 ((struct lem1802_ *)(hw->data))->pixbuf = calloc(PIX_X * PIX_Y, sizeof *((struct lem1802_ *)(hw->data))->pixbuf);
542 if (((struct lem1802_ *)(hw->data))->pixbuf == NULL) {
543 hw->vm->warn_cb_("%s():%s", "calloc", strerror(errno));
544 free(hw->data);
545 hw->data = NULL;
546 return -1;
547 }
548
549 ((struct lem1802_ *)(hw->data))->refresh_rate = 1666;
550 ((struct lem1802_ *)(hw->data))->blink_rate = 75000;
551
552 return 0;
553 }
554
555 void lem1802_data_free_(struct dcpu16_hw *hw) {
556 if (hw) {
557 if (hw->data) {
558 if (((struct lem1802_ *)(hw->data))->pixbuf) {
559 free(((struct lem1802_ *)(hw->data))->pixbuf);
560 ((struct lem1802_ *)(hw->data))->pixbuf = NULL;
561 }
562 free(hw->data);
563 hw->data = NULL;
564 }
565 }
566 }
567
568 static struct dcpu16_hw_ctl_cmd ctl_[] = {
569 { "blink_rate", "const unsigned int *rate", "unsigned int *rate", "sets or gets cycles per blink toggle" },
570 { "refresh_rate", "const unsigned int *rate", "unsigned int *rate", "sets or gets cycles per screen refresh" },
571 #ifdef HAVE_LIBVNCSERVER
572 { "associate_rfbScreen", "rfbScreenInfoPtr", "NULL", "associates this lem1802 instance with an rfb display" },
573 #endif /* HAVE_LIBVNCSERVER */
574 { "renderer", "const char *", "NULL", "sets this lem1802 instance to use renderer" },
575 { "renderer_data", "void *", "NULL", "sets renderer-specific data" },
576 { NULL, NULL, NULL, NULL }
577 };
578 int lem1802_data_ctl_(struct dcpu16_hw *hw, const char *cmd, void *data_in, void *data_out) {
579 if (strcmp(cmd, "blink_rate") == 0) {
580 struct lem1802_ *display = (struct lem1802_ *)hw->data;
581 const unsigned int *rate_in = (const unsigned int *)data_in;
582 unsigned int *rate_out = (unsigned int *)data_out;
583
584 if (rate_out) {
585 *rate_out = display->blink_rate;
586 }
587
588 if (rate_in) {
589 display->blink_rate = *rate_in;
590 }
591
592 return 0;
593 }
594
595 if (strcmp(cmd, "refresh_rate") == 0) {
596 struct lem1802_ *display = (struct lem1802_ *)hw->data;
597 const unsigned int *rate_in = (const unsigned int *)data_in;
598 unsigned int *rate_out = (unsigned int *)data_out;
599
600 if (rate_out) {
601 *rate_out = display->refresh_rate;
602 }
603
604 if (rate_in) {
605 display->refresh_rate = *rate_in;
606 }
607
608 return 0;
609 }
610
611 #ifdef HAVE_LIBVNCSERVER
612 if (strcmp(cmd, "associate_rfbScreen") == 0) {
613 struct lem1802_ *display = (struct lem1802_ *)hw->data;
614 rfbScreenInfoPtr rfbScreen = (rfbScreenInfoPtr)data_out;
615 (void)data_in;
616
617 if (rfbScreen == NULL)
618 return -EFAULT;
619
620 rfbScreen->desktopName = "NYA ELEKTRISKA LEM1802";
621 rfbScreen->frameBuffer = (char *)display->pixbuf;
622
623 return 0;
624 }
625 #endif /* HAVE_LIBVNCSERVER */
626
627 if (strcmp(cmd, "renderer") == 0) {
628 struct lem1802_ *display = (struct lem1802_ *)hw->data;
629 char *renderer = (char *)data_in;
630 (void)data_out;
631 struct renderer_ *r;
632
633 for (r = lem1802_renderers_; r->renderer; r++) {
634 if (strcmp(renderer, r->name) == 0) {
635 display->render = r->renderer;
636 TRACE("%s>> renderer set to %s", __func__, renderer);
637 return 0;
638 }
639 }
640
641 hw->vm->warn_cb_("unknown renderer '%s'", renderer);
642
643 return -ENOENT;
644 }
645
646 if (strcmp(cmd, "renderer_data") == 0) {
647 struct lem1802_ *display = (struct lem1802_ *)hw->data;
648 (void)data_out;
649
650 display->renderer_data = data_in;
651
652 return 0;
653 }
654
655 return -EINVAL;
656 }
657
658
659 static struct dcpu16_hw hw_ = {
660 .name_ = "LEM1802 - Low Energy Monitor",
661 .id_l = 0xf615,
662 .id_h = 0x7349,
663 .ver = 0x1802,
664 .mfg_l = 0x8b36,
665 .mfg_h = 0x1c6c,
666 .hwi = lem1802_hwi_,
667 .cycle = lem1802_cycle_,
668 .reset = lem1802_reset_,
669 .data = (struct lem1802_ *)NULL
670 };
671
672 struct dcpu16_hw_module dcpu16_hw_module_lem1802 = {
673 .template = &hw_,
674 .data_init = lem1802_data_init_,
675 .data_free = lem1802_data_free_,
676 .ctl = lem1802_data_ctl_,
677 .ctl_cmd = ctl_,
678 };
679