drivers/media/platform/nuvoton/npcm-video.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/nuvoton/npcm-video.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/nuvoton/npcm-video.c- Extension
.c- Size
- 48447 bytes
- Lines
- 1843
- Domain
- Driver Families
- Bucket
- drivers/media
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/atomic.hlinux/bitfield.hlinux/bitmap.hlinux/clk.hlinux/delay.hlinux/device.hlinux/dma-mapping.hlinux/interrupt.hlinux/jiffies.hlinux/mfd/syscon.hlinux/module.hlinux/mutex.hlinux/of.hlinux/of_irq.hlinux/of_platform.hlinux/of_reserved_mem.hlinux/platform_device.hlinux/regmap.hlinux/reset.hlinux/sched.hlinux/string.hlinux/v4l2-controls.hlinux/videodev2.hmedia/v4l2-ctrls.hmedia/v4l2-dev.hmedia/v4l2-device.hmedia/v4l2-dv-timings.hmedia/v4l2-event.hmedia/v4l2-ioctl.hmedia/videobuf2-dma-contig.huapi/linux/npcm-video.hnpcm-regs.h
Detected Declarations
struct npcm_video_addrstruct npcm_video_bufferstruct rect_liststruct rect_list_infostruct npcm_ecestruct npcm_videostruct npcm_fmtfunction npcm_video_ece_prepend_rect_headerfunction npcm_video_ece_get_ed_sizefunction npcm_video_ece_enc_rectfunction npcm_video_ece_read_rect_offsetfunction pitchfunction npcm_video_ece_set_fb_addrfunction npcm_video_ece_set_enc_dbafunction npcm_video_ece_clear_rect_offsetfunction npcm_video_ece_ctrl_resetfunction npcm_video_ece_ip_resetfunction npcm_video_ece_stopfunction npcm_video_alloc_fbfunction npcm_video_free_fbfunction npcm_video_free_diff_tablefunction list_for_each_safefunction npcm_video_add_rectfunction npcm_video_merge_rectfunction npcm_video_find_rectfunction npcm_video_build_tablefunction for_each_set_bitfunction npcm_video_get_rect_listfunction npcm_video_is_mgafunction npcm_video_hresfunction npcm_video_vresfunction npcm_video_capresfunction npcm_video_vcd_ip_resetfunction npcm_video_vcd_state_machine_resetfunction npcm_video_gfx_resetfunction npcm_video_kvm_bwfunction npcm_video_pclkfunction npcm_video_get_bppfunction npcm_video_set_linepitchfunction npcm_video_get_linepitchfunction npcm_video_commandfunction npcm_video_init_regfunction npcm_video_start_framefunction npcm_video_bufs_donefunction npcm_video_get_diff_rectfunction npcm_video_detect_resolutionfunction npcm_video_set_resolutionfunction npcm_video_start
Annotated Snippet
struct npcm_video_addr {
size_t size;
dma_addr_t dma;
void *virt;
};
struct npcm_video_buffer {
struct vb2_v4l2_buffer vb;
struct list_head link;
};
#define to_npcm_video_buffer(x) \
container_of((x), struct npcm_video_buffer, vb)
/*
* VIDEO_STREAMING: a flag indicating if the video has started streaming
* VIDEO_CAPTURING: a flag indicating if the VCD is capturing a frame
* VIDEO_RES_CHANGING: a flag indicating if the resolution is changing
* VIDEO_STOPPED: a flag indicating if the video has stopped streaming
*/
enum {
VIDEO_STREAMING,
VIDEO_CAPTURING,
VIDEO_RES_CHANGING,
VIDEO_STOPPED,
};
struct rect_list {
struct v4l2_clip clip;
struct list_head list;
};
struct rect_list_info {
struct rect_list *list;
struct rect_list *first;
struct list_head *head;
unsigned int index;
unsigned int tile_perline;
unsigned int tile_perrow;
unsigned int offset_perline;
unsigned int tile_size;
unsigned int tile_cnt;
};
struct npcm_ece {
struct regmap *regmap;
atomic_t clients;
struct reset_control *reset;
bool enable;
};
struct npcm_video {
struct regmap *gcr_regmap;
struct regmap *gfx_regmap;
struct regmap *vcd_regmap;
struct device *dev;
struct v4l2_ctrl_handler ctrl_handler;
struct v4l2_ctrl *rect_cnt_ctrl;
struct v4l2_device v4l2_dev;
struct v4l2_pix_format pix_fmt;
struct v4l2_bt_timings active_timings;
struct v4l2_bt_timings detected_timings;
unsigned int v4l2_input_status;
struct vb2_queue queue;
struct video_device vdev;
struct mutex video_lock; /* v4l2 and videobuf2 lock */
struct list_head buffers;
struct mutex buffer_lock; /* buffer list lock */
unsigned long flags;
unsigned int sequence;
struct npcm_video_addr src;
struct reset_control *reset;
struct npcm_ece ece;
unsigned int bytesperline;
unsigned int bytesperpixel;
unsigned int rect_cnt;
struct list_head list[VIDEO_MAX_FRAME];
unsigned int rect[VIDEO_MAX_FRAME];
unsigned int ctrl_cmd;
unsigned int op_cmd;
};
#define to_npcm_video(x) container_of((x), struct npcm_video, v4l2_dev)
struct npcm_fmt {
unsigned int fourcc;
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/bitfield.h`, `linux/bitmap.h`, `linux/clk.h`, `linux/delay.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/interrupt.h`.
- Detected declarations: `struct npcm_video_addr`, `struct npcm_video_buffer`, `struct rect_list`, `struct rect_list_info`, `struct npcm_ece`, `struct npcm_video`, `struct npcm_fmt`, `function npcm_video_ece_prepend_rect_header`, `function npcm_video_ece_get_ed_size`, `function npcm_video_ece_enc_rect`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.