drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c- Extension
.c- Size
- 76153 bytes
- Lines
- 2758
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/platform_device.hlinux/sched.hlinux/videodev2.hmedia/v4l2-event.hlinux/workqueue.hmedia/v4l2-ctrls.hmedia/videobuf2-v4l2.hs5p_mfc_common.hs5p_mfc_ctrl.hs5p_mfc_debug.hs5p_mfc_enc.hs5p_mfc_intr.hs5p_mfc_opr.h
Detected Declarations
function s5p_mfc_ctx_readyfunction cleanup_ref_queuefunction enc_pre_seq_startfunction enc_post_seq_startfunction enc_pre_frame_startfunction enc_post_frame_startfunction list_for_each_entryfunction list_for_each_entryfunction vidioc_querycapfunction vidioc_enum_fmtfunction vidioc_enum_fmt_vid_capfunction vidioc_enum_fmt_vid_outfunction vidioc_g_fmtfunction vidioc_try_fmtfunction vidioc_s_fmtfunction vidioc_reqbufsfunction vidioc_querybuffunction vidioc_qbuffunction vidioc_dqbuffunction vidioc_expbuffunction vidioc_streamonfunction vidioc_streamofffunction h264_levelfunction mpeg4_levelfunction hevc_levelfunction vui_sar_idcfunction __enc_update_hevc_qp_ctrls_rangefunction s5p_mfc_enc_s_ctrlfunction s5p_mfc_enc_g_v_ctrlfunction vidioc_s_parmfunction vidioc_g_parmfunction vidioc_encoder_cmdfunction vidioc_subscribe_eventfunction check_vb_with_fmtfunction s5p_mfc_queue_setupfunction s5p_mfc_buf_initfunction s5p_mfc_buf_preparefunction s5p_mfc_start_streamingfunction s5p_mfc_stop_streamingfunction s5p_mfc_buf_queuefunction s5p_mfc_enc_ctrls_setupfunction s5p_mfc_enc_ctrls_deletefunction s5p_mfc_enc_init
Annotated Snippet
if (!list_empty(&ctx->dst_queue)) {
dst_mb = list_entry(ctx->dst_queue.next,
struct s5p_mfc_buf, list);
list_del(&dst_mb->list);
ctx->dst_queue_cnt--;
vb2_set_plane_payload(&dst_mb->b->vb2_buf, 0,
s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size,
dev));
vb2_buffer_done(&dst_mb->b->vb2_buf,
VB2_BUF_STATE_DONE);
}
}
if (!IS_MFCV6_PLUS(dev)) {
ctx->state = MFCINST_RUNNING;
if (s5p_mfc_ctx_ready(ctx))
set_work_bit_irqsave(ctx);
s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
} else {
ctx->pb_count = s5p_mfc_hw_call(dev->mfc_ops, get_enc_dpb_count, dev);
if (FW_HAS_E_MIN_SCRATCH_BUF(dev)) {
ctx->scratch_buf_size = s5p_mfc_hw_call(dev->mfc_ops,
get_e_min_scratch_buf_size, dev);
if (!IS_MFCV12(dev))
ctx->bank1.size += ctx->scratch_buf_size;
}
ctx->state = MFCINST_HEAD_PRODUCED;
}
return 0;
}
static int enc_pre_frame_start(struct s5p_mfc_ctx *ctx)
{
struct s5p_mfc_dev *dev = ctx->dev;
struct s5p_mfc_buf *dst_mb;
struct s5p_mfc_buf *src_mb;
unsigned long src_y_addr, src_c_addr, src_c_1_addr, dst_addr;
unsigned int dst_size;
src_mb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
src_y_addr = vb2_dma_contig_plane_dma_addr(&src_mb->b->vb2_buf, 0);
src_c_addr = vb2_dma_contig_plane_dma_addr(&src_mb->b->vb2_buf, 1);
if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_YUV420M || ctx->src_fmt->fourcc ==
V4L2_PIX_FMT_YVU420M)
src_c_1_addr =
vb2_dma_contig_plane_dma_addr(&src_mb->b->vb2_buf, 2);
else
src_c_1_addr = 0;
s5p_mfc_hw_call(dev->mfc_ops, set_enc_frame_buffer, ctx,
src_y_addr, src_c_addr, src_c_1_addr);
dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0);
dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0);
s5p_mfc_hw_call(dev->mfc_ops, set_enc_stream_buffer, ctx, dst_addr,
dst_size);
return 0;
}
static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
{
struct s5p_mfc_dev *dev = ctx->dev;
struct s5p_mfc_buf *mb_entry;
unsigned long enc_y_addr = 0, enc_c_addr = 0, enc_c_1_addr = 0;
unsigned long mb_y_addr, mb_c_addr, mb_c_1_addr;
int slice_type;
unsigned int strm_size;
bool src_ready;
slice_type = s5p_mfc_hw_call(dev->mfc_ops, get_enc_slice_type, dev);
strm_size = s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size, dev);
mfc_debug(2, "Encoded slice type: %d\n", slice_type);
mfc_debug(2, "Encoded stream size: %d\n", strm_size);
mfc_debug(2, "Display order: %d\n",
mfc_read(dev, S5P_FIMV_ENC_SI_PIC_CNT));
if (slice_type >= 0) {
s5p_mfc_hw_call(dev->mfc_ops, get_enc_frame_buffer, ctx,
&enc_y_addr, &enc_c_addr, &enc_c_1_addr);
list_for_each_entry(mb_entry, &ctx->src_queue, list) {
mb_y_addr = vb2_dma_contig_plane_dma_addr(
&mb_entry->b->vb2_buf, 0);
mb_c_addr = vb2_dma_contig_plane_dma_addr(
&mb_entry->b->vb2_buf, 1);
if (ctx->src_fmt->fourcc ==
V4L2_PIX_FMT_YUV420M ||
ctx->src_fmt->fourcc ==
V4L2_PIX_FMT_YVU420M)
mb_c_1_addr = vb2_dma_contig_plane_dma_addr
Annotation
- Immediate include surface: `linux/clk.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`, `linux/platform_device.h`, `linux/sched.h`, `linux/videodev2.h`, `media/v4l2-event.h`.
- Detected declarations: `function s5p_mfc_ctx_ready`, `function cleanup_ref_queue`, `function enc_pre_seq_start`, `function enc_post_seq_start`, `function enc_pre_frame_start`, `function enc_post_frame_start`, `function list_for_each_entry`, `function list_for_each_entry`, `function vidioc_querycap`, `function vidioc_enum_fmt`.
- 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.
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.