From owner-svn-src-head@freebsd.org Thu May 4 23:12:47 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0CF27D5E058; Thu, 4 May 2017 23:12:47 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DE04587C; Thu, 4 May 2017 23:12:46 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v44NCjg4018646; Thu, 4 May 2017 23:12:45 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v44NCj6c018645; Thu, 4 May 2017 23:12:45 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <201705042312.v44NCj6c018645@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Thu, 4 May 2017 23:12:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r317817 - head/sys/dev/atkbdc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 May 2017 23:12:47 -0000 Author: wulf Date: Thu May 4 23:12:45 2017 New Revision: 317817 URL: https://svnweb.freebsd.org/changeset/base/317817 Log: Set predefined logical touchpad sizes for several ancient Elan hw v.2 models. This change is based on Linux driver. Determine logical trace size. It used for calculation of touch sizes in surface units for MT-protocol type B evdev reports. Reviewed by: gonzo Approved by: gonzo (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D10266 Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c ============================================================================== --- head/sys/dev/atkbdc/psm.c Thu May 4 23:08:55 2017 (r317816) +++ head/sys/dev/atkbdc/psm.c Thu May 4 23:12:45 2017 (r317817) @@ -300,6 +300,8 @@ typedef struct elantechhw { int dpmmy; int ntracesx; int ntracesy; + int dptracex; + int dptracey; int issemimt; int isclickpad; int hascrc; @@ -6280,8 +6282,17 @@ enable_elantech(struct psm_softc *sc, en static const int ic2hw[] = /*IC: 0 1 2 3 4 5 6 7 8 9 a b c d e f */ { 0, 0, 2, 0, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0 }; + static const int fw_sizes[][3] = { + /* FW.vers MaxX MaxY */ + { 0x020030, 1152, 768 }, + { 0x020800, 1152, 768 }, + { 0x020b00, 1152, 768 }, + { 0x040215, 900, 500 }, + { 0x040216, 819, 405 }, + { 0x040219, 900, 500 }, + }; elantechhw_t elanhw; - int icversion, hwversion, dptracex, dptracey, id, resp[3], dpix, dpiy; + int icversion, hwversion, xtr, i, id, resp[3], dpix, dpiy; KBDC kbdc = sc->kbdc; VLOG(3, (LOG_DEBUG, "elantech: BEGIN init\n")); @@ -6332,8 +6343,8 @@ enable_elantech(struct psm_softc *sc, en return (FALSE); } - elanhw.ntracesx = resp[1] - 1; - elanhw.ntracesy = resp[2] - 1; + elanhw.ntracesx = imax(resp[1], 3); + elanhw.ntracesy = imax(resp[2], 3); elanhw.hastrackpoint = (resp[0] & 0x80) != 0; /* Get the touchpad resolution */ @@ -6367,24 +6378,35 @@ enable_elantech(struct psm_softc *sc, en * On HW v.3 touchpads it should be done after switching hardware * to real resolution mode (by setting bit 3 of reg10) */ + elanhw.dptracex = elanhw.dptracey = 64; + for (i = 0; i < nitems(fw_sizes); i++) { + if (elanhw.fwversion == fw_sizes[i][0]) { + elanhw.sizex = fw_sizes[i][1]; + elanhw.sizey = fw_sizes[i][2]; + goto found; + } + } if (elantech_cmd(kbdc, hwversion, ELANTECH_FW_ID, resp) != 0) { printf(" Failed to read touchpad size\n"); elanhw.sizex = 10000; /* Arbitrary high values to */ elanhw.sizey = 10000; /* prevent clipping in smoother */ } else if (hwversion == 2) { - dptracex = dptracey = 64; if ((elanhw.fwversion >> 16) == 0x14 && (resp[1] & 0x10) && !elantech_cmd(kbdc, hwversion, ELANTECH_SAMPLE, resp)) { - dptracex = resp[1] / 2; - dptracey = resp[2] / 2; + elanhw.dptracex = resp[1] / 2; + elanhw.dptracey = resp[2] / 2; } - elanhw.sizex = (elanhw.ntracesx - 1) * dptracex; - elanhw.sizey = (elanhw.ntracesy - 1) * dptracey; + xtr = ((elanhw.fwversion >> 8) == 0x0208) ? 1 : 2; + elanhw.sizex = (elanhw.ntracesx - xtr) * elanhw.dptracex; + elanhw.sizey = (elanhw.ntracesy - xtr) * elanhw.dptracey; } else { elanhw.sizex = (resp[0] & 0x0f) << 8 | resp[1]; elanhw.sizey = (resp[0] & 0xf0) << 4 | resp[2]; + xtr = (elanhw.sizex % (elanhw.ntracesx - 2) == 0) ? 2 : 1; + elanhw.dptracex = elanhw.sizex / (elanhw.ntracesx - xtr); + elanhw.dptracey = elanhw.sizey / (elanhw.ntracesy - xtr); } - +found: if (verbose >= 2) { printf(" Model information:\n"); printf(" MaxX: %d\n", elanhw.sizex); @@ -6393,6 +6415,8 @@ enable_elantech(struct psm_softc *sc, en printf(" DpmmY: %d\n", elanhw.dpmmy); printf(" TracesX: %d\n", elanhw.ntracesx); printf(" TracesY: %d\n", elanhw.ntracesy); + printf(" DptraceX: %d\n", elanhw.dptracex); + printf(" DptraceY: %d\n", elanhw.dptracey); printf(" SemiMT: %d\n", elanhw.issemimt); printf(" Clickpad: %d\n", elanhw.isclickpad); printf(" Trackpoint: %d\n", elanhw.hastrackpoint);