2021-10-19 07:45:05 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/*
|
|
|
|
* Character line display core support
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 Imagination Technologies
|
|
|
|
* Author: Paul Burton <paul.burton@mips.com>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2021 Glider bv
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINEDISP_H
|
|
|
|
#define _LINEDISP_H
|
|
|
|
|
2024-02-12 10:01:38 -07:00
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/timer_types.h>
|
|
|
|
|
2024-02-12 10:01:42 -07:00
|
|
|
#include <linux/map_to_7segment.h>
|
|
|
|
#include <linux/map_to_14segment.h>
|
|
|
|
|
2024-02-12 10:01:41 -07:00
|
|
|
struct linedisp;
|
|
|
|
|
2024-02-12 10:01:42 -07:00
|
|
|
/**
|
|
|
|
* enum linedisp_map_type - type of the character mapping
|
|
|
|
* @LINEDISP_MAP_SEG7: Map characters to 7 segment display
|
|
|
|
* @LINEDISP_MAP_SEG14: Map characters to 14 segment display
|
|
|
|
*/
|
|
|
|
enum linedisp_map_type {
|
|
|
|
LINEDISP_MAP_SEG7,
|
|
|
|
LINEDISP_MAP_SEG14,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct linedisp_map - character mapping
|
|
|
|
* @type: type of the character mapping
|
|
|
|
* @map: conversion character mapping
|
|
|
|
* @size: size of the @map
|
|
|
|
*/
|
|
|
|
struct linedisp_map {
|
|
|
|
enum linedisp_map_type type;
|
|
|
|
union {
|
|
|
|
struct seg7_conversion_map seg7;
|
|
|
|
struct seg14_conversion_map seg14;
|
|
|
|
} map;
|
|
|
|
unsigned int size;
|
|
|
|
};
|
|
|
|
|
2024-02-12 10:01:41 -07:00
|
|
|
/**
|
|
|
|
* struct linedisp_ops - character line display operations
|
2024-02-12 10:01:42 -07:00
|
|
|
* @get_map_type: Function called to get the character mapping, if required
|
2024-02-12 10:01:41 -07:00
|
|
|
* @update: Function called to update the display. This must not sleep!
|
|
|
|
*/
|
|
|
|
struct linedisp_ops {
|
2024-02-12 10:01:42 -07:00
|
|
|
int (*get_map_type)(struct linedisp *linedisp);
|
2024-02-12 10:01:41 -07:00
|
|
|
void (*update)(struct linedisp *linedisp);
|
|
|
|
};
|
|
|
|
|
2021-10-19 07:45:05 -07:00
|
|
|
/**
|
|
|
|
* struct linedisp - character line display private data structure
|
|
|
|
* @dev: the line display device
|
|
|
|
* @timer: timer used to implement scrolling
|
2024-02-12 10:01:41 -07:00
|
|
|
* @ops: character line display operations
|
2021-10-19 07:45:05 -07:00
|
|
|
* @buf: pointer to the buffer for the string currently displayed
|
|
|
|
* @message: the full message to display or scroll on the display
|
|
|
|
* @num_chars: the number of characters that can be displayed
|
|
|
|
* @message_len: the length of the @message string
|
|
|
|
* @scroll_pos: index of the first character of @message currently displayed
|
|
|
|
* @scroll_rate: scroll interval in jiffies
|
2024-02-12 10:01:36 -07:00
|
|
|
* @id: instance id of this display
|
2021-10-19 07:45:05 -07:00
|
|
|
*/
|
|
|
|
struct linedisp {
|
|
|
|
struct device dev;
|
|
|
|
struct timer_list timer;
|
2024-02-12 10:01:41 -07:00
|
|
|
const struct linedisp_ops *ops;
|
2024-02-12 10:01:42 -07:00
|
|
|
struct linedisp_map *map;
|
2021-10-19 07:45:05 -07:00
|
|
|
char *buf;
|
|
|
|
char *message;
|
|
|
|
unsigned int num_chars;
|
|
|
|
unsigned int message_len;
|
|
|
|
unsigned int scroll_pos;
|
|
|
|
unsigned int scroll_rate;
|
2024-02-12 10:01:36 -07:00
|
|
|
unsigned int id;
|
2021-10-19 07:45:05 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
int linedisp_register(struct linedisp *linedisp, struct device *parent,
|
2024-02-19 09:58:01 -07:00
|
|
|
unsigned int num_chars, const struct linedisp_ops *ops);
|
2021-10-19 07:45:05 -07:00
|
|
|
void linedisp_unregister(struct linedisp *linedisp);
|
|
|
|
|
|
|
|
#endif /* LINEDISP_H */
|