drivers/media/platform/qcom/iris/iris_venc.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/qcom/iris/iris_venc.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/qcom/iris/iris_venc.c
Extension
.c
Size
16938 bytes
Lines
613
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 (!supported) {
			f_inst = inst->fmt_src;
			f->fmt.pix_mp.width = f_inst->fmt.pix_mp.width;
			f->fmt.pix_mp.height = f_inst->fmt.pix_mp.height;
			f->fmt.pix_mp.pixelformat = f_inst->fmt.pix_mp.pixelformat;
		}
		break;
	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
		if (!supported) {
			f_inst = inst->fmt_dst;
			f->fmt.pix_mp.width = f_inst->fmt.pix_mp.width;
			f->fmt.pix_mp.height = f_inst->fmt.pix_mp.height;
			f->fmt.pix_mp.pixelformat = f_inst->fmt.pix_mp.pixelformat;
		}
		break;
	default:
		return -EINVAL;
	}

	if (pixmp->field == V4L2_FIELD_ANY)
		pixmp->field = V4L2_FIELD_NONE;

	pixmp->num_planes = 1;

	return 0;
}

static int iris_venc_s_fmt_output(struct iris_inst *inst, struct v4l2_format *f)
{
	struct v4l2_format *fmt;
	u32 codec_align;
	bool supported;

	iris_venc_try_fmt(inst, f);

	supported = check_format(inst, f->fmt.pix_mp.pixelformat, f->type);
	if (!supported)
		return -EINVAL;

	codec_align = (f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_HEVC) ? 32 : 16;

	fmt = inst->fmt_dst;
	fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
	/*
	 * If output format size != input format size,
	 * it is considered a scaling case,
	 * and the scaled size needs to be saved.
	 */
	if (f->fmt.pix_mp.width != inst->fmt_src->fmt.pix_mp.width ||
	    f->fmt.pix_mp.height != inst->fmt_src->fmt.pix_mp.height) {
		inst->enc_scale_width = f->fmt.pix_mp.width;
		inst->enc_scale_height = f->fmt.pix_mp.height;
		fmt->fmt.pix_mp.width = ALIGN(f->fmt.pix_mp.width, codec_align);
		fmt->fmt.pix_mp.height = ALIGN(f->fmt.pix_mp.height, codec_align);
	}
	fmt->fmt.pix_mp.num_planes = 1;
	fmt->fmt.pix_mp.plane_fmt[0].bytesperline = 0;
	fmt->fmt.pix_mp.plane_fmt[0].sizeimage = iris_get_buffer_size(inst, BUF_OUTPUT);

	if (f->fmt.pix_mp.colorspace != V4L2_COLORSPACE_DEFAULT &&
	    f->fmt.pix_mp.colorspace != V4L2_COLORSPACE_REC709)
		f->fmt.pix_mp.colorspace = V4L2_COLORSPACE_DEFAULT;
	fmt->fmt.pix_mp.colorspace = f->fmt.pix_mp.colorspace;
	fmt->fmt.pix_mp.xfer_func = f->fmt.pix_mp.xfer_func;
	fmt->fmt.pix_mp.ycbcr_enc = f->fmt.pix_mp.ycbcr_enc;
	fmt->fmt.pix_mp.quantization = f->fmt.pix_mp.quantization;

	inst->buffers[BUF_OUTPUT].min_count = iris_vpu_buf_count(inst, BUF_OUTPUT);
	inst->buffers[BUF_OUTPUT].size = fmt->fmt.pix_mp.plane_fmt[0].sizeimage;
	fmt->fmt.pix_mp.pixelformat = f->fmt.pix_mp.pixelformat;
	inst->codec = f->fmt.pix_mp.pixelformat;
	memcpy(f, fmt, sizeof(struct v4l2_format));

	return 0;
}

static int iris_venc_s_fmt_input(struct iris_inst *inst, struct v4l2_format *f)
{
	struct v4l2_format *fmt, *output_fmt;

	iris_venc_try_fmt(inst, f);

	if (!check_format(inst, f->fmt.pix_mp.pixelformat, f->type))
		return -EINVAL;

	fmt = inst->fmt_src;
	fmt->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
	fmt->fmt.pix_mp.width = ALIGN(f->fmt.pix_mp.width, 128);
	fmt->fmt.pix_mp.height = ALIGN(f->fmt.pix_mp.height, 32);
	fmt->fmt.pix_mp.num_planes = 1;

Annotation

Implementation Notes