From patchwork Tue Sep 12 02:54:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masaki Ota <012nexus@gmail.com> X-Patchwork-Id: 9948305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0C379603FB for ; Tue, 12 Sep 2017 02:56:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F01D128DDE for ; Tue, 12 Sep 2017 02:56:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E455028DB9; Tue, 12 Sep 2017 02:56:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,FROM_STARTS_WITH_NUMS,RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F63628CE0 for ; Tue, 12 Sep 2017 02:56:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751434AbdILCyi (ORCPT ); Mon, 11 Sep 2017 22:54:38 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36575 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751411AbdILCyf (ORCPT ); Mon, 11 Sep 2017 22:54:35 -0400 Received: by mail-pf0-f193.google.com with SMTP id f84so5693321pfj.3; Mon, 11 Sep 2017 19:54:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fRj81I1jEQ/KzghBVE4JsRRPrDlQeR2/MD8FUMtvOz4=; b=YE+oNim2b766DL1Hy7LJHcKVEIStceFDUa3Fp6MP0NnZ5/uU39rldFg35IeOADGFDi O8e49vnBt0L9V9p9xay/XdCq0c8siGesHDys3R0QwGbr/G/K0qD0saBtpfhvyRpaYAVY 6x8dhxv2/efWVtDQqxZs2KAmxIkQeNqKmZiH1Qdm1XxhVZILd08NiB/FePljfOb6B+NO 0arJ8T4R9h3SGOmy72V7M0bHOIA3mAX/5WU+UR25mVTW+yY2BOGoc9upJ6kebY9DPnZJ CvwD+Of1gztZMcmCWCe3OyBAekHjUTWRG5EYVwUoEkAprO/kH7t7JkPoFqVR25eeCICN XjWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fRj81I1jEQ/KzghBVE4JsRRPrDlQeR2/MD8FUMtvOz4=; b=XOhQlMAlCC4a9WrVZfGrQc1qX7sc7AIFpxznifhg0dv6LvwXYGcllUhMYTz+WI3BCz NA6mzT/KwuKpjfTLAEpQuc+vLmI8JvC/jcGuelKKrvWXP+ewDNhvhUNDmiIbJSQOK9GT pdcwJ6Ju3wX/LOW4O613IDdJCfY5kJMMj1opvJp3+7Dr9+JYf92YCjYPmAwolyPIb1KC GYm6jdO4eECdmV5VQVmqBQ4/A+esANVllSuOmpf8Um0Z8TGEWhzshs0bLwnPBmI/sgGG 9lTFQ9W83tx9wXiEySXHgwnU5BRGhHBA4UtY+bgPZ1gA07WQEcLPeIq1CoI3FjfhmX4x T33Q== X-Gm-Message-State: AHPjjUis5Rd4vS/8LhWrudAWeKwZgVWExlAVkSm9Au9FeUF+Tfh5v6Sz DAsZRuS3W4A42SmoSxSE+Q== X-Google-Smtp-Source: ADKCNb4GaKpv21JiheY3QQhgYeeprfIdseI1XWyBzCjBZIqtGmpzKaX2vQMK0znFKpBAGAuaGZVuYg== X-Received: by 10.99.115.92 with SMTP id d28mr13625145pgn.280.1505184874697; Mon, 11 Sep 2017 19:54:34 -0700 (PDT) Received: from localhost (p2142-ipad301aobadori.miyagi.ocn.ne.jp. [123.216.57.142]) by smtp.gmail.com with ESMTPSA id 5sm18009867pfr.151.2017.09.11.19.54.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Sep 2017 19:54:33 -0700 (PDT) From: Masaki Ota <012nexus@gmail.com> X-Google-Original-From: Masaki Ota To: jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, masaki.ota@jp.alps.com Subject: [PATCH 3/7] Minor changes in hid-alps.c for support new Alps device(Add some variables) Date: Tue, 12 Sep 2017 11:54:10 +0900 Message-Id: <20170912025414.3784-4-masaki.ota@jp.alps.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170912025414.3784-1-masaki.ota@jp.alps.com> References: <20170912025414.3784-1-masaki.ota@jp.alps.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Masaki Ota -To support Alps T4 device, add x_min, y_min, max_fingers variables Signed-off-by: Masaki Ota --- drivers/hid/hid-alps.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/hid/hid-alps.c b/drivers/hid/hid-alps.c index c4ea5c6c9be9..201fe175cba3 100644 --- a/drivers/hid/hid-alps.c +++ b/drivers/hid/hid-alps.c @@ -73,9 +73,12 @@ * @y_active_len_mm: active area length of Y (mm) * @x_max: maximum x coordinate value * @y_max: maximum y coordinate value + * @x_min: minimum x coordinate value + * @y_min: minimum y coordinate value * @btn_cnt: number of buttons * @sp_btn_cnt: number of stick buttons * @has_sp: boolean of sp existense + * @max_fingers: total number of fingers */ struct u1_dev { struct input_dev *input; @@ -95,9 +98,12 @@ struct u1_dev { u32 y_active_len_mm; u32 x_max; u32 y_max; + u32 x_min; + u32 y_min; u32 btn_cnt; u32 sp_btn_cnt; u8 has_sp; + u8 max_fingers; }; static int u1_read_write_register(struct hid_device *hdev, u32 address, @@ -319,8 +325,10 @@ static int u1_init(struct hid_device *hdev, struct u1_dev *pri_data) pri_data->x_max = (pri_data->resolution << 2) * (pri_data->sen_line_num_x - 1); + pri_data->x_min = 1; pri_data->y_max = (pri_data->resolution << 2) * (pri_data->sen_line_num_y - 1); + pri_data->y_min = 1; ret = u1_read_write_register(hdev, ADDRESS_U1_PAD_BTN, &pri_data->btn_info, 0, true); @@ -328,6 +336,12 @@ static int u1_init(struct hid_device *hdev, struct u1_dev *pri_data) dev_err(&hdev->dev, "failed U1_PAD_BTN (%d)\n", ret); goto exit; } + if ((pri_data->btn_info & 0x0F) == (pri_data->btn_info & 0xF0) >> 4) { + pri_data->btn_cnt = (pri_data->btn_info & 0x0F); + } else { + /* Button pad */ + pri_data->btn_cnt = 1; + } pri_data->has_sp = 0; /* Check StickPointer device */ @@ -355,7 +369,7 @@ static int u1_init(struct hid_device *hdev, struct u1_dev *pri_data) } pri_data->has_sp = 1; } - + pri_data->max_fingers = 5; exit: return ret; } @@ -383,8 +397,10 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi) goto exit; __set_bit(EV_ABS, input->evbit); - input_set_abs_params(input, ABS_MT_POSITION_X, 1, data->x_max, 0, 0); - input_set_abs_params(input, ABS_MT_POSITION_Y, 1, data->y_max, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_X, + data->x_min, data->x_max, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, + data->y_min, data->y_max, 0, 0); if (data->x_active_len_mm && data->y_active_len_mm) { res_x = (data->x_max - 1) / data->x_active_len_mm; @@ -396,26 +412,21 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi) input_set_abs_params(input, ABS_MT_PRESSURE, 0, 64, 0, 0); - input_mt_init_slots(input, MAX_TOUCHES, INPUT_MT_POINTER); + input_mt_init_slots(input, data->max_fingers, INPUT_MT_POINTER); __set_bit(EV_KEY, input->evbit); - if ((data->btn_info & 0x0F) == (data->btn_info & 0xF0) >> 4) { - data->btn_cnt = (data->btn_info & 0x0F); - } else { - /* Button pad */ - data->btn_cnt = 1; + + if (data->btn_cnt == 1) __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); - } for (i = 0; i < data->btn_cnt; i++) __set_bit(BTN_LEFT + i, input->keybit); - /* Stick device initialization */ if (data->has_sp) { input2 = input_allocate_device(); if (!input2) { - ret = -ENOMEM; + input_free_device(input2); goto exit; } @@ -439,8 +450,7 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi) __set_bit(INPUT_PROP_POINTER, input2->propbit); __set_bit(INPUT_PROP_POINTING_STICK, input2->propbit); - ret = input_register_device(data->input2); - if (ret) { + if (input_register_device(data->input2)) { input_free_device(input2); goto exit; }