drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c- Extension
.c- Size
- 93060 bytes
- Lines
- 3160
- 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/kernel.hlinux/module.hlinux/io.hlinux/clk.hlinux/genalloc.hlinux/of_platform.hlinux/platform_device.hlinux/slab.hlinux/irqreturn.hlinux/interrupt.hlinux/pm_runtime.hlinux/pm_domain.hlinux/string.hmedia/v4l2-jpeg.hmedia/v4l2-mem2mem.hmedia/v4l2-ioctl.hmedia/v4l2-common.hmedia/v4l2-event.hmedia/videobuf2-dma-contig.hmxc-jpeg-hw.hmxc-jpeg.h
Detected Declarations
struct mxc_jpeg_src_buffunction _bswap16function mxc_jpeg_get_plane_dma_addrfunction mxc_jpeg_get_plane_payloadfunction print_mxc_buffunction enum_fmtfunction mxc_jpeg_fourcc_to_imgfmtfunction mxc_jpeg_addrsfunction mxc_jpeg_is_extended_sequentialfunction notify_eosfunction notify_src_chgfunction mxc_get_free_slotfunction mxc_jpeg_freefunction mxc_jpeg_free_slot_datafunction mxc_jpeg_alloc_slot_datafunction mxc_jpeg_check_and_set_last_bufferfunction mxc_jpeg_job_finishfunction mxc_jpeg_get_plane_sizefunction mxc_dec_is_ongoingfunction mxc_jpeg_dec_irqfunction mxc_dec_is_ongoingfunction mxc_jpeg_fixup_soffunction mxc_jpeg_fixup_sosfunction mxc_jpeg_setup_cfg_streamfunction mxc_jpeg_config_dec_descfunction mxc_jpeg_config_enc_descfunction mxc_jpeg_enc_start_config_manuallyfunction mxc_jpeg_enc_finish_config_manuallyfunction mxc_jpeg_enc_configure_descfunction mxc_jpeg_compare_formatfunction mxc_jpeg_set_last_bufferfunction mxc_jpeg_source_changefunction mxc_jpeg_job_readyfunction mxc_jpeg_device_run_timeoutfunction mxc_jpeg_device_runfunction mxc_jpeg_decoder_cmdfunction mxc_jpeg_encoder_cmdfunction mxc_jpeg_queue_setupfunction mxc_jpeg_start_streamingfunction mxc_jpeg_stop_streamingfunction mxc_jpeg_valid_comp_idfunction mxc_jpeg_match_image_formatfunction mxc_jpeg_get_image_formatfunction mxc_jpeg_bytesperlinefunction mxc_jpeg_sizeimagefunction mxc_jpeg_parsefunction mxc_jpeg_buf_queuefunction mxc_jpeg_buf_out_validate
Annotated Snippet
struct mxc_jpeg_src_buf {
/* common v4l buffer stuff -- must be first */
struct vb2_v4l2_buffer b;
struct list_head list;
/* mxc-jpeg specific */
bool dht_needed;
bool jpeg_parse_error;
const struct mxc_jpeg_fmt *fmt;
int w;
int h;
};
static inline struct mxc_jpeg_src_buf *vb2_to_mxc_buf(struct vb2_buffer *vb)
{
return container_of(to_vb2_v4l2_buffer(vb),
struct mxc_jpeg_src_buf, b);
}
static unsigned int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "Debug level (0-3)");
static unsigned int hw_timeout = 2000;
module_param(hw_timeout, int, 0644);
MODULE_PARM_DESC(hw_timeout, "MXC JPEG hw timeout, the number of milliseconds");
static void mxc_jpeg_bytesperline(struct mxc_jpeg_q_data *q, u32 precision);
static void mxc_jpeg_sizeimage(struct mxc_jpeg_q_data *q);
static void _bswap16(u16 *a)
{
*a = ((*a & 0x00FF) << 8) | ((*a & 0xFF00) >> 8);
}
static dma_addr_t mxc_jpeg_get_plane_dma_addr(struct vb2_buffer *buf, unsigned int plane_no)
{
if (plane_no >= buf->num_planes)
return 0;
return vb2_dma_contig_plane_dma_addr(buf, plane_no) + buf->planes[plane_no].data_offset;
}
static void *mxc_jpeg_get_plane_vaddr(struct vb2_buffer *buf, unsigned int plane_no)
{
if (plane_no >= buf->num_planes)
return NULL;
return vb2_plane_vaddr(buf, plane_no) + buf->planes[plane_no].data_offset;
}
static unsigned long mxc_jpeg_get_plane_payload(struct vb2_buffer *buf, unsigned int plane_no)
{
if (plane_no >= buf->num_planes)
return 0;
return vb2_get_plane_payload(buf, plane_no) - buf->planes[plane_no].data_offset;
}
static void print_mxc_buf(struct mxc_jpeg_dev *jpeg, struct vb2_buffer *buf,
unsigned long len)
{
unsigned int plane_no;
u32 dma_addr;
void *vaddr;
unsigned long payload;
if (debug < 3)
return;
for (plane_no = 0; plane_no < buf->num_planes; plane_no++) {
payload = mxc_jpeg_get_plane_payload(buf, plane_no);
if (len == 0)
len = payload;
dma_addr = mxc_jpeg_get_plane_dma_addr(buf, plane_no);
vaddr = mxc_jpeg_get_plane_vaddr(buf, plane_no);
v4l2_dbg(3, debug, &jpeg->v4l2_dev,
"plane %d (vaddr=%p dma_addr=%x payload=%ld):",
plane_no, vaddr, dma_addr, payload);
print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
vaddr, len, false);
}
}
static inline struct mxc_jpeg_ctx *mxc_jpeg_file_to_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct mxc_jpeg_ctx, fh);
}
static int enum_fmt(const struct mxc_jpeg_fmt *mxc_formats, int n,
struct v4l2_fmtdesc *f, u32 type)
{
int i, num = 0;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/io.h`, `linux/clk.h`, `linux/genalloc.h`, `linux/of_platform.h`, `linux/platform_device.h`, `linux/slab.h`.
- Detected declarations: `struct mxc_jpeg_src_buf`, `function _bswap16`, `function mxc_jpeg_get_plane_dma_addr`, `function mxc_jpeg_get_plane_payload`, `function print_mxc_buf`, `function enum_fmt`, `function mxc_jpeg_fourcc_to_imgfmt`, `function mxc_jpeg_addrs`, `function mxc_jpeg_is_extended_sequential`, `function notify_eos`.
- 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.