line-display.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. * Copyright (C) 2025 Jean-François Lessard
  10. */
  11. #ifndef _LINEDISP_H
  12. #define _LINEDISP_H
  13. #include <linux/device.h>
  14. #include <linux/timer_types.h>
  15. #include <linux/map_to_7segment.h>
  16. #include <linux/map_to_14segment.h>
  17. struct linedisp;
  18. /**
  19. * enum linedisp_map_type - type of the character mapping
  20. * @LINEDISP_MAP_SEG7: Map characters to 7 segment display
  21. * @LINEDISP_MAP_SEG14: Map characters to 14 segment display
  22. */
  23. enum linedisp_map_type {
  24. LINEDISP_MAP_SEG7,
  25. LINEDISP_MAP_SEG14,
  26. };
  27. /**
  28. * struct linedisp_map - character mapping
  29. * @type: type of the character mapping
  30. * @map: conversion character mapping
  31. * @size: size of the @map
  32. */
  33. struct linedisp_map {
  34. enum linedisp_map_type type;
  35. union {
  36. struct seg7_conversion_map seg7;
  37. struct seg14_conversion_map seg14;
  38. } map;
  39. unsigned int size;
  40. };
  41. /**
  42. * struct linedisp_ops - character line display operations
  43. * @get_map_type: Function called to get the character mapping, if required
  44. * @update: Function called to update the display. This must not sleep!
  45. */
  46. struct linedisp_ops {
  47. int (*get_map_type)(struct linedisp *linedisp);
  48. void (*update)(struct linedisp *linedisp);
  49. };
  50. /**
  51. * struct linedisp - character line display private data structure
  52. * @dev: the line display device
  53. * @timer: timer used to implement scrolling
  54. * @ops: character line display operations
  55. * @buf: pointer to the buffer for the string currently displayed
  56. * @message: the full message to display or scroll on the display
  57. * @num_chars: the number of characters that can be displayed
  58. * @message_len: the length of the @message string
  59. * @scroll_pos: index of the first character of @message currently displayed
  60. * @scroll_rate: scroll interval in jiffies
  61. * @id: instance id of this display
  62. */
  63. struct linedisp {
  64. struct device dev;
  65. struct timer_list timer;
  66. const struct linedisp_ops *ops;
  67. struct linedisp_map *map;
  68. char *buf;
  69. char *message;
  70. unsigned int num_chars;
  71. unsigned int message_len;
  72. unsigned int scroll_pos;
  73. unsigned int scroll_rate;
  74. unsigned int id;
  75. };
  76. int linedisp_attach(struct linedisp *linedisp, struct device *dev,
  77. unsigned int num_chars, const struct linedisp_ops *ops);
  78. void linedisp_detach(struct device *dev);
  79. int linedisp_register(struct linedisp *linedisp, struct device *parent,
  80. unsigned int num_chars, const struct linedisp_ops *ops);
  81. void linedisp_unregister(struct linedisp *linedisp);
  82. #endif /* LINEDISP_H */