drivers/video/fbdev/cobalt_lcdfb.c
Source file repositories/reference/linux-study-clean/drivers/video/fbdev/cobalt_lcdfb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/fbdev/cobalt_lcdfb.c- Extension
.c- Size
- 7034 bytes
- Lines
- 351
- Domain
- Driver Families
- Bucket
- drivers/video
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/fb.hlinux/init.hlinux/io.hlinux/ioport.hlinux/uaccess.hlinux/platform_device.hlinux/module.hlinux/sched/signal.h
Detected Declarations
function Copyrightfunction lcd_read_controlfunction lcd_write_datafunction lcd_read_datafunction lcd_busy_waitfunction lcd_clearfunction cobalt_lcdfb_readfunction cobalt_lcdfb_writefunction cobalt_lcdfb_blankfunction cobalt_lcdfb_cursorfunction cobalt_lcdfb_probefunction cobalt_lcdfb_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Cobalt/SEAD3 LCD frame buffer driver.
*
* Copyright (C) 2008 Yoichi Yuasa <yuasa@linux-mips.org>
* Copyright (C) 2012 MIPS Technologies, Inc.
*/
#include <linux/delay.h>
#include <linux/fb.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/ioport.h>
#include <linux/uaccess.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/sched/signal.h>
/*
* Cursor position address
* \X 0 1 2 ... 14 15
* Y+----+----+----+---+----+----+
* 0|0x00|0x01|0x02|...|0x0e|0x0f|
* +----+----+----+---+----+----+
* 1|0x40|0x41|0x42|...|0x4e|0x4f|
* +----+----+----+---+----+----+
*/
#define LCD_DATA_REG_OFFSET 0x10
#define LCD_XRES_MAX 16
#define LCD_YRES_MAX 2
#define LCD_CHARS_MAX 32
#define LCD_CLEAR 0x01
#define LCD_CURSOR_MOVE_HOME 0x02
#define LCD_RESET 0x06
#define LCD_OFF 0x08
#define LCD_CURSOR_OFF 0x0c
#define LCD_CURSOR_BLINK_OFF 0x0e
#define LCD_CURSOR_ON 0x0f
#define LCD_ON LCD_CURSOR_ON
#define LCD_CURSOR_MOVE_LEFT 0x10
#define LCD_CURSOR_MOVE_RIGHT 0x14
#define LCD_DISPLAY_LEFT 0x18
#define LCD_DISPLAY_RIGHT 0x1c
#define LCD_PRERESET 0x3f /* execute 4 times continuously */
#define LCD_BUSY 0x80
#define LCD_GRAPHIC_MODE 0x40
#define LCD_TEXT_MODE 0x80
#define LCD_CUR_POS_MASK 0x7f
#define LCD_CUR_POS(x) ((x) & LCD_CUR_POS_MASK)
#define LCD_TEXT_POS(x) ((x) | LCD_TEXT_MODE)
static inline void lcd_write_control(struct fb_info *info, u8 control)
{
writel((u32)control << 24, info->screen_base);
}
static inline u8 lcd_read_control(struct fb_info *info)
{
return readl(info->screen_base) >> 24;
}
static inline void lcd_write_data(struct fb_info *info, u8 data)
{
writel((u32)data << 24, info->screen_base + LCD_DATA_REG_OFFSET);
}
static inline u8 lcd_read_data(struct fb_info *info)
{
return readl(info->screen_base + LCD_DATA_REG_OFFSET) >> 24;
}
static int lcd_busy_wait(struct fb_info *info)
{
u8 val = 0;
int timeout = 10, retval = 0;
do {
val = lcd_read_control(info);
val &= LCD_BUSY;
if (val != LCD_BUSY)
break;
if (msleep_interruptible(1))
return -EINTR;
timeout--;
} while (timeout);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/fb.h`, `linux/init.h`, `linux/io.h`, `linux/ioport.h`, `linux/uaccess.h`, `linux/platform_device.h`, `linux/module.h`.
- Detected declarations: `function Copyright`, `function lcd_read_control`, `function lcd_write_data`, `function lcd_read_data`, `function lcd_busy_wait`, `function lcd_clear`, `function cobalt_lcdfb_read`, `function cobalt_lcdfb_write`, `function cobalt_lcdfb_blank`, `function cobalt_lcdfb_cursor`.
- Atlas domain: Driver Families / drivers/video.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.