drivers/media/pci/saa7164/saa7164-api.c

Source file repositories/reference/linux-study-clean/drivers/media/pci/saa7164/saa7164-api.c

File Facts

System
Linux kernel
Corpus path
drivers/media/pci/saa7164/saa7164-api.c
Extension
.c
Size
44151 bytes
Lines
1513
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 (memcmp(&fmt, &rsp, sizeof(rsp)) == 0) {
			dprintk(DBGLVL_API, "SET/PROBE Verified\n");

			/* Ask the device to select the negotiated format */
			ret = saa7164_cmd_send(port->dev, port->hwcfg.unitid,
				SET_CUR, SAA_COMMIT_CONTROL, sizeof(fmt), &fmt);
			if (ret != SAA_OK)
				printk(KERN_ERR "%s() commit error, ret = 0x%x\n",
					__func__, ret);

			ret = saa7164_cmd_send(port->dev, port->hwcfg.unitid,
				GET_CUR, SAA_COMMIT_CONTROL, sizeof(rsp), &rsp);
			if (ret != SAA_OK)
				printk(KERN_ERR "%s() GET commit error, ret = 0x%x\n",
					__func__, ret);

			if (memcmp(&fmt, &rsp, sizeof(rsp)) != 0) {
				printk(KERN_ERR "%s() memcmp error, ret = 0x%x\n",
					__func__, ret);
			} else
				dprintk(DBGLVL_API, "SET/COMMIT Verified\n");

			dprintk(DBGLVL_API, "rsp.bmHint = 0x%x\n", rsp.bmHint);
			dprintk(DBGLVL_API, "rsp.bFormatIndex = 0x%x\n",
				rsp.bFormatIndex);
			dprintk(DBGLVL_API, "rsp.bFrameIndex = 0x%x\n",
				rsp.bFrameIndex);
		} else
			printk(KERN_ERR "%s() compare failed\n", __func__);
	}

	if (ret == SAA_OK)
		dprintk(DBGLVL_API, "%s(nr=%d) Success\n", __func__, port->nr);

	return ret;
}

static int saa7164_api_set_gop_size(struct saa7164_port *port)
{
	struct saa7164_dev *dev = port->dev;
	struct tmComResEncVideoGopStructure gs;
	int ret;

	dprintk(DBGLVL_ENC, "%s()\n", __func__);

	gs.ucRefFrameDist = port->encoder_params.refdist;
	gs.ucGOPSize = port->encoder_params.gop_size;
	ret = saa7164_cmd_send(port->dev, port->hwcfg.sourceid, SET_CUR,
		EU_VIDEO_GOP_STRUCTURE_CONTROL,
		sizeof(gs), &gs);
	if (ret != SAA_OK)
		printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret);

	return ret;
}

int saa7164_api_set_encoder(struct saa7164_port *port)
{
	struct saa7164_dev *dev = port->dev;
	struct tmComResEncVideoBitRate vb;
	struct tmComResEncAudioBitRate ab;
	int ret;

	dprintk(DBGLVL_ENC, "%s() unitid=0x%x\n", __func__,
		port->hwcfg.sourceid);

	if (port->encoder_params.stream_type == V4L2_MPEG_STREAM_TYPE_MPEG2_PS)
		port->encoder_profile = EU_PROFILE_PS_DVD;
	else
		port->encoder_profile = EU_PROFILE_TS_HQ;

	ret = saa7164_cmd_send(port->dev, port->hwcfg.sourceid, SET_CUR,
		EU_PROFILE_CONTROL, sizeof(u8), &port->encoder_profile);
	if (ret != SAA_OK)
		printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret);

	/* Resolution */
	ret = saa7164_cmd_send(port->dev, port->hwcfg.sourceid, SET_CUR,
		EU_PROFILE_CONTROL, sizeof(u8), &port->encoder_profile);
	if (ret != SAA_OK)
		printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret);

	/* Establish video bitrates */
	if (port->encoder_params.bitrate_mode ==
		V4L2_MPEG_VIDEO_BITRATE_MODE_CBR)
		vb.ucVideoBitRateMode = EU_VIDEO_BIT_RATE_MODE_CONSTANT;
	else
		vb.ucVideoBitRateMode = EU_VIDEO_BIT_RATE_MODE_VARIABLE_PEAK;
	vb.dwVideoBitRate = port->encoder_params.bitrate;
	vb.dwVideoBitRatePeak = port->encoder_params.bitrate_peak;

Annotation

Implementation Notes