drivers/media/dvb-frontends/dibx000_common.c

Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/dibx000_common.c

File Facts

System
Linux kernel
Corpus path
drivers/media/dvb-frontends/dibx000_common.c
Extension
.c
Size
13159 bytes
Lines
509
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.

Dependency Surface

Detected Declarations

Annotated Snippet

while (len) {
			da = dibx000_read_word(mst, mst->base_reg);
			*b++ = (da >> 8) & 0xff;
			len--;
			if (len >= 1) {
				*b++ =  da   & 0xff;
				len--;
			}
		}
	}

	return 0;
}

int dibx000_i2c_set_speed(struct i2c_adapter *i2c_adap, u16 speed)
{
	struct dibx000_i2c_master *mst = i2c_get_adapdata(i2c_adap);

	if (mst->device_rev < DIB7000MC && speed < 235)
		speed = 235;
	return dibx000_write_word(mst, mst->base_reg + 3, (u16)(60000 / speed));

}
EXPORT_SYMBOL(dibx000_i2c_set_speed);

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

static int dibx000_i2c_select_interface(struct dibx000_i2c_master *mst,
					enum dibx000_i2c_interface intf)
{
	if (mst->device_rev > DIB3000MC && mst->selected_interface != intf) {
		dprintk("selecting interface: %d\n", intf);
		mst->selected_interface = intf;
		return dibx000_write_word(mst, mst->base_reg + 4, intf);
	}
	return 0;
}

static int dibx000_i2c_master_xfer_gpio12(struct i2c_adapter *i2c_adap, struct i2c_msg msg[], int num)
{
	struct dibx000_i2c_master *mst = i2c_get_adapdata(i2c_adap);
	int msg_index;
	int ret = 0;

	dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_GPIO_1_2);
	for (msg_index = 0; msg_index < num; msg_index++) {
		if (msg[msg_index].flags & I2C_M_RD) {
			ret = dibx000_master_i2c_read(mst, &msg[msg_index]);
			if (ret != 0)
				return 0;
		} else {
			ret = dibx000_master_i2c_write(mst, &msg[msg_index], 1);
			if (ret != 0)
				return 0;
		}
	}

	return num;
}

static int dibx000_i2c_master_xfer_gpio34(struct i2c_adapter *i2c_adap, struct i2c_msg msg[], int num)
{
	struct dibx000_i2c_master *mst = i2c_get_adapdata(i2c_adap);
	int msg_index;
	int ret = 0;

	dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_GPIO_3_4);
	for (msg_index = 0; msg_index < num; msg_index++) {
		if (msg[msg_index].flags & I2C_M_RD) {
			ret = dibx000_master_i2c_read(mst, &msg[msg_index]);
			if (ret != 0)
				return 0;
		} else {
			ret = dibx000_master_i2c_write(mst, &msg[msg_index], 1);
			if (ret != 0)
				return 0;
		}
	}

	return num;
}

static const struct i2c_algorithm dibx000_i2c_master_gpio12_xfer_algo = {
	.master_xfer = dibx000_i2c_master_xfer_gpio12,
	.functionality = dibx000_i2c_func,
};

Annotation

Implementation Notes