drivers/gpu/drm/panel/panel-widechips-ws2401.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panel/panel-widechips-ws2401.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/panel/panel-widechips-ws2401.c- Extension
.c- Size
- 13123 bytes
- Lines
- 447
- 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
drm/drm_mipi_dbi.hdrm/drm_modes.hdrm/drm_panel.hlinux/backlight.hlinux/delay.hlinux/gpio/consumer.hlinux/init.hlinux/kernel.hlinux/media-bus-format.hlinux/module.hlinux/regulator/consumer.hlinux/spi/spi.hvideo/mipi_display.h
Detected Declarations
struct ws2401function ws2401_read_mtp_idfunction ws2401_power_onfunction ws2401_power_offfunction ws2401_unpreparefunction ws2401_disablefunction ws2401_preparefunction ws2401_enablefunction ws2401_get_modesfunction ws2401_set_brightnessfunction ws2401_probefunction ws2401_remove
Annotated Snippet
struct ws2401 {
/** @dev: the container device */
struct device *dev;
/** @dbi: the DBI bus abstraction handle */
struct mipi_dbi dbi;
/** @panel: the DRM panel instance for this device */
struct drm_panel panel;
/** @width: the width of this panel in mm */
u32 width;
/** @height: the height of this panel in mm */
u32 height;
/** @reset: reset GPIO line */
struct gpio_desc *reset;
/** @regulators: VCCIO and VIO supply regulators */
struct regulator_bulk_data regulators[2];
/** @internal_bl: If using internal backlight */
bool internal_bl;
};
static const struct drm_display_mode lms380kf01_480_800_mode = {
/*
* The vendor driver states that the "SMD panel" has a clock
* frequency of 49920000 Hz / 2 = 24960000 Hz.
*/
.clock = 24960,
.hdisplay = 480,
.hsync_start = 480 + 8,
.hsync_end = 480 + 8 + 10,
.htotal = 480 + 8 + 10 + 8,
.vdisplay = 800,
.vsync_start = 800 + 8,
.vsync_end = 800 + 8 + 2,
.vtotal = 800 + 8 + 2 + 18,
.width_mm = 50,
.height_mm = 84,
.flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
};
static inline struct ws2401 *to_ws2401(struct drm_panel *panel)
{
return container_of(panel, struct ws2401, panel);
}
static void ws2401_read_mtp_id(struct ws2401 *ws)
{
struct mipi_dbi *dbi = &ws->dbi;
u8 id1, id2, id3;
int ret;
ret = mipi_dbi_command_read(dbi, WS2401_READ_ID1, &id1);
if (ret) {
dev_err(ws->dev, "unable to read MTP ID 1\n");
return;
}
ret = mipi_dbi_command_read(dbi, WS2401_READ_ID2, &id2);
if (ret) {
dev_err(ws->dev, "unable to read MTP ID 2\n");
return;
}
ret = mipi_dbi_command_read(dbi, WS2401_READ_ID3, &id3);
if (ret) {
dev_err(ws->dev, "unable to read MTP ID 3\n");
return;
}
dev_info(ws->dev, "MTP ID: %02x %02x %02x\n", id1, id2, id3);
}
static int ws2401_power_on(struct ws2401 *ws)
{
struct mipi_dbi *dbi = &ws->dbi;
int ret;
/* Power up */
ret = regulator_bulk_enable(ARRAY_SIZE(ws->regulators),
ws->regulators);
if (ret) {
dev_err(ws->dev, "failed to enable regulators: %d\n", ret);
return ret;
}
msleep(10);
/* Assert reset >=1 ms */
gpiod_set_value_cansleep(ws->reset, 1);
usleep_range(1000, 5000);
/* De-assert reset */
gpiod_set_value_cansleep(ws->reset, 0);
/* Wait >= 10 ms */
msleep(10);
dev_dbg(ws->dev, "de-asserted RESET\n");
Annotation
- Immediate include surface: `drm/drm_mipi_dbi.h`, `drm/drm_modes.h`, `drm/drm_panel.h`, `linux/backlight.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/init.h`, `linux/kernel.h`.
- Detected declarations: `struct ws2401`, `function ws2401_read_mtp_id`, `function ws2401_power_on`, `function ws2401_power_off`, `function ws2401_unprepare`, `function ws2401_disable`, `function ws2401_prepare`, `function ws2401_enable`, `function ws2401_get_modes`, `function ws2401_set_brightness`.
- 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.