STRUCT MTK_VCODEC_ENC_CTX(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐ŸŒธ struct mtk_vcodec_enc_ctx(9) ๐ŸŒธ

okay so bestie, welcome to the Kernel API Manual ๐Ÿ’– this page is all about struct mtk_vcodec_enc_ctx โ€” literally the private data for one context (a whole instance, like a whole little world ๐ŸŒ). yes it's a C struct, yes it's iconic, no you can't skip it.


โœจ NAME โœจ

struct mtk_vcodec_enc_ctx โ€” the context (instance) private data. that's it, that's the vibe ๐Ÿ’… it's the per-instance bag of holding for MediaTek's encoder.


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

here's the whole thing, character for character, do not touch, she's perfect:

struct mtk_vcodec_enc_ctx {
    enum mtk_instance_type type;
    struct mtk_vcodec_enc_dev *dev;
    struct list_head list;
    struct v4l2_fh fh;
    struct v4l2_m2m_ctx *m2m_ctx;
    struct mtk_q_data q_data[2];
    int id;
    enum mtk_instance_state state;
    enum mtk_encode_param param_change;
    struct mtk_enc_params enc_params;
    const struct venc_common_if *enc_if;
    void *drv_handle;
    int int_cond[MTK_VDEC_HW_MAX];
    int int_type[MTK_VDEC_HW_MAX];
    wait_queue_head_t queue[MTK_VDEC_HW_MAX];
    unsigned int irq_status;
    struct v4l2_ctrl_handler ctrl_hdl;
    struct work_struct encode_work;
    struct v4l2_m2m_buffer empty_flush_buf;
    bool is_flushing;
    enum v4l2_colorspace colorspace;
    enum v4l2_ycbcr_encoding ycbcr_enc;
    enum v4l2_quantization quantization;
    enum v4l2_xfer_func xfer_func;
    struct mutex q_mutex;
    void *vpu_inst;
};

๐Ÿ’œ Members ๐Ÿ’œ

๐Ÿฆ‹ the basics

  • type โ€” what kind of encoder instance this is. the personality type of the instance, if you will โœจ
  • dev โ€” pointer to the mtk_vcodec_enc_dev of the device. the parent, the home base, the main character ๐Ÿ 
  • list โ€” link to ctx_list of mtk_vcodec_enc_dev. it's how this ctx hangs out with all the other ctxs ๐Ÿซถ
  • fh โ€” a struct v4l2_fh. justโ€ฆ there. slaying quietly ๐Ÿ’…
  • m2m_ctx โ€” pointer to the v4l2_m2m_ctx of the context. mem2mem brain.
  • q_data โ€” store information of input and output queue of the context. two of them ([2]), because input AND output, duh ๐Ÿ‘‘
  • id โ€” index of the context that this structure describes. her little name tag ๐Ÿท๏ธ
  • state โ€” state of the context. mood ring, basically ๐Ÿ”ฎ

๐ŸŒˆ the encoding stuff

  • param_change โ€” indicate encode parameter type. flags which kind of encode params changed, no cap.
  • enc_params โ€” encoding parameters. the actual seasoning in the soup ๐Ÿ“
  • enc_if โ€” hooked encoder driver interface. the plug, the connector, the const struct venc_common_if * girly.
  • drv_handle โ€” driver handle for specific decode/encode instance. yes the manpage literally says "decode/encode" โ€” we do not edit โœ๏ธ

๐Ÿ”ฅ interrupts & waiting

  • int_cond โ€” variable used by the waitqueue.
  • int_type โ€” type of the last interrupt. she remembers the last interrupts, both arrays are [MTK_VDEC_HW_MAX] sized btw โญ
  • queue โ€” waitqueue that can be used to wait for this context to finish. also [MTK_VDEC_HW_MAX], also iconic.
  • irq_status โ€” irq status. that's the whole description, she's mysterious like that ๐Ÿ™ˆ

๐ŸŽ€ v4l2 framework corner

  • ctrl_hdl โ€” handler for v4l2 framework. the control freak (affectionate) ๐Ÿ’–
  • encode_work โ€” worker for the encoding. she works, she's a struct work_struct, we respect her ๐Ÿซก
  • empty_flush_buf โ€” a fake size-0 capture buffer that indicates flush. Used for encoder. it's fake but it's doing her best ๐Ÿ˜ญ honestly a legend for that.
  • is_flushing โ€” set to true if flushing is in progress. true girlies set it, false girliesโ€ฆ also possible ๐Ÿšฝโœจ

๐Ÿ’€ colorspace lore (do NOT skip, I know you want to)

  • colorspace โ€” enum v4l2_colorspace; supplemental to pixelformat.
  • ycbcr_enc โ€” enum v4l2_ycbcr_encoding, Y'CbCr encoding.
  • quantization โ€” enum v4l2_quantization, colorspace quantization.
  • xfer_func โ€” enum v4l2_xfer_func, colorspace transfer function.

like yes it's four whole enum fields but they're besties and they come as a set ๐Ÿ’œ

๐ŸŒธ the last two

  • q_mutex โ€” vb2_queue mutex. lock her before you touch her, mutual respect ๐Ÿ”’
  • vpu_inst โ€” vpu instance pointer. final member energy, main character exit ๐Ÿ‘‘

โญ SEE ALSO โญ

go read these next, bestie, iykyk:

  • Kernel file ./drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h
  • struct mtk_vcodec_enc_pdata(9)
  • struct mtk_enc_params(9)
  • struct mtk_vcodec_enc_dev(9)

also, just so we're clear: the manpage footer literally shows the source as ./drivers/media/platform/media... โ€” truncated and everything, that's the actual original text, we are NOT fixing it ๐Ÿซถ

okay that's the page!! this was struct mtk_vcodec_enc_ctx(9), from the Kernel API Manual, the source/version line being ./drivers/media/platform/media... and the date October 2026 (futuristic icon behavior, honestly ๐Ÿ”ฅ). mwah, go encode something, bestie ๐Ÿ’‹๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from