line-display.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Character line display core support
  4. *
  5. * Copyright (C) 2016 Imagination Technologies
  6. * Author: Paul Burton <paul.burton@mips.com>
  7. *
  8. * Copyright (C) 2021 Glider bv
  9. */
  10. #ifndef _LINEDISP_H
  11. #define _LINEDISP_H
  12. #include <linux/device.h>
  13. #include <linux/timer_types.h>
  14. #include <linux/map_to_7segment.h>
  15. #include <linux/map_to_14segment.h>
  16. struct linedisp;
  17. /**
  18. * enum linedisp_map_type - type of the character mapping
  19. * @LINEDISP_MAP_SEG7: Map characters to 7 segment display
  20. * @LINEDISP_MAP_SEG14: Map characters to 14 segment display
  21. */
  22. enum linedisp_map_type {
  23. LINEDISP_MAP_SEG7,
  24. LINEDISP_MAP_SEG14,
  25. };
  26. /**
  27. * struct linedisp_map - character mapping
  28. * @type: type of the character mapping
  29. * @map: conversion character mapping
  30. * @size: size of the @map
  31. */
  32. struct linedisp_map {
  33. enum linedisp_map_type type;
  34. union {
  35. struct seg7_conversion_map seg7;
  36. struct seg14_conversion_map seg14;
  37. } map;
  38. unsigned int size;
  39. };
  40. /**
  41. * struct linedisp_ops - character line display operations
  42. * @get_map_type: Function called to get the character mapping, if required
  43. * @update: Function called to update the display. This must not sleep!
  44. */
  45. struct linedisp_ops {
  46. int (*get_map_type)(struct linedisp *linedisp);
  47. void (*update)(struct linedisp *linedisp);
  48. };
  49. /**
  50. * struct linedisp - character line display private data structure
  51. * @dev: the line display device
  52. * @timer: timer used to implement scrolling
  53. * @ops: character line display operations
  54. * @buf: pointer to the buffer for the string currently displayed
  55. * @message: the full message to display or scroll on the display
  56. * @num_chars: the number of characters that can be displayed
  57. * @message_len: the length of the @message string
  58. * @scroll_pos: index of the first character of @message currently displayed
  59. * @scroll_rate: scroll interval in jiffies
  60. * @id: instance id of this display
  61. */
  62. struct linedisp {
  63. struct device dev;
  64. struct timer_list timer;
  65. const struct linedisp_ops *ops;
  66. struct linedisp_map *map;
  67. char *buf;
  68. char *message;
  69. unsigned int num_chars;
  70. unsigned int message_len;
  71. unsigned int scroll_pos;
  72. unsigned int scroll_rate;
  73. unsigned int id;
  74. };
  75. int linedisp_register(struct linedisp *linedisp, struct device *parent,
  76. unsigned int num_chars, const struct linedisp_ops *ops);
  77. void linedisp_unregister(struct linedisp *linedisp);
  78. #endif /* LINEDISP_H */