drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
Extension
.c
Size
59058 bytes
Lines
2029
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (src_buf == m2m_ctx->last_src_buf) {
			int ret;

			m2m_ctx->last_src_buf = NULL;
			ret = wave5_vpu_dec_set_eos_on_firmware(inst);
			if (ret)
				dev_warn(inst->dev->dev,
					 "Setting EOS for the bitstream, fail: %d\n", ret);
			break;
		}
	}

	inst->remaining_consumed_bytes = consumed_bytes;
}

static int start_decode(struct vpu_instance *inst, u32 *fail_res)
{
	struct v4l2_m2m_ctx *m2m_ctx = inst->v4l2_fh.m2m_ctx;
	int ret = 0;

	ret = wave5_vpu_dec_start_one_frame(inst, fail_res);
	if (ret) {
		struct vb2_v4l2_buffer *src_buf;

		src_buf = v4l2_m2m_src_buf_remove(m2m_ctx);
		if (src_buf)
			v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR);
		set_instance_state(inst, VPU_INST_STATE_STOP);

		dev_dbg(inst->dev->dev, "%s: pic run failed / finish job", __func__);
		v4l2_m2m_job_finish(inst->v4l2_m2m_dev, m2m_ctx);
	}

	return ret;
}

static void flag_last_buffer_done(struct vpu_instance *inst)
{
	struct v4l2_m2m_ctx *m2m_ctx = inst->v4l2_fh.m2m_ctx;
	struct vb2_v4l2_buffer *vb;
	int i;

	lockdep_assert_held(&inst->state_spinlock);

	vb = v4l2_m2m_dst_buf_remove(m2m_ctx);
	if (!vb) {
		m2m_ctx->is_draining = true;
		m2m_ctx->next_buf_last = true;
		return;
	}

	for (i = 0; i < vb->vb2_buf.num_planes; i++)
		vb2_set_plane_payload(&vb->vb2_buf, i, 0);
	vb->field = V4L2_FIELD_NONE;

	v4l2_m2m_last_buffer_done(m2m_ctx, vb);
}

static void send_eos_event(struct vpu_instance *inst)
{
	static const struct v4l2_event vpu_event_eos = {
		.type = V4L2_EVENT_EOS
	};

	lockdep_assert_held(&inst->state_spinlock);

	v4l2_event_queue_fh(&inst->v4l2_fh, &vpu_event_eos);
	inst->eos = false;
	inst->sent_eos = true;
}

static void wave5_update_min_bufs_ctrl(struct vpu_instance *inst, u32 fbc_buf_count)
{
	struct v4l2_m2m_ctx *m2m_ctx = inst->v4l2_fh.m2m_ctx;
	struct v4l2_ctrl *ctrl;

	if (!fbc_buf_count || fbc_buf_count == v4l2_m2m_num_dst_bufs_ready(m2m_ctx))
		return;

	ctrl = v4l2_ctrl_find(&inst->v4l2_ctrl_hdl,
			      V4L2_CID_MIN_BUFFERS_FOR_CAPTURE);
	if (ctrl)
		v4l2_ctrl_s_ctrl(ctrl, fbc_buf_count);
}

static int handle_dynamic_resolution_change(struct vpu_instance *inst)
{
	struct v4l2_fh *fh = &inst->v4l2_fh;

	static const struct v4l2_event vpu_event_src_ch = {

Annotation

Implementation Notes