drivers/input/touchscreen/rohm_bu21023.c

Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/rohm_bu21023.c

File Facts

System
Linux kernel
Corpus path
drivers/input/touchscreen/rohm_bu21023.c
Extension
.c
Size
26879 bytes
Lines
1165
Domain
Driver Families
Bucket
drivers/input
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

struct rohm_ts_data {
	struct i2c_client *client;
	struct input_dev *input;

	bool initialized;

	unsigned int contact_count[MAX_CONTACTS + 1];
	int finger_count;

	u8 setup2;
};

/*
 * rohm_i2c_burst_read - execute combined I2C message for ROHM BU21023/24
 * @client: Handle to ROHM BU21023/24
 * @start: Where to start read address from ROHM BU21023/24
 * @buf: Where to store read data from ROHM BU21023/24
 * @len: How many bytes to read
 *
 * Returns negative errno, else zero on success.
 *
 * Note
 * In BU21023/24 burst read, stop condition is needed after "address write".
 * Therefore, transmission is performed in 2 steps.
 */
static int rohm_i2c_burst_read(struct i2c_client *client, u8 start, void *buf,
			       size_t len)
{
	struct i2c_adapter *adap = client->adapter;
	struct i2c_msg msg[2];
	int i, ret = 0;

	msg[0].addr = client->addr;
	msg[0].flags = 0;
	msg[0].len = 1;
	msg[0].buf = &start;

	msg[1].addr = client->addr;
	msg[1].flags = I2C_M_RD;
	msg[1].len = len;
	msg[1].buf = buf;

	i2c_lock_bus(adap, I2C_LOCK_SEGMENT);

	for (i = 0; i < 2; i++) {
		if (__i2c_transfer(adap, &msg[i], 1) < 0) {
			ret = -EIO;
			break;
		}
	}

	i2c_unlock_bus(adap, I2C_LOCK_SEGMENT);

	return ret;
}

static int rohm_ts_manual_calibration(struct rohm_ts_data *ts)
{
	struct i2c_client *client = ts->client;
	struct device *dev = &client->dev;
	u8 buf[33];	/* for PRM1_X_H(0x08)-TOUCH(0x28) */

	int retry;
	bool success = false;
	bool first_time = true;
	bool calibration_done;

	u8 reg1, reg2, reg3;
	s32 reg1_orig, reg2_orig, reg3_orig;
	s32 val;

	int calib_x = 0, calib_y = 0;
	int reg_x, reg_y;
	int err_x, err_y;

	int error, error2;
	int i;

	reg1_orig = i2c_smbus_read_byte_data(client, CALIBRATION_REG1);
	if (reg1_orig < 0)
		return reg1_orig;

	reg2_orig = i2c_smbus_read_byte_data(client, CALIBRATION_REG2);
	if (reg2_orig < 0)
		return reg2_orig;

	reg3_orig = i2c_smbus_read_byte_data(client, CALIBRATION_REG3);
	if (reg3_orig < 0)
		return reg3_orig;

Annotation

Implementation Notes