drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c- Extension
.c- Size
- 35573 bytes
- Lines
- 1257
- 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/slab.hlinux/videodev2.hlinux/workqueue.hmedia/v4l2-ctrls.hmedia/v4l2-event.hmedia/videobuf2-v4l2.hs5p_mfc_common.hs5p_mfc_ctrl.hs5p_mfc_debug.hs5p_mfc_dec.hs5p_mfc_intr.hs5p_mfc_opr.hs5p_mfc_pm.h
Detected Declarations
function s5p_mfc_ctx_readyfunction vidioc_querycapfunction vidioc_enum_fmtfunction vidioc_enum_fmt_vid_capfunction vidioc_enum_fmt_vid_outfunction vidioc_g_fmtfunction vidioc_try_fmtfunction vidioc_s_fmtfunction reqbufs_outputfunction reqbufs_capturefunction vidioc_reqbufsfunction vidioc_querybuffunction vidioc_qbuffunction vidioc_dqbuffunction vidioc_expbuffunction vidioc_streamonfunction vidioc_streamofffunction s5p_mfc_dec_s_ctrlfunction s5p_mfc_dec_g_v_ctrlfunction vidioc_g_selectionfunction vidioc_decoder_cmdfunction vidioc_subscribe_eventfunction s5p_mfc_queue_setupfunction s5p_mfc_buf_initfunction s5p_mfc_start_streamingfunction s5p_mfc_stop_streamingfunction s5p_mfc_buf_queuefunction s5p_mfc_dec_ctrls_setupfunction s5p_mfc_dec_ctrls_deletefunction s5p_mfc_dec_init
Annotated Snippet
if (!fmt) {
mfc_err("Unsupported format for source.\n");
return -EINVAL;
}
if (fmt->codec_mode == S5P_FIMV_CODEC_NONE) {
mfc_err("Unknown codec\n");
return -EINVAL;
}
if ((dev->variant->version_bit & fmt->versions) == 0) {
mfc_err("Unsupported format by this MFC version.\n");
return -EINVAL;
}
} else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
fmt = find_format(f, MFC_FMT_RAW);
if (!fmt) {
mfc_err("Unsupported format for destination.\n");
return -EINVAL;
}
if ((dev->variant->version_bit & fmt->versions) == 0) {
mfc_err("Unsupported format by this MFC version.\n");
return -EINVAL;
}
}
return 0;
}
/* Set format */
static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
struct s5p_mfc_dev *dev = video_drvdata(file);
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
int ret = 0;
struct v4l2_pix_format_mplane *pix_mp;
const struct s5p_mfc_buf_size *buf_size = dev->variant->buf_size;
mfc_debug_enter();
ret = vidioc_try_fmt(file, priv, f);
pix_mp = &f->fmt.pix_mp;
if (ret)
return ret;
if (vb2_is_streaming(&ctx->vq_src) || vb2_is_streaming(&ctx->vq_dst)) {
v4l2_err(&dev->v4l2_dev, "%s queue busy\n", __func__);
ret = -EBUSY;
goto out;
}
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
/* dst_fmt is validated by call to vidioc_try_fmt */
ctx->dst_fmt = find_format(f, MFC_FMT_RAW);
ret = 0;
goto out;
} else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
/* src_fmt is validated by call to vidioc_try_fmt */
ctx->src_fmt = find_format(f, MFC_FMT_DEC);
ctx->codec_mode = ctx->src_fmt->codec_mode;
mfc_debug(2, "The codec number is: %d\n", ctx->codec_mode);
pix_mp->height = 0;
pix_mp->width = 0;
if (pix_mp->plane_fmt[0].sizeimage == 0)
pix_mp->plane_fmt[0].sizeimage = ctx->dec_src_buf_size =
DEF_CPB_SIZE;
else if (pix_mp->plane_fmt[0].sizeimage > buf_size->cpb)
ctx->dec_src_buf_size = buf_size->cpb;
else
ctx->dec_src_buf_size = pix_mp->plane_fmt[0].sizeimage;
pix_mp->plane_fmt[0].bytesperline = 0;
ctx->state = MFCINST_INIT;
ret = 0;
goto out;
} else {
mfc_err("Wrong type error for S_FMT : %d", f->type);
ret = -EINVAL;
goto out;
}
out:
mfc_debug_leave();
return ret;
}
static int reqbufs_output(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx,
struct v4l2_requestbuffers *reqbufs)
{
int ret = 0;
s5p_mfc_clock_on(dev);
if (reqbufs->count == 0) {
mfc_debug(2, "Freeing buffers\n");
ret = vb2_reqbufs(&ctx->vq_src, reqbufs);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`, `linux/platform_device.h`, `linux/sched.h`, `linux/slab.h`, `linux/videodev2.h`.
- Detected declarations: `function s5p_mfc_ctx_ready`, `function vidioc_querycap`, `function vidioc_enum_fmt`, `function vidioc_enum_fmt_vid_cap`, `function vidioc_enum_fmt_vid_out`, `function vidioc_g_fmt`, `function vidioc_try_fmt`, `function vidioc_s_fmt`, `function reqbufs_output`, `function reqbufs_capture`.
- 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.