[PATCH 1/1 v2] input: add qt1070 touch keyboard support

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Sat Nov 3 03:32:43 EDT 2012


> > +}
> > +
> > +static int __init qt1070_probe(struct device_d *dev)
> > +{
> > +	struct console_device *cdev;
> > +	struct qt1070_data *data;
> > +	u8 fw_version, chip_id;
> > +	int ret;
> > +	char buf[6];
> > +
> > +	data = xzalloc(sizeof(*data));
> > +	data->client = to_i2c_client(dev);
> > +
> > +	ret = qt1070_read(data, QT1070_READ_CHIP_ID, &chip_id);
> > +	if (ret) {
> > +		dev_err(dev, "can not read chip id (%d)\n", ret);
> > +		goto err;
> > +	}
> > +
> > +	if (chip_id != QT1070_CHIP_ID) {
> > +		dev_err(dev, "unsupported id 0x%x\n", chip_id);
> > +		ret = -ENXIO;
> > +		goto err;
> > +	}
> > +
> > +	ret = qt1070_read(data, QT1070_FW_VERSION, &fw_version);
> > +	if (ret) {
> > +		dev_err(dev, "can not read firmware version (%d)\n", ret);
> > +		goto err;
> > +	}
> > +
> > +	sprintf(buf, "0x%x", fw_version);
> > +	dev_add_param_fixed(dev, "fw_version", buf);
> > +	sprintf(buf, "0x%x", chip_id);
> > +	dev_add_param_fixed(dev, "chip_ip", buf);
> > +
> > +	/* Calibrate device */
> > +	qt1070_write(data, QT1070_CALIBRATE_CMD, 1);
> > +	if (ret) {
> > +		dev_err(dev, "can not calibreate the chip (%d)\n", ret);
> 
> s/calibreate/calibrate/
> 
> > +		goto err;
> > +	}
> > +	mdelay(QT1070_CAL_TIME);
> > +
> > +	/* Soft reset */
> > +	ret = qt1070_write(data, QT1070_RESET, 1);
> > +	if (ret) {
> > +		dev_err(dev, "can not reset the chip (%d)\n", ret);
> > +		goto err;
> > +	}
> > +	mdelay(QT1070_RESET_TIME);
> > +
> 
> This delays the boot by about half a second. If you register
> a poller anyway you could use it to wait until the reset finished.
ok
> 
> > +	memcpy(data->code, default_code, sizeof(int) * ARRAY_SIZE(default_code));
> > +	if (dev->platform_data) {
> > +		struct qt1070_platform_data *pdata = dev->platform_data;
> > +
> > +		memcpy(data->code, pdata->code, sizeof(int) * pdata->nb_code);
> > +	}
> > +
> > +	data->fifo_size = 50;
> 
> I wonder if such a deep fifo is useful. If the user
> plays with the buttons when and nobody empties the fifo
> at that time you will end up with 50 old button presses
> in the fifo. It may be better to just store the last button
> in a variable. This would also fix the problem that when
> the fifo is full you discard the newest buttons. It's
> better to drop the oldest buttons.
no the touch can report 7 keys at the same time so I put 50.

If we pessed 2 times 7 keys before barebox read we have 14 * sifeod(int) = 56
bytes so I think 50 is ok

Best Regards,
J.



More information about the barebox mailing list