drivers/staging/fbtft/fb_hx8340bn.c
Source file repositories/reference/linux-study-clean/drivers/staging/fbtft/fb_hx8340bn.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/fbtft/fb_hx8340bn.c- Extension
.c- Size
- 5717 bytes
- Lines
- 218
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/init.hlinux/vmalloc.hlinux/spi/spi.hlinux/delay.hvideo/mipi_display.hfbtft.h
Detected Declarations
function init_displayfunction set_varfunction set_gamma
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* FB driver for the HX8340BN LCD Controller
*
* This display uses 9-bit SPI: Data/Command bit + 8 data bits
* For platforms that doesn't support 9-bit, the driver is capable
* of emulating this using 8-bit transfer.
* This is done by transferring eight 9-bit words in 9 bytes.
*
* Copyright (C) 2013 Noralf Tronnes
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/vmalloc.h>
#include <linux/spi/spi.h>
#include <linux/delay.h>
#include <video/mipi_display.h>
#include "fbtft.h"
#define DRVNAME "fb_hx8340bn"
#define WIDTH 176
#define HEIGHT 220
#define TXBUFLEN (4 * PAGE_SIZE)
#define DEFAULT_GAMMA "1 3 0E 5 0 2 09 0 6 1 7 1 0 2 2\n" \
"3 3 17 8 4 7 05 7 6 0 3 1 6 0 0 "
static bool emulate;
module_param(emulate, bool, 0000);
MODULE_PARM_DESC(emulate, "Force emulation in 9-bit mode");
static int init_display(struct fbtft_par *par)
{
par->fbtftops.reset(par);
/* BTL221722-276L startup sequence, from datasheet */
/*
* SETEXTCOM: Set extended command set (C1h)
* This command is used to set extended command set access enable.
* Enable: After command (C1h), must write: ffh,83h,40h
*/
write_reg(par, 0xC1, 0xFF, 0x83, 0x40);
/*
* Sleep out
* This command turns off sleep mode.
* In this mode the DC/DC converter is enabled, Internal oscillator
* is started, and panel scanning is started.
*/
write_reg(par, 0x11);
mdelay(150);
/* Undoc'd register? */
write_reg(par, 0xCA, 0x70, 0x00, 0xD9);
/*
* SETOSC: Set Internal Oscillator (B0h)
* This command is used to set internal oscillator related settings
* OSC_EN: Enable internal oscillator
* Internal oscillator frequency: 125% x 2.52MHz
*/
write_reg(par, 0xB0, 0x01, 0x11);
/* Drive ability setting */
write_reg(par, 0xC9, 0x90, 0x49, 0x10, 0x28, 0x28, 0x10, 0x00, 0x06);
mdelay(20);
/*
* SETPWCTR5: Set Power Control 5(B5h)
* This command is used to set VCOM Low and VCOM High Voltage
* VCOMH 0110101 : 3.925
* VCOML 0100000 : -1.700
* 45h=69 VCOMH: "VMH" + 5d VCOML: "VMH" + 5d
*/
write_reg(par, 0xB5, 0x35, 0x20, 0x45);
/*
* SETPWCTR4: Set Power Control 4(B4h)
* VRH[4:0]: Specify the VREG1 voltage adjusting.
* VREG1 voltage is for gamma voltage setting.
* BT[2:0]: Switch the output factor of step-up circuit 2
* for VGH and VGL voltage generation.
*/
write_reg(par, 0xB4, 0x33, 0x25, 0x4C);
mdelay(10);
/*
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/init.h`, `linux/vmalloc.h`, `linux/spi/spi.h`, `linux/delay.h`, `video/mipi_display.h`, `fbtft.h`.
- Detected declarations: `function init_display`, `function set_var`, `function set_gamma`.
- 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.