drivers/gpu/drm/panel/panel-novatek-nt39016.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panel/panel-novatek-nt39016.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/panel/panel-novatek-nt39016.c- Extension
.c- Size
- 9158 bytes
- Lines
- 359
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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/delay.hlinux/device.hlinux/gpio/consumer.hlinux/media-bus-format.hlinux/module.hlinux/of.hlinux/regmap.hlinux/regulator/consumer.hlinux/spi/spi.hdrm/drm_modes.hdrm/drm_panel.h
Detected Declarations
struct nt39016_panel_infostruct nt39016enum nt39016_regsfunction nt39016_preparefunction nt39016_unpreparefunction nt39016_enablefunction nt39016_disablefunction nt39016_get_modesfunction nt39016_probefunction nt39016_remove
Annotated Snippet
struct nt39016_panel_info {
const struct drm_display_mode *display_modes;
unsigned int num_modes;
u16 width_mm, height_mm;
u32 bus_format, bus_flags;
};
struct nt39016 {
struct drm_panel drm_panel;
struct regmap *map;
struct regulator *supply;
const struct nt39016_panel_info *panel_info;
struct gpio_desc *reset_gpio;
};
static inline struct nt39016 *to_nt39016(struct drm_panel *panel)
{
return container_of(panel, struct nt39016, drm_panel);
}
#define RV(REG, VAL) { .reg = (REG), .def = (VAL), .delay_us = 2 }
static const struct reg_sequence nt39016_panel_regs[] = {
RV(NT39016_REG_SYSTEM, 0x00),
RV(NT39016_REG_TIMING, 0x00),
RV(NT39016_REG_OP, 0x03),
RV(NT39016_REG_DATA_IN, 0xCC),
RV(NT39016_REG_SRC_TIMING_DELAY, 0x46),
RV(NT39016_REG_GATE_TIMING_DELAY, 0x05),
RV(NT39016_REG_RESERVED, 0x00),
RV(NT39016_REG_INITIAL_FUNC, 0x00),
RV(NT39016_REG_CONTRAST, 0x08),
RV(NT39016_REG_BRIGHTNESS, 0x40),
RV(NT39016_REG_HUE_SATURATION, 0x88),
RV(NT39016_REG_RB_SUBCONTRAST, 0x88),
RV(NT39016_REG_R_SUBBRIGHTNESS, 0x20),
RV(NT39016_REG_B_SUBBRIGHTNESS, 0x20),
RV(NT39016_REG_VCOMDC, 0x67),
RV(NT39016_REG_VCOMAC, 0xA4),
RV(NT39016_REG_VGAM2, 0x04),
RV(NT39016_REG_VGAM34, 0x24),
RV(NT39016_REG_VGAM56, 0x24),
RV(NT39016_REG_DISPLAY_MODE, 0x00),
};
#undef RV
static const struct regmap_range nt39016_regmap_no_ranges[] = {
regmap_reg_range(0x13, 0x1D),
regmap_reg_range(0x1F, 0x1F),
};
static const struct regmap_access_table nt39016_regmap_access_table = {
.no_ranges = nt39016_regmap_no_ranges,
.n_no_ranges = ARRAY_SIZE(nt39016_regmap_no_ranges),
};
static const struct regmap_config nt39016_regmap_config = {
.reg_bits = 6,
.pad_bits = 2,
.val_bits = 8,
.max_register = NT39016_REG_DISPLAY_MODE,
.wr_table = &nt39016_regmap_access_table,
.write_flag_mask = 0x02,
.cache_type = REGCACHE_FLAT,
};
static int nt39016_prepare(struct drm_panel *drm_panel)
{
struct nt39016 *panel = to_nt39016(drm_panel);
int err;
err = regulator_enable(panel->supply);
if (err) {
dev_err(drm_panel->dev, "Failed to enable power supply: %d\n", err);
return err;
}
/*
* Reset the NT39016.
* The documentation says the reset pulse should be at least 40 us to
* pass the glitch filter, but when testing I see some resets fail and
* some succeed when using a 70 us delay, so we use 100 us instead.
*/
gpiod_set_value_cansleep(panel->reset_gpio, 1);
usleep_range(100, 1000);
gpiod_set_value_cansleep(panel->reset_gpio, 0);
udelay(2);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/device.h`, `linux/gpio/consumer.h`, `linux/media-bus-format.h`, `linux/module.h`, `linux/of.h`, `linux/regmap.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct nt39016_panel_info`, `struct nt39016`, `enum nt39016_regs`, `function nt39016_prepare`, `function nt39016_unprepare`, `function nt39016_enable`, `function nt39016_disable`, `function nt39016_get_modes`, `function nt39016_probe`, `function nt39016_remove`.
- Atlas domain: Driver Families / drivers/gpu.
- 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.