s1d13700_sim.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Model of the TCA9539 output stage and the S1D13700 indirect interface.
  3. *
  4. * It sees only the I2C bytes the panel core produces, so what it renders is
  5. * what the real panel would receive, and it counts anything the hardware
  6. * would not tolerate.
  7. */
  8. #ifndef S1D13700_SIM_H
  9. #define S1D13700_SIM_H
  10. #include <stdbool.h>
  11. #include <stddef.h>
  12. #include <stdint.h>
  13. struct s1d_sim_faults {
  14. unsigned int a0_with_wr_edge; /* A0 changed in the same update as WR# */
  15. unsigned int data_no_command; /* parameter with no command in progress */
  16. unsigned int data_no_mwrite; /* parameter beyond what a command takes */
  17. unsigned int unknown_command;
  18. unsigned int bad_tca_register;
  19. unsigned int short_message; /* message ended between P0 and P1 */
  20. unsigned int bad_system_set; /* FX != 7 or C/R, AP mismatch */
  21. unsigned int write_in_reset;
  22. };
  23. struct s1d_sim {
  24. uint8_t vram[32768];
  25. uint8_t out[2]; /* TCA output latches */
  26. uint8_t config[2]; /* TCA direction: 1 = input */
  27. uint8_t cmd;
  28. unsigned int nparam;
  29. uint8_t params[16];
  30. unsigned int cursor;
  31. int step;
  32. /* decoded configuration */
  33. unsigned int cr, tcr, lf, ap, fx, sad1, sl1, bpp;
  34. bool configured;
  35. bool display_on;
  36. uint8_t disp_flags;
  37. struct s1d_sim_faults faults;
  38. unsigned long latches;
  39. };
  40. void s1d_sim_init(struct s1d_sim *s);
  41. /* One I2C write message: buf[0] is the TCA9539 command byte */
  42. void s1d_sim_i2c_write(struct s1d_sim *s, const uint8_t *buf, size_t len);
  43. unsigned int s1d_sim_fault_count(const struct s1d_sim *s);
  44. /*
  45. * Render what the panel shows into levels[width * height], one level per
  46. * pixel, using only the controller's decoded configuration. Returns false if
  47. * the display is off or not configured, or the size does not match.
  48. */
  49. bool s1d_sim_render(const struct s1d_sim *s, unsigned int width,
  50. unsigned int height, uint8_t *levels);
  51. #endif /* S1D13700_SIM_H */