drivers/media/usb/dvb-usb-v2/ec168.c

Source file repositories/reference/linux-study-clean/drivers/media/usb/dvb-usb-v2/ec168.c

File Facts

System
Linux kernel
Corpus path
drivers/media/usb/dvb-usb-v2/ec168.c
Extension
.c
Size
8964 bytes
Lines
379
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 (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) {
			if (msg[i].addr == ec168_ec100_config.demod_address) {
				if (msg[i].len < 1) {
					i = -EOPNOTSUPP;
					break;
				}
				req.cmd = READ_DEMOD;
				req.value = 0;
				req.index = 0xff00 + msg[i].buf[0]; /* reg */
				req.size = msg[i+1].len; /* bytes to read */
				req.data = &msg[i+1].buf[0];
				ret = ec168_ctrl_msg(d, &req);
				i += 2;
			} else {
				dev_err(&d->udev->dev, "%s: I2C read not " \
						"implemented\n",
						KBUILD_MODNAME);
				ret = -EOPNOTSUPP;
				i += 2;
			}
		} else {
			if (msg[i].addr == ec168_ec100_config.demod_address) {
				if (msg[i].len < 1) {
					i = -EOPNOTSUPP;
					break;
				}
				req.cmd = WRITE_DEMOD;
				req.value = msg[i].buf[1]; /* val */
				req.index = 0xff00 + msg[i].buf[0]; /* reg */
				req.size = 0;
				req.data = NULL;
				ret = ec168_ctrl_msg(d, &req);
				i += 1;
			} else {
				if (msg[i].len < 1) {
					i = -EOPNOTSUPP;
					break;
				}
				req.cmd = WRITE_I2C;
				req.value = msg[i].buf[0]; /* val */
				req.index = 0x0100 + msg[i].addr; /* I2C addr */
				req.size = msg[i].len-1;
				req.data = &msg[i].buf[1];
				ret = ec168_ctrl_msg(d, &req);
				i += 1;
			}
		}
		if (ret)
			goto error;

	}
	ret = i;

error:
	mutex_unlock(&d->i2c_mutex);
	return ret;
}

static u32 ec168_i2c_func(struct i2c_adapter *adapter)
{
	return I2C_FUNC_I2C;
}

static const struct i2c_algorithm ec168_i2c_algo = {
	.master_xfer   = ec168_i2c_xfer,
	.functionality = ec168_i2c_func,
};

/* Callbacks for DVB USB */
static int ec168_identify_state(struct dvb_usb_device *d, const char **name)
{
	int ret;
	u8 reply;
	struct ec168_req req = {GET_CONFIG, 0, 1, sizeof(reply), &reply};
	dev_dbg(&d->udev->dev, "%s:\n", __func__);

	ret = ec168_ctrl_msg(d, &req);
	if (ret)
		goto error;

	dev_dbg(&d->udev->dev, "%s: reply=%02x\n", __func__, reply);

	if (reply == 0x01)
		ret = WARM;
	else
		ret = COLD;

	return ret;
error:
	dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);

Annotation

Implementation Notes