drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_parse.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_parse.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_parse.c- Extension
.c- Size
- 2825 bytes
- Lines
- 148
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/videodev2.hmedia/jpeg.hmtk_jpeg_dec_parse.h
Detected Declarations
struct mtk_jpeg_streamfunction read_bytefunction read_word_befunction read_skipfunction mtk_jpeg_do_parsefunction mtk_jpeg_parse
Annotated Snippet
struct mtk_jpeg_stream {
u8 *addr;
u32 size;
u32 curr;
};
static int read_byte(struct mtk_jpeg_stream *stream)
{
if (stream->curr >= stream->size)
return -1;
return stream->addr[stream->curr++];
}
static int read_word_be(struct mtk_jpeg_stream *stream, u32 *word)
{
u32 temp;
int byte;
byte = read_byte(stream);
if (byte == -1)
return -1;
temp = byte << 8;
byte = read_byte(stream);
if (byte == -1)
return -1;
*word = (u32)byte | temp;
return 0;
}
static void read_skip(struct mtk_jpeg_stream *stream, long len)
{
if (len <= 0)
return;
while (len--)
read_byte(stream);
}
static bool mtk_jpeg_do_parse(struct mtk_jpeg_dec_param *param, u8 *src_addr_va,
u32 src_size)
{
bool notfound = true;
struct mtk_jpeg_stream stream;
stream.addr = src_addr_va;
stream.size = src_size;
stream.curr = 0;
while (notfound) {
int i, length, byte;
u32 word;
byte = read_byte(&stream);
if (byte == -1)
return false;
if (byte != 0xff)
continue;
do
byte = read_byte(&stream);
while (byte == 0xff);
if (byte == -1)
return false;
if (byte == 0)
continue;
length = 0;
switch (byte) {
case JPEG_MARKER_SOF0:
/* length */
if (read_word_be(&stream, &word))
break;
/* precision */
if (read_byte(&stream) == -1)
break;
if (read_word_be(&stream, &word))
break;
param->pic_h = word;
if (read_word_be(&stream, &word))
break;
param->pic_w = word;
param->comp_num = read_byte(&stream);
if (param->comp_num != 1 && param->comp_num != 3)
break;
for (i = 0; i < param->comp_num; i++) {
param->comp_id[i] = read_byte(&stream);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/videodev2.h`, `media/jpeg.h`, `mtk_jpeg_dec_parse.h`.
- Detected declarations: `struct mtk_jpeg_stream`, `function read_byte`, `function read_word_be`, `function read_skip`, `function mtk_jpeg_do_parse`, `function mtk_jpeg_parse`.
- Atlas domain: Driver Families / drivers/media.
- 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.