drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c- Extension
.c- Size
- 85325 bytes
- Lines
- 3172
- 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/clk.hlinux/err.hlinux/gfp.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/slab.hlinux/spinlock.hlinux/string.hmedia/v4l2-event.hmedia/v4l2-mem2mem.hmedia/v4l2-ioctl.hmedia/v4l2-rect.hmedia/videobuf2-v4l2.hmedia/videobuf2-dma-contig.hjpeg-core.hjpeg-hw-s5p.hjpeg-hw-exynos4.hjpeg-hw-exynos3250.hjpeg-regs.h
Detected Declarations
function s5p_jpeg_get_dwngrd_sch_id_by_fourccfunction s5p_jpeg_adjust_fourcc_to_subsamplingfunction s5p_jpeg_to_user_subsamplingfunction s5p_jpeg_set_qtblfunction s5p_jpeg_set_qtbl_lumfunction s5p_jpeg_set_qtbl_chrfunction s5p_jpeg_set_htblfunction s5p_jpeg_set_hdctblfunction s5p_jpeg_set_hdctblgfunction s5p_jpeg_set_hactblfunction s5p_jpeg_set_hactblgfunction exynos4_jpeg_set_tblfunction exynos4_jpeg_set_qtbl_lumfunction exynos4_jpeg_set_qtbl_chrfunction exynos4_jpeg_set_huff_tblfunction __exynos4_huff_tblfunction exynos4_huff_tbl_lenfunction exynos4_huff_tbl_valfunction exynos4_jpeg_parse_decode_h_tblfunction exynos4_jpeg_parse_huff_tblfunction exynos4_jpeg_parse_decode_q_tblfunction exynos4_jpeg_parse_q_tblfunction s5p_jpeg_openfunction s5p_jpeg_releasefunction get_bytefunction get_word_befunction skipfunction s5p_jpeg_subsampling_decodefunction s5p_jpeg_parse_hdrfunction s5p_jpeg_querycapfunction enum_fmtfunction s5p_jpeg_enum_fmt_vid_capfunction s5p_jpeg_enum_fmt_vid_outfunction s5p_jpeg_g_fmtfunction jpeg_bound_align_imagefunction vidioc_try_fmtfunction s5p_jpeg_try_fmt_vid_capfunction s5p_jpeg_try_fmt_vid_outfunction exynos4_jpeg_get_output_buffer_sizefunction s5p_jpeg_s_fmtfunction s5p_jpeg_s_fmt_vid_capfunction s5p_jpeg_s_fmt_vid_outfunction s5p_jpeg_subscribe_eventfunction exynos3250_jpeg_try_downscalefunction exynos3250_jpeg_try_cropfunction s5p_jpeg_g_selectionfunction s5p_jpeg_s_selectionfunction s5p_jpeg_g_volatile_ctrl
Annotated Snippet
while (jpeg_buffer.curr < jpeg_buffer.size) {
char id, class;
c = get_byte(&jpeg_buffer);
if (c == -1)
return;
id = c & 0xf;
class = (c >> 4) & 0xf;
n = 0;
for (i = 0; i < 16; ++i) {
c = get_byte(&jpeg_buffer);
if (c == -1)
return;
word |= c << ((i % 4) * 8);
if ((i + 1) % 4 == 0) {
writel(word, jpeg->regs +
exynos4_huff_tbl_len(class, id) +
(i / 4) * 4);
word = 0;
}
n += c;
}
word = 0;
for (i = 0; i < n; ++i) {
c = get_byte(&jpeg_buffer);
if (c == -1)
return;
word |= c << ((i % 4) * 8);
if ((i + 1) % 4 == 0) {
writel(word, jpeg->regs +
exynos4_huff_tbl_val(class, id) +
(i / 4) * 4);
word = 0;
}
}
if (i % 4) {
writel(word, jpeg->regs +
exynos4_huff_tbl_val(class, id) + (i / 4) * 4);
}
word = 0;
}
}
}
static void exynos4_jpeg_parse_decode_q_tbl(struct s5p_jpeg_ctx *ctx)
{
struct s5p_jpeg *jpeg = ctx->jpeg;
struct vb2_v4l2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
struct s5p_jpeg_buffer jpeg_buffer;
int c, x, components;
jpeg_buffer.size = ctx->out_q.sof_len;
jpeg_buffer.data =
(unsigned long)vb2_plane_vaddr(&vb->vb2_buf, 0) + ctx->out_q.sof;
jpeg_buffer.curr = 0;
skip(&jpeg_buffer, 5); /* P, Y, X */
components = get_byte(&jpeg_buffer);
if (components == -1)
return;
exynos4_jpeg_set_dec_components(jpeg->regs, components);
while (components--) {
c = get_byte(&jpeg_buffer);
if (c == -1)
return;
skip(&jpeg_buffer, 1);
x = get_byte(&jpeg_buffer);
if (x == -1)
return;
exynos4_jpeg_select_dec_q_tbl(jpeg->regs, c, x);
}
}
static void exynos4_jpeg_parse_q_tbl(struct s5p_jpeg_ctx *ctx)
{
struct s5p_jpeg *jpeg = ctx->jpeg;
struct vb2_v4l2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
struct s5p_jpeg_buffer jpeg_buffer;
unsigned int word;
int c, i, j;
for (j = 0; j < ctx->out_q.dqt.n; ++j) {
jpeg_buffer.size = ctx->out_q.dqt.len[j];
jpeg_buffer.data = (unsigned long)vb2_plane_vaddr(&vb->vb2_buf, 0) +
ctx->out_q.dqt.marker[j];
jpeg_buffer.curr = 0;
word = 0;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/err.h`, `linux/gfp.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `function s5p_jpeg_get_dwngrd_sch_id_by_fourcc`, `function s5p_jpeg_adjust_fourcc_to_subsampling`, `function s5p_jpeg_to_user_subsampling`, `function s5p_jpeg_set_qtbl`, `function s5p_jpeg_set_qtbl_lum`, `function s5p_jpeg_set_qtbl_chr`, `function s5p_jpeg_set_htbl`, `function s5p_jpeg_set_hdctbl`, `function s5p_jpeg_set_hdctblg`, `function s5p_jpeg_set_hactbl`.
- 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.