Received: from eggs.gnu.org ([208.118.235.92]:60316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ucsc8-0004hW-0q for qemu-devel@nongnu.org; Thu, 16 May 2013 03:28:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ucsc6-0003Yr-Pv for qemu-devel@nongnu.org; Thu, 16 May 2013 03:28:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ucsc6-0003Yd-Gz for qemu-devel@nongnu.org; Thu, 16 May 2013 03:28:34 -0400 Date: Thu, 16 May 2013 15:28:22 +0800 From: Amos Kong Message-ID: <20130516072822.GD3785@t430s.nay.redhat.com> References: <1368678651-3561-1-git-send-email-akong@redhat.com> <1368682228.5142.68.camel@liguang.fnst.cn.fujitsu.com> <20130516065810.GB3785@t430s.nay.redhat.com> <1368688390.5142.87.camel@liguang.fnst.cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1368688390.5142.87.camel@liguang.fnst.cn.fujitsu.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] ps2: add support of auto-repeat List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: li guang Cc: aliguori@us.ibm.com, lcapitulino@redhat.com, lersek@redhat.com, qemu-devel@nongnu.org, kraxel@redhat.com On Thu, May 16, 2013 at 03:13:10PM +0800, li guang wrote: > =E5=9C=A8 2013-05-16=E5=9B=9B=E7=9A=84 14:58 +0800=EF=BC=8CAmos Kong=E5= =86=99=E9=81=93=EF=BC=9A > > On Thu, May 16, 2013 at 01:30:28PM +0800, li guang wrote: > > > =E5=9C=A8 2013-05-16=E5=9B=9B=E7=9A=84 12:30 +0800=EF=BC=8CAmos Kon= g=E5=86=99=E9=81=93=EF=BC=9A > > > > Guest driver sets repeat rate and delay time by KBD_CMD_SET_RATE, > > > > but ps2 backend doesn't process it and no auto-repeat implementat= ion. > > > > This patch adds support of auto-repeat feature. > > > >=20 > > > > Guest ps2 driver sets autorepeat to fastest possible in reset, > > > > period: 250ms, delay: 33ms > > > >=20 > > > > Tested by 'sendkey' monitor command. > > > >=20 > > > > referenced: http://www.computer-engineering.org/ps2keyboard/ > > > >=20 > > > > Signed-off-by: Amos Kong > > Hi, Li guang > > =20 > > > theoretically, we have to check if the typematic key is in break > > > now, if so, we will not do repeat anymore. > >=20 > > You mean key is released? I checked by '~keycode & 0x80', stop repea= t > > when key is release. > >=20 > > > don't you think we have a chance that new key can come in during > > > waiting? > >=20 > > When the new key (press) comes, repeat_timer will be modified by > > qemu_mod_timer(), original repate will be end. > > =20 > > > > + if (auto_repeat) { > > > > + qemu_mod_timer(repeat_timer, qemu_get_clock_ns(vm_clock)= + > > > > + muldiv64(get_ticks_per_sec(), s->repeat_p= eriod, > > > > + 1000)); > > > > + ps2_queue(&s->common, s->repeat_key); > > > > + } > > > > +} > > > > + > > > > + > > > > /* > > > > keycode is expressed as follow: > > > > bit 7 - 0 key pressed, 1 =3D key released > > > > @@ -167,7 +186,17 @@ static void ps2_put_keycode(void *opaque, in= t keycode) > > > > keycode =3D ps2_raw_keycode_set3[keycode & 0x7f]; > > > > } > > > > } > > > > + > > > > + /* only auto-repeat press event */ > > > > + auto_repeat =3D ~keycode & 0x80; > >=20 > > ^^^ >=20 > case: >=20 > 1. new key pressed > 2. enter ps2_put_keycode > 3. previous timer timeout I guess it's repeat_timer > 4. enter repeat_ps2_queue > 5. put previous keycode in queue > 6. back to ps2_put_keycode back? repeat_ps_queue() is called in background. > 7. check auto_repeat >=20 > so, an obsolete key comes up. > can timer interrupt ps2_put_keycode? =20 no. --=20 Amos.