// SPDX-License-Identifier: GPL-2.0+ /* * FB driver for the ST7789V LCD Controller * * Copyright (C) 2015 Dennis Menschel */ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/gpio/consumer.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/interrupt.h> #include <linux/completion.h> #include <linux/module.h> #include <video/mipi_display.h> #include "fbtft.h" #define DRVNAME … #define DEFAULT_GAMMA … #define HSD20_IPS_GAMMA … #define HSD20_IPS … /** * enum st7789v_command - ST7789V display controller commands * * @PORCTRL: porch setting * @GCTRL: gate control * @VCOMS: VCOM setting * @VDVVRHEN: VDV and VRH command enable * @VRHS: VRH set * @VDVS: VDV set * @VCMOFSET: VCOM offset set * @PWCTRL1: power control 1 * @PVGAMCTRL: positive voltage gamma control * @NVGAMCTRL: negative voltage gamma control * * The command names are the same as those found in the datasheet to ease * looking up their semantics and usage. * * Note that the ST7789V display controller offers quite a few more commands * which have been omitted from this list as they are not used at the moment. * Furthermore, commands that are compliant with the MIPI DCS have been left * out as well to avoid duplicate entries. */ enum st7789v_command { … }; #define MADCTL_BGR … #define MADCTL_MV … #define MADCTL_MX … #define MADCTL_MY … /* 60Hz for 16.6ms, configured as 2*16.6ms */ #define PANEL_TE_TIMEOUT_MS … static struct completion panel_te; /* completion for panel TE line */ static int irq_te; /* Linux IRQ for LCD TE line */ static irqreturn_t panel_te_handler(int irq, void *data) { … } /* * init_tearing_effect_line() - init tearing effect line. * @par: FBTFT parameter object. * * Return: 0 on success, or a negative error code otherwise. */ static int init_tearing_effect_line(struct fbtft_par *par) { … } /** * init_display() - initialize the display controller * * @par: FBTFT parameter object * * Most of the commands in this init function set their parameters to the * same default values which are already in place after the display has been * powered up. (The main exception to this rule is the pixel format which * would default to 18 instead of 16 bit per pixel.) * Nonetheless, this sequence can be used as a template for concrete * displays which usually need some adjustments. * * Return: 0 on success, < 0 if error occurred. */ static int init_display(struct fbtft_par *par) { … } /* * write_vmem() - write data to display. * @par: FBTFT parameter object. * @offset: offset from screen_buffer. * @len: the length of data to be writte. * * Return: 0 on success, or a negative error code otherwise. */ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) { … } /** * set_var() - apply LCD properties like rotation and BGR mode * * @par: FBTFT parameter object * * Return: 0 on success, < 0 if error occurred. */ static int set_var(struct fbtft_par *par) { … } /** * set_gamma() - set gamma curves * * @par: FBTFT parameter object * @curves: gamma curves * * Before the gamma curves are applied, they are preprocessed with a bitmask * to ensure syntactically correct input for the display controller. * This implies that the curves input parameter might be changed by this * function and that illegal gamma values are auto-corrected and not * reported as errors. * * Return: 0 on success, < 0 if error occurred. */ static int set_gamma(struct fbtft_par *par, u32 *curves) { … } /** * blank() - blank the display * * @par: FBTFT parameter object * @on: whether to enable or disable blanking the display * * Return: 0 on success, < 0 if error occurred. */ static int blank(struct fbtft_par *par, bool on) { … } static struct fbtft_display display = …; FBTFT_REGISTER_DRIVER(…); MODULE_ALIAS(…) …; MODULE_ALIAS(…) …; MODULE_ALIAS(…) …; MODULE_ALIAS(…) …; MODULE_DESCRIPTION(…) …; MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …;