drivers/staging/fbtft/fb_sh1106.c
Source file repositories/reference/linux-study-clean/drivers/staging/fbtft/fb_sh1106.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/fbtft/fb_sh1106.c- Extension
.c- Size
- 4043 bytes
- Lines
- 178
- 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.hfbtft.h
Detected Declarations
function Copyrightfunction set_addr_winfunction set_gammafunction write_vmemfunction write_register
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* FB driver for the SH1106 OLED Controller
* Based on the SSD1306 driver by Noralf Tronnes
*
* Copyright (C) 2017 Heiner Kallweit
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/delay.h>
#include "fbtft.h"
#define DRVNAME "fb_sh1106"
#define WIDTH 128
#define HEIGHT 64
/* Init sequence based on the Adafruit SSD1306 Arduino library */
static int init_display(struct fbtft_par *par)
{
if (!par->info->var.xres || par->info->var.xres > WIDTH ||
!par->info->var.yres || par->info->var.yres > HEIGHT ||
par->info->var.yres % 8) {
dev_err(par->info->device, "Invalid screen size\n");
return -EINVAL;
}
if (par->info->var.rotate) {
dev_err(par->info->device, "Display rotation not supported\n");
return -EINVAL;
}
par->fbtftops.reset(par);
/* Set Display OFF */
write_reg(par, 0xAE);
/* Set Display Clock Divide Ratio/ Oscillator Frequency */
write_reg(par, 0xD5, 0x80);
/* Set Multiplex Ratio */
write_reg(par, 0xA8, par->info->var.yres - 1);
/* Set Display Offset */
write_reg(par, 0xD3, 0x00);
/* Set Display Start Line */
write_reg(par, 0x40 | 0x0);
/* Set Segment Re-map */
/* column address 127 is mapped to SEG0 */
write_reg(par, 0xA0 | 0x1);
/* Set COM Output Scan Direction */
/* remapped mode. Scan from COM[N-1] to COM0 */
write_reg(par, 0xC8);
/* Set COM Pins Hardware Configuration */
if (par->info->var.yres == 64)
/* A[4]=1b, Alternative COM pin configuration */
write_reg(par, 0xDA, 0x12);
else if (par->info->var.yres == 48)
/* A[4]=1b, Alternative COM pin configuration */
write_reg(par, 0xDA, 0x12);
else
/* A[4]=0b, Sequential COM pin configuration */
write_reg(par, 0xDA, 0x02);
/* Set Pre-charge Period */
write_reg(par, 0xD9, 0xF1);
/* Set VCOMH Deselect Level */
write_reg(par, 0xDB, 0x40);
/* Set Display ON */
write_reg(par, 0xAF);
msleep(150);
return 0;
}
static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
{
}
static int blank(struct fbtft_par *par, bool on)
{
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/init.h`, `linux/delay.h`, `fbtft.h`.
- Detected declarations: `function Copyright`, `function set_addr_win`, `function set_gamma`, `function write_vmem`, `function write_register`.
- 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.