drivers/staging/fbtft/fb_ili9163.c
Source file repositories/reference/linux-study-clean/drivers/staging/fbtft/fb_ili9163.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/fbtft/fb_ili9163.c- Extension
.c- Size
- 7666 bytes
- Lines
- 261
- Domain
- Driver Families
- Bucket
- drivers/staging
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/init.hlinux/delay.hvideo/mipi_display.hfbtft.h
Detected Declarations
function Copyrightfunction set_addr_winfunction set_varfunction gamma_adj
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* FB driver for the ILI9163 LCD Controller
*
* Copyright (C) 2015 Kozhevnikov Anatoly
*
* Based on ili9325.c by Noralf Tronnes and
* .S.U.M.O.T.O.Y. by Max MC Costa (https://github.com/sumotoy/TFT_ILI9163C).
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <video/mipi_display.h>
#include "fbtft.h"
#define DRVNAME "fb_ili9163"
#define WIDTH 128
#define HEIGHT 128
#define BPP 16
#define FPS 30
#ifdef GAMMA_ADJ
#define GAMMA_LEN 15
#define GAMMA_NUM 1
#define DEFAULT_GAMMA "36 29 12 22 1C 15 42 B7 2F 13 12 0A 11 0B 06\n"
#endif
/* ILI9163C commands */
#define CMD_FRMCTR1 0xB1 /* Frame Rate Control */
/* (In normal mode/Full colors) */
#define CMD_FRMCTR2 0xB2 /* Frame Rate Control (In Idle mode/8-colors) */
#define CMD_FRMCTR3 0xB3 /* Frame Rate Control */
/* (In Partial mode/full colors) */
#define CMD_DINVCTR 0xB4 /* Display Inversion Control */
#define CMD_RGBBLK 0xB5 /* RGB Interface Blanking Porch setting */
#define CMD_DFUNCTR 0xB6 /* Display Function set 5 */
#define CMD_SDRVDIR 0xB7 /* Source Driver Direction Control */
#define CMD_GDRVDIR 0xB8 /* Gate Driver Direction Control */
#define CMD_PWCTR1 0xC0 /* Power_Control1 */
#define CMD_PWCTR2 0xC1 /* Power_Control2 */
#define CMD_PWCTR3 0xC2 /* Power_Control3 */
#define CMD_PWCTR4 0xC3 /* Power_Control4 */
#define CMD_PWCTR5 0xC4 /* Power_Control5 */
#define CMD_VCOMCTR1 0xC5 /* VCOM_Control 1 */
#define CMD_VCOMCTR2 0xC6 /* VCOM_Control 2 */
#define CMD_VCOMOFFS 0xC7 /* VCOM Offset Control */
#define CMD_PGAMMAC 0xE0 /* Positive Gamma Correction Setting */
#define CMD_NGAMMAC 0xE1 /* Negative Gamma Correction Setting */
#define CMD_GAMRSEL 0xF2 /* GAM_R_SEL */
/*
* This display:
* http://www.ebay.com/itm/Replace-Nokia-5110-LCD-1-44-Red-Serial-128X128-SPI-
* Color-TFT-LCD-Display-Module-/271422122271
* This particular display has a design error! The controller has 3 pins to
* configure to constrain the memory and resolution to a fixed dimension (in
* that case 128x128) but they leaved those pins configured for 128x160 so
* there was several pixel memory addressing problems.
* I solved by setup several parameters that dynamically fix the resolution as
* needit so below the parameters for this display. If you have a strain or a
* correct display (can happen with chinese) you can copy those parameters and
* create setup for different displays.
*/
#ifdef RED
#define __OFFSET 32 /*see note 2 - this is the red version */
#else
#define __OFFSET 0 /*see note 2 - this is the black version */
#endif
static int init_display(struct fbtft_par *par)
{
par->fbtftops.reset(par);
write_reg(par, MIPI_DCS_SOFT_RESET); /* software reset */
mdelay(500);
write_reg(par, MIPI_DCS_EXIT_SLEEP_MODE); /* exit sleep */
mdelay(5);
write_reg(par, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_16BIT);
/* default gamma curve 3 */
write_reg(par, MIPI_DCS_SET_GAMMA_CURVE, 0x02);
#ifdef GAMMA_ADJ
write_reg(par, CMD_GAMRSEL, 0x01); /* Enable Gamma adj */
#endif
write_reg(par, MIPI_DCS_ENTER_NORMAL_MODE);
write_reg(par, CMD_DFUNCTR, 0xff, 0x06);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/init.h`, `linux/delay.h`, `video/mipi_display.h`, `fbtft.h`.
- Detected declarations: `function Copyright`, `function set_addr_win`, `function set_var`, `function gamma_adj`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.