From patchwork Fri Jul 10 14:19:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HungNien Chen X-Patchwork-Id: 6766281 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CC8D29F2F0 for ; Fri, 10 Jul 2015 14:21:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CE7822069A for ; Fri, 10 Jul 2015 14:21:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D351D20681 for ; Fri, 10 Jul 2015 14:21:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754251AbbGJOVn (ORCPT ); Fri, 10 Jul 2015 10:21:43 -0400 Received: from ml01.weidahitech.com ([61.222.87.235]:1582 "EHLO ml01.weidahitech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932729AbbGJOUa convert rfc822-to-8bit (ORCPT ); Fri, 10 Jul 2015 10:20:30 -0400 Received: from mail01.advancedsilicon.com.tw (mail01.wht.local [192.168.10.15]) by ml01.weidahitech.com (8.13.8/8.13.8) with ESMTP id t6AEJieb016029; Fri, 10 Jul 2015 22:19:44 +0800 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Subject: RE: [PATCH] Input: wdt87xx_i2c - Add a prodcut_id attribute in sysfs Date: Fri, 10 Jul 2015 22:19:43 +0800 Message-ID: <1A63A1423E772B419A9D2E882CBCF6C4020A4937@mail> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] Input: wdt87xx_i2c - Add a prodcut_id attribute in sysfs Thread-Index: AdC6ijqAseoKNTDGSei4G9cCRZReIQAkQJDA References: <1436454043-15093-1-git-send-email-hn.chen@weidahitech.com> <20150709180603.GB1237@dtor-ws> <20150709205956.GF1237@dtor-ws> From: "Hn Chen" To: "Dmitry Torokhov" Cc: , , Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, Dmitry, Thanks for your suggestion ! I will just follow your suggestion and resubmit a patch! BR, Hn.chen -----Original Message----- From: Dmitry Torokhov [mailto:dmitry.torokhov@gmail.com] Sent: Friday, July 10, 2015 5:00 AM To: Hn Chen Cc: linux-input@vger.kernel.org; linux-kernel@vger.kernel.org; charliemooney@google.com Subject: Re: [PATCH] Input: wdt87xx_i2c - Add a prodcut_id attribute in sysfs On Thu, Jul 09, 2015 at 11:06:03AM -0700, Dmitry Torokhov wrote: > Hi Hn, > > On Thu, Jul 09, 2015 at 11:00:43PM +0800, HungNien Chen wrote: > > @@ -165,6 +170,8 @@ struct wdt87xx_sys_param { > > u16 scaling_factor; > > u32 max_x; > > u32 max_y; > > + u16 vendor_id; > > + u16 product_id; > > The vendor and product id of the device usually go into input dveice: > > input->id.vendor > input->id.product > > the custom attributes should be created for data that is not covered > by the standard attributes (like you have with config_csum or fw_version). Something like the version below... --- Dmitry Input: wdt87xx_i2c - populate vendor and product in input device From: HungNien Chen These attributes can be used to identify controllers present in the system. Signed-off-by: HungNien Chen Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/wdt87xx_i2c.c | 46 ++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) input->name = "WDT87xx Touchscreen"; input->id.bustype = BUS_I2C; + input->id.vendor = wdt->param.vendor_id; + input->id.product = wdt->param.product_id; input->phys = wdt->phys; input_set_abs_params(input, ABS_MT_POSITION_X, 0, -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/touchscreen/wdt87xx_i2c.c b/drivers/input/touchscreen/wdt87xx_i2c.c index fb92ae1..764d8f2 100644 --- a/drivers/input/touchscreen/wdt87xx_i2c.c +++ b/drivers/input/touchscreen/wdt87xx_i2c.c @@ -23,7 +23,7 @@ #include #define WDT87XX_NAME "wdt87xx_i2c" -#define WDT87XX_DRV_VER "0.9.6" +#define WDT87XX_DRV_VER "0.9.7" #define WDT87XX_FW_NAME "wdt87xx_fw.bin" #define WDT87XX_CFG_NAME "wdt87xx_cfg.bin" @@ -85,6 +85,11 @@ #define CTL_PARAM_OFFSET_PHY_H 24 #define CTL_PARAM_OFFSET_FACTOR 32 +/* The definition of the device descriptor */ +#define WDT_GD_DEVICE 1 +#define DEV_DESC_OFFSET_VID 8 +#define DEV_DESC_OFFSET_PID 10 + /* Communication commands */ #define PACKET_SIZE 56 #define VND_REQ_READ 0x06 @@ -165,6 +170,8 @@ struct wdt87xx_sys_param { u16 scaling_factor; u32 max_x; u32 max_y; + u16 vendor_id; + u16 product_id; }; struct wdt87xx_data { @@ -208,6 +215,32 @@ static int wdt87xx_i2c_xfer(struct i2c_client *client, return 0; } +static int wdt87xx_get_desc(struct i2c_client *client, u8 desc_idx, + u8 *buf, size_t len) +{ + u8 tx_buf[] = { 0x22, 0x00, 0x10, 0x0E, 0x23, 0x00 }; + int error; + + tx_buf[2] |= desc_idx & 0xF; + + error = wdt87xx_i2c_xfer(client, tx_buf, sizeof(tx_buf), + buf, len); + if (error) { + dev_err(&client->dev, "get desc failed: %d\n", error); + return error; + } + + if (buf[0] != len) { + dev_err(&client->dev, "unexpected response to get desc: %d\n", + buf[0]); + return -EINVAL; + } + + mdelay(WDT_COMMAND_DELAY_MS); + + return 0; +} + static int wdt87xx_get_string(struct i2c_client *client, u8 str_idx, u8 *buf, size_t len) { @@ -403,6 +436,15 @@ static int wdt87xx_get_sysparam(struct i2c_client *client, u8 buf[PKT_READ_SIZE]; int error; + error = wdt87xx_get_desc(client, WDT_GD_DEVICE, buf, 18); + if (error) { + dev_err(&client->dev, "failed to get device desc\n"); + return error; + } + + param->vendor_id = get_unaligned_le16(buf + DEV_DESC_OFFSET_VID); + param->product_id = get_unaligned_le16(buf + DEV_DESC_OFFSET_PID); + error = wdt87xx_get_string(client, STRIDX_PARAMETERS, buf, 34); if (error) { dev_err(&client->dev, "failed to get parameters\n"); @@ -994,6 +1036,8 @@ static int wdt87xx_ts_create_input_device(struct wdt87xx_data *wdt)