drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c- Extension
.c- Size
- 19537 bytes
- Lines
- 686
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/bitfield.hlinux/bits.hlinux/clk.hlinux/interrupt.hlinux/irq.hlinux/io.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/slab.hmedia/media-device.hmedia/videobuf2-core.hmedia/videobuf2-v4l2.hmedia/v4l2-mem2mem.hmedia/v4l2-dev.hmedia/v4l2-device.hmedia/v4l2-fh.hmedia/v4l2-event.hmtk_jpeg_core.hmtk_jpeg_dec_hw.h
Detected Declarations
enum mtk_jpeg_colorfunction mtk_jpeg_verify_alignfunction mtk_jpeg_decide_formatfunction mtk_jpeg_calc_mcufunction mtk_jpeg_calc_dma_groupfunction mtk_jpeg_calc_dst_sizefunction mtk_jpeg_dec_fill_paramfunction mtk_jpeg_dec_get_int_statusfunction mtk_jpeg_dec_enum_resultfunction mtk_jpeg_dec_startfunction mtk_jpeg_dec_soft_resetfunction mtk_jpeg_dec_hard_resetfunction mtk_jpeg_dec_resetfunction mtk_jpeg_dec_set_brz_factorfunction mtk_jpeg_dec_set_dst_bank0function mtk_jpeg_dec_set_dst_bank1function mtk_jpeg_dec_set_mem_stridefunction mtk_jpeg_dec_set_img_stridefunction mtk_jpeg_dec_set_pause_mcu_idxfunction mtk_jpeg_dec_set_dec_modefunction mtk_jpeg_dec_set_bs_write_ptrfunction mtk_jpeg_dec_set_bs_infofunction mtk_jpeg_dec_set_comp_idfunction mtk_jpeg_dec_set_total_mcufunction mtk_jpeg_dec_set_comp0_dufunction mtk_jpeg_dec_set_du_membershipfunction mtk_jpeg_dec_set_q_tablefunction mtk_jpeg_dec_set_dma_groupfunction mtk_jpeg_dec_set_sampling_factorfunction mtk_jpeg_dec_set_configfunction mtk_jpegdec_put_buffunction list_for_each_prev_safefunction mtk_jpegdec_timeout_workfunction mtk_jpegdec_hw_irq_handlerfunction mtk_jpegdec_hw_init_irqfunction mtk_jpegdec_hw_probeexport mtk_jpeg_dec_fill_paramexport mtk_jpeg_dec_get_int_statusexport mtk_jpeg_dec_enum_resultexport mtk_jpeg_dec_startexport mtk_jpeg_dec_resetexport mtk_jpeg_dec_set_config
Annotated Snippet
if (i < param->blk_num && comp < param->comp_num) {
u32 tmp;
tmp = (0x04 + (comp & 0x3));
param->membership |= tmp << (i * 3);
if (++blk == param->blk_comp[comp]) {
comp++;
blk = 0;
}
} else {
param->membership |= 7 << (i * 3);
}
}
}
static void mtk_jpeg_calc_dma_group(struct mtk_jpeg_dec_param *param)
{
u32 factor_mcu = 3;
if (param->src_color == MTK_JPEG_COLOR_444 &&
param->dst_fourcc == V4L2_PIX_FMT_YUV422M)
factor_mcu = 4;
else if (param->src_color == MTK_JPEG_COLOR_422V &&
param->dst_fourcc == V4L2_PIX_FMT_YUV420M)
factor_mcu = 4;
else if (param->src_color == MTK_JPEG_COLOR_422X2 &&
param->dst_fourcc == V4L2_PIX_FMT_YUV422M)
factor_mcu = 2;
else if (param->src_color == MTK_JPEG_COLOR_400 ||
(param->src_color & 0x0FFFF) == 0)
factor_mcu = 4;
param->dma_mcu = 1 << factor_mcu;
param->dma_group = param->mcu_w / param->dma_mcu;
param->dma_last_mcu = param->mcu_w % param->dma_mcu;
if (param->dma_last_mcu)
param->dma_group++;
else
param->dma_last_mcu = param->dma_mcu;
}
static int mtk_jpeg_calc_dst_size(struct mtk_jpeg_dec_param *param)
{
u32 i, padding_w;
u32 ds_row_h[3];
u32 brz_w[3];
brz_w[0] = 0;
brz_w[1] = param->uv_brz_w;
brz_w[2] = brz_w[1];
for (i = 0; i < param->comp_num; i++) {
if (brz_w[i] > 3)
return -1;
padding_w = param->mcu_w * MTK_JPEG_DCTSIZE *
param->sampling_w[i];
/* output format is 420/422 */
param->comp_w[i] = padding_w >> brz_w[i];
param->comp_w[i] = round_up(param->comp_w[i],
MTK_JPEG_DCTSIZE);
param->img_stride[i] = i ? round_up(param->comp_w[i], 16)
: round_up(param->comp_w[i], 32);
ds_row_h[i] = (MTK_JPEG_DCTSIZE * param->sampling_h[i]);
}
param->dec_w = param->img_stride[0];
param->dec_h = ds_row_h[0] * param->mcu_h;
for (i = 0; i < MTK_JPEG_COMP_MAX; i++) {
/* They must be equal in frame mode. */
param->mem_stride[i] = param->img_stride[i];
param->comp_size[i] = param->mem_stride[i] * ds_row_h[i] *
param->mcu_h;
}
param->y_size = param->comp_size[0];
param->uv_size = param->comp_size[1];
param->dec_size = param->y_size + (param->uv_size << 1);
return 0;
}
int mtk_jpeg_dec_fill_param(struct mtk_jpeg_dec_param *param)
{
if (mtk_jpeg_decide_format(param))
return -1;
mtk_jpeg_calc_mcu(param);
mtk_jpeg_calc_dma_group(param);
if (mtk_jpeg_calc_dst_size(param))
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/clk.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/io.h`, `linux/kernel.h`, `linux/module.h`.
- Detected declarations: `enum mtk_jpeg_color`, `function mtk_jpeg_verify_align`, `function mtk_jpeg_decide_format`, `function mtk_jpeg_calc_mcu`, `function mtk_jpeg_calc_dma_group`, `function mtk_jpeg_calc_dst_size`, `function mtk_jpeg_dec_fill_param`, `function mtk_jpeg_dec_get_int_status`, `function mtk_jpeg_dec_enum_result`, `function mtk_jpeg_dec_start`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.