STRUCT S5P_MFC_CTX(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ struct s5p_mfc_ctx(9) πŸŽ€

okay so bestie, welcome to the Kernel API Manual β€” this is the page about struct s5p_mfc_ctx, and it's literally the whole personality of a single instance's context. like, everything the driver needs to remember about one running thing lives in here. it's giving "main character struct" and honestly? deserved. πŸ’…


✨ NAME ✨

struct s5p_mfc_ctx β€” this struct contains the instance context πŸ’–


🌸 SYNOPSIS 🌸

struct s5p_mfc_ctx {
    struct s5p_mfc_dev *dev;
    struct v4l2_fh fh;
    int num;
    int int_cond;
    int int_type;
    unsigned int int_err;
    wait_queue_head_t queue;
    const struct s5p_mfc_fmt *src_fmt;
    const struct s5p_mfc_fmt *dst_fmt;
    struct vb2_queue vq_src;
    struct vb2_queue vq_dst;
    struct list_head src_queue;
    struct list_head dst_queue;
    unsigned int src_queue_cnt;
    unsigned int dst_queue_cnt;
    enum s5p_mfc_inst_type type;
    enum s5p_mfc_inst_state state;
    int inst_no;
    int img_width;
    int img_height;
    int buf_width;
    int buf_height;
    int luma_size;
    int chroma_size;
    int chroma_size_1;
    int mv_size;
    unsigned long consumed_stream;
    unsigned int dpb_flush_flag;
    unsigned int head_processed;
    struct s5p_mfc_priv_buf bank1;
    struct s5p_mfc_priv_buf bank2;
    enum s5p_mfc_queue_state capture_state;
    enum s5p_mfc_queue_state output_state;
    struct s5p_mfc_buf src_bufs[MFC_MAX_BUFFERS];
    int src_bufs_cnt;
    struct s5p_mfc_buf dst_bufs[MFC_MAX_BUFFERS];
    int dst_bufs_cnt;
    unsigned int sequence;
    unsigned long dec_dst_flag;
    size_t dec_src_buf_size;
    int codec_mode;
    int slice_interface;
    int loop_filter_mpeg4;
    int display_delay;
    int display_delay_enable;
    int after_packed_pb;
    int sei_fp_parse;
    int pb_count;
    int total_dpb_count;
    int mv_count;
    struct s5p_mfc_priv_buf ctx;
    struct s5p_mfc_priv_buf dsc;
    struct s5p_mfc_priv_buf shm;
    struct s5p_mfc_enc_params enc_params;
    size_t enc_dst_buf_size;
    size_t luma_dpb_size;
    size_t chroma_dpb_size;
    size_t me_buffer_size;
    size_t tmv_buffer_size;
    enum v4l2_mpeg_mfc51_video_force_frame_type force_frame_type;
    struct list_head ref_queue;
    unsigned int ref_queue_cnt;
    enum v4l2_mpeg_video_multi_slice_mode slice_mode;
    union {
      unsigned int mb;
      unsigned int bits;
    } slice_size;
    const struct s5p_mfc_codec_ops *c_ops;
    struct v4l2_ctrl *ctrls[MFC_MAX_CTRLS];
    struct v4l2_ctrl_handler ctrl_handler;
    size_t scratch_buf_size;
    int is_10bit;
    int is_422;
    int stride[VB2_MAX_PLANE_COUNT];
 };

no cap, that's a lot of fields. don't panic. we're gonna go through every single one, and by the end you'll be obsessed. 🫢


πŸ¦‹ Members πŸ¦‹

🧚 the identity crisis section

  • dev β€” pointer to the s5p_mfc_dev of the device. like, which device do you belong to, babe
  • fh β€” a struct v4l2_fh. that's it, that's the whole vibe
  • num β€” number of the context that this structure describes
  • type β€” type of the instance β€” decoder or encoder πŸ‘‘
  • state β€” state of the context, aka what chapter of its life it's in rn
  • inst_no β€” number of the hw instance associated with the context

πŸ’« interrupt & waitqueue energy

  • int_cond β€” variable used by the waitqueue
  • int_type β€” type of the last interrupt
  • int_err β€” error number received from MFC hw in the interrupt
  • queue β€” waitqueue that can be used to wait for this context to finish. it's literally the "bestie r u done yet" queue 😭

🌈 formats & queues

  • src_fmt β€” source pixelformat information
  • dst_fmt β€” destination pixelformat information
  • vq_src β€” vb2 queue for source buffers
  • vq_dst β€” vb2 queue for destination buffers
  • src_queue β€” driver internal queue for source buffers
  • dst_queue β€” driver internal queue for destination buffers
  • src_queue_cnt β€” number of buffers queued on the source internal queue
  • dst_queue_cnt β€” number of buffers queued on the dest internal queue
  • capture_state β€” state of the capture buffers queue
  • output_state β€” state of the output buffers queue

πŸ“ sizes & dimensions (the measuring tape moment)

  • img_width β€” width of the image that is decoded or encoded
  • img_height β€” height of the image that is decoded or encoded
  • buf_width β€” width of the buffer for processed image
  • buf_height β€” height of the buffer for processed image
  • luma_size β€” size of a luma plane
  • chroma_size β€” size of a chroma plane
  • chroma_size_1 β€” size of a chroma third plane ✨
  • mv_size β€” size of a motion vectors buffer

πŸ’œ stream bookkeeping

  • consumed_stream β€” number of bytes that have been used so far from the decoding buffer
  • dpb_flush_flag β€” flag used to indicate that a DPB buffers are being flushed
  • head_processed β€” flag mentioning whether the header data is processed completely or not
  • sequence β€” counter for the sequence number for v4l2
  • dec_dst_flag β€” flags for buffers queued in the hardware
  • dec_src_buf_size β€” size of the buffer for source buffers in decoding

πŸŽ€ memory banks & buffer pools

  • bank1 β€” handle to memory allocated for temporary buffers from memory bank 1
  • bank2 β€” handle to memory allocated for temporary buffers from memory bank 2
  • src_bufs β€” information on allocated source buffers
  • src_bufs_cnt β€” number of allocated source buffers
  • dst_bufs β€” information on allocated destination buffers
  • dst_bufs_cnt β€” number of allocated destination buffers

πŸ”₯ codec settings (decoder side)

  • codec_mode β€” number of codec mode used by MFC hw
  • slice_interface β€” slice interface flag
  • loop_filter_mpeg4 β€” loop filter for MPEG4 flag
  • display_delay β€” value of the display delay for H264
  • display_delay_enable β€” display delay for H264 enable flag
  • after_packed_pb β€” flag used to track buffer when stream is in Packed PB format
  • sei_fp_parse β€” enable/disable parsing of frame packing SEI information
  • pb_count β€” count of the DPB buffers required by MFC hw
  • total_dpb_count β€” count of DPB buffers with additional buffers requested by the application
  • mv_count β€” number of MV buffers allocated for decoding

🌸 buffer handles

  • ctx β€” context buffer information
  • dsc β€” descriptor buffer information
  • shm β€” shared memory buffer information

πŸ‘‘ encoder stuff

  • enc_params β€” encoding parameters for MFC
  • enc_dst_buf_size β€” size of the buffers for encoder output
  • luma_dpb_size β€” dpb buffer size for luma
  • chroma_dpb_size β€” dpb buffer size for chroma
  • me_buffer_size β€” size of the motion estimation buffer
  • tmv_buffer_size β€” size of temporal predictor motion vector buffer
  • force_frame_type β€” encoder's frame type forcing control
  • ref_queue β€” list of the reference buffers for encoding
  • ref_queue_cnt β€” number of the buffers in the reference list
  • slice_mode β€” mode of dividing frames into slices
  • slice_size β€” slice size

πŸ’… ops & controls

  • c_ops β€” ops for encoding
  • ctrls β€” array of controls, used when adding controls to the v4l2 control framework
  • ctrl_handler β€” handler for v4l2 framework

⭐ the little extras at the bottom

  • scratch_buf_size β€” scratch buffer size
  • is_10bit β€” state to check 10bit support
  • is_422 β€” state to check YUV422 10bit format
  • stride β€” size of stride for all planes

🫢 SEE ALSO 🫢

  • Kernel file ./drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
  • struct s5p_mfc_priv_buf(9)
  • struct s5p_mfc_dev(9)
ngl bestie, if you're digging this deep you're already iconic β€” go read those two structs next, they're the supporting cast and they ate too πŸ”₯

and that's the whole page!! πŸ’– this lil writeup lives in ./drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h and it's dated October 2026 β€” so yeah, staying current, slay. struct s5p_mfc_ctx(9) out. πŸ¦‹βœ¨

πŸ“¦ where this page comes from