Re: ulpt firmware for HP LaserJet (was: Re: add usb quirk to attach foo2zjs printers as ugen)

2013-01-28 Thread Martin Pieuchot
On 28/01/13(Mon) 00:44, Stefan Sperling wrote:
 On Fri, Jan 25, 2013 at 04:00:51PM +0100, Martin Pieuchot wrote:
  What about modifying ulpt(4) to upload the correct firmware like
  uvideo(4) does?
 
 I've done this, and the printer now works out of the box with lpd(8),
 as long as the foo2zjs port is used as a filter:

Awesome, that's ok mpi@ but obviously the printer ids go in separate
commits ;)

 $ cat /etc/printcap  
 #   $OpenBSD: printcap,v 1.4 2003/03/28 21:32:30 jmc Exp $
 
 #lp|local line printer:\
 # :lp=/dev/lp:sd=/var/spool/output:lf=/var/log/lpd-errs:
 #rp|remote line printer:\
 #   :lp=:rm=printhost:rp=lp:sd=/var/spool/output:lf=/var/log/lpd-errs:
 # Entry edited Sun Jan 27 19:58:45 2013 by foomatic-configure.
 # Additional configuration atop /etc/foomatic/lpd/lp.ppd
 lp|local line printer|HP LaserJet 1020:\
 :af=/etc/foomatic/lpd/lp.ppd:\
 :lf=/var/log/lpd-errs:\
 :sd=/var/spool/output/lp:\
 :ppdfile=/etc/foomatic/lpd/lp.ppd:\
 :lp=/dev/ulpt0:\
 :if=/usr/local/bin/foomatic-rip:\
 :sh:\
 :mx#0:
 
 For the record, here's the foomatic-configure line I used (IIRC):
   # foomatic-configure -n lp -s lpd -p HP-LaserJet_1020 -o PageSize=A4

Maybe you should also mention the foomatic* ports in the ulpt(4) man
page?

And I couldn't find a section on the FAQ about printers. Am I blind?
Do you think it would be useful to at least document how to setup a
printer like you did? Antoine what do you think?

 Diff for ulpt below. The firmware port is attached, and since tech@
 will probably eat the attachment also at http://stsp.name/openbsd/ulpt.tar.gz
 
 The firmware has some ridiculous licensing conditions:
 
   3. Copies and Adaptations.   You may only make copies or adaptations of
   the Software for archival purposes or when copying or adaptation is an
   essential step in the authorized Use of the Software. You must reproduce
   all copyright notices in the original Software on all copies or
   adaptations. You may not copy the Software onto any public network.
 
 I'm not sure what copy onto any public network is supposed to mean here.
 Does this last clause affect our ability to put a firmware package on
 the firmware mirrors?

I don't understand much about firmware licenses... Maybe someone else
can tell use if it is ok to put them on the mirrors. By the way if you
have a port for your firmware, you can also import it into
sysutils/firmware.

M.



Re: ulpt firmware for HP LaserJet (was: Re: add usb quirk to attach foo2zjs printers as ugen)

2013-01-28 Thread Antoine Jacoutot
On Mon, Jan 28, 2013 at 09:54:18AM +0100, Martin Pieuchot wrote:
 And I couldn't find a section on the FAQ about printers. Am I blind?
 Do you think it would be useful to at least document how to setup a
 printer like you did? Antoine what do you think?

Yes yes, it's on my todo.
Currently most stuffs that people need are all documented in the 
cups/foomatic-* pkg-readmes (for settingup both cups and lpd queues).
I will eventually work on a printing FAQ in a more generic way than setting up 
just one particular printer -- I just need to find the time.

-- 
Antoine



Re: WPA Enterprise on OpenBSD

2013-01-28 Thread Matthieu Herrb
On Sun, Jan 27, 2013 at 06:17:13PM +, Stuart Henderson wrote:
 On 2013/01/27 17:33, Stuart Henderson wrote:
  I will merge this with my port diff to update to 2.0 and send out a diff 
  soon.
 
 I haven't tested WPA enterprise, but I have tested wired authentication
 with this version (TP-Link switch / MD5 / freeradius).
 
 I made a start at enabling the privilege separation code, but haven't
 finished that yet, so the diff is in place but it's still disabled
 for now.
 
 This diff also enables smartcard support via pcsc-lite - this could
 be made a flavour instead if people prefer to avoid it pulling in an
 LGPL dependency (libusb1) but have kept it simple for now.
 

Works for me on my lab's wifi which uses TTLS PAP with:

network={
ssid=whatever
key_mgmt=WPA-EAP
eap=TTLS PEAP
identity=matthieu
password=my_passord
phase2=auth=PAP
}

Thanks to both kettenis and sthen !

 
 Index: Makefile
 ===
 RCS file: /cvs/ports/security/wpa_supplicant/Makefile,v
 retrieving revision 1.5
 diff -u -p -r1.5 Makefile
 --- Makefile  19 Jan 2012 16:14:11 -  1.5
 +++ Makefile  27 Jan 2013 18:13:11 -
 @@ -2,7 +2,7 @@
  
  COMMENT= IEEE 802.1X supplicant
  
 -DISTNAME=wpa_supplicant-0.7.3
 +DISTNAME=wpa_supplicant-2.0
  CATEGORIES=  security net
  
  HOMEPAGE=http://hostap.epitest.fi/wpa_supplicant/
 @@ -15,7 +15,9 @@ PERMIT_PACKAGE_FTP= Yes
  PERMIT_DISTFILES_CDROM=  Yes
  PERMIT_DISTFILES_FTP=Yes
  
 -WANTLIB += c ssl crypto pcap
 +WANTLIB += c ssl crypto pcap pcsclite pthread
 +
 +LIB_DEPENDS= security/pcsc-lite
  
  MASTER_SITES=http://hostap.epitest.fi/releases/
  
 @@ -26,15 +28,14 @@ MAKE_FLAGS=   V=1
  
  WRKSRC=  ${WRKDIST}/wpa_supplicant
  
 -MAN5=wpa_supplicant.conf.5
 -MAN8=wpa_background.8 wpa_cli.8 wpa_passphrase.8 wpa_supplicant.8
 -
  EXAMPLEDIR=  ${PREFIX}/share/examples/wpa_supplicant
  
  post-extract:
 - cp ${FILESDIR}/config ${WRKSRC}/.config
 + @${SUBST_CMD} -c ${FILESDIR}/config ${WRKSRC}/.config
 + @cp ${FILESDIR}/driver_openbsd.c ${WRKSRC}/../src/drivers/
  
  post-install:
 + @#${INSTALL_PROGRAM} ${WRKBUILD}/wpa_priv ${PREFIX}/sbin
   ${INSTALL_MAN} ${WRKBUILD}/doc/docbook/*.5 ${PREFIX}/man/man5/
   ${INSTALL_MAN} ${WRKBUILD}/doc/docbook/*.8 ${PREFIX}/man/man8/
   ${INSTALL_DATA_DIR} ${EXAMPLEDIR}
 Index: distinfo
 ===
 RCS file: /cvs/ports/security/wpa_supplicant/distinfo,v
 retrieving revision 1.2
 diff -u -p -r1.2 distinfo
 --- distinfo  19 Jan 2012 16:14:11 -  1.2
 +++ distinfo  27 Jan 2013 18:13:11 -
 @@ -1,5 +1,2 @@
 -MD5 (wpa_supplicant-0.7.3.tar.gz) = 9RbxkThKmlRuP1FFwIrd2g==
 -RMD160 (wpa_supplicant-0.7.3.tar.gz) = 4i8EQNZMlD5LCIbu+jQY516gG2A=
 -SHA1 (wpa_supplicant-0.7.3.tar.gz) = ylHbiTH6vzhjUsh0IvPmL7RMP+M=
 -SHA256 (wpa_supplicant-0.7.3.tar.gz) = 
 0M1QyqhTRszDdtzaXtPCWO7xmpOzyt450ldgEYrVlEM=
 -SIZE (wpa_supplicant-0.7.3.tar.gz) = 1638224
 +SHA256 (wpa_supplicant-2.0.tar.gz) = 
 LBFWCfu1Ij1ROBCEpclERVqK/NqB1YQXP/VbojM3ngk=
 +SIZE (wpa_supplicant-2.0.tar.gz) = 2044281
 Index: files/config
 ===
 RCS file: /cvs/ports/security/wpa_supplicant/files/config,v
 retrieving revision 1.1
 diff -u -p -r1.1 config
 --- files/config  19 Jan 2012 16:14:11 -  1.1
 +++ files/config  27 Jan 2013 18:13:11 -
 @@ -1,19 +1,36 @@
 +# $OpenBSD$
 +# see defconfig and README for notes
 +
 +CFLAGS += -I${LOCALBASE}/include/PCSC
 +LIBS += -L${LOCALBASE}/lib
 +
 +CONFIG_BACKEND=file
  CONFIG_CTRL_IFACE=y
  CONFIG_DRIVER_WIRED=y
 +CONFIG_DRIVER_OPENBSD=y
  CONFIG_IEEE8021X_EAPOL=y
 +CONFIG_PEERKEY=y
 +
  CONFIG_EAP_MD5=y
  CONFIG_EAP_MSCHAPV2=y
  CONFIG_EAP_TLS=y
  CONFIG_EAP_PEAP=y
  CONFIG_EAP_TTLS=y
 +CONFIG_EAP_FAST=y
  CONFIG_EAP_GTC=y
  CONFIG_EAP_OTP=y
 -CONFIG_EAP_AKA=y
  CONFIG_EAP_PSK=y
  CONFIG_EAP_SAKE=y
  CONFIG_EAP_GPSK=y
  CONFIG_EAP_PAX=y
  CONFIG_EAP_LEAP=y
 +CONFIG_EAP_IKEV2=y
 +
 +CONFIG_EAP_AKA=y
  CONFIG_EAP_SIM=y
 -#CONFIG_EAP_FAST=n
 -CONFIG_L2_PACKET=freebsd
 +CONFIG_PCSC=y
 +CONFIG_SMARTCARD=y
 +
 +# privilege separation, see README.
 +# WIP: not yet tested.
 +# CONFIG_PRIVSEP=y
 Index: files/driver_openbsd.c
 ===
 RCS file: files/driver_openbsd.c
 diff -N files/driver_openbsd.c
 --- /dev/null 1 Jan 1970 00:00:00 -
 +++ files/driver_openbsd.c27 Jan 2013 18:13:11 -
 @@ -0,0 +1,136 @@
 +/*
 + * Driver interaction with OpenBSD net80211 layer
 + * Copyright (c) 2013, Mark Kettenis
 + *
 + * This software may be distributed under the terms of the BSD license.
 + * See README for more details.
 + */
 +
 +#include includes.h
 +#include sys/ioctl.h
 +
 +#include net/if.h
 +#include net80211/ieee80211.h
 +#include net80211/ieee80211_crypto.h
 

Re: beaglebone JTAG (FT2232H)

2013-01-28 Thread Stuart Henderson
Have you checked if this is still necessary? libusb on OpenBSD is now able to 
talk to devices claimed by drivers other than ugen.


Raphael Graf r...@undefined.ch wrote:

The diff below makes the jtag and serial interfaces of the beaglebone
(FT2232H)
work simultaneously.
This is how the beaglebone shows up:

uhub8 at uhub0 port 1 Standard Microsystems product 0x2412 rev
2.00/b.b2 addr 3
uftdi0 at uhub8 port 1 configuration 1 interface 1 FTDI
BeagleBone/XDS100V2 rev 2.00/7.00 addr 4
ucom0 at uftdi0 portno 2
ugen0 at uhub8 port 1 configuration 1 FTDI BeagleBone/XDS100V2 rev
2.00/7.00 addr 4

Like this, openocd (using ugen) and cu both work.

It is just assumed that interface 0 is used for jtag, not sure if this
is
always true. I'm also unsure if the diff would break other devices.
Can someone comment on this?

Thanks


Index: uftdi.c
===
RCS file: /cvs/src/sys/dev/usb/uftdi.c,v
retrieving revision 1.63
diff -u -p -r1.63 uftdi.c
--- uftdi.c11 Sep 2012 16:04:44 -  1.63
+++ uftdi.c27 Jan 2013 13:20:53 -
@@ -748,28 +748,21 @@ int
 uftdi_match(struct device *parent, void *match, void *aux)
 {
   struct usb_attach_arg *uaa = aux;
-  usbd_status err;
   u_int8_t nifaces;

   if (usb_lookup(uftdi_devs, uaa-vendor, uaa-product) == NULL)
   return (UMATCH_NONE);

   /* Get the number of interfaces. */
-  if (uaa-iface != NULL) {
+  if (uaa-iface != NULL)
   nifaces = uaa-nifaces;
-  } else {
-  err = usbd_set_config_index(uaa-device, UFTDI_CONFIG_INDEX, 1);
-  if (err)
-  return (UMATCH_NONE);
-  err = usbd_interface_count(uaa-device, nifaces);
-  if (err)
-  return (UMATCH_NONE);
-  usbd_set_config_index(uaa-device, USB_UNCONFIG_INDEX, 1);
-  }
+  else
+  return UMATCH_NONE;

   /* JTAG on USB interface 0 */
   if (uaa-vendor == USB_VENDOR_FTDI 
-  uaa-product == USB_PRODUCT_FTDI_OPENRD 
+  (uaa-product == USB_PRODUCT_FTDI_OPENRD ||
+  uaa-product == USB_PRODUCT_FTDI_SERIAL_2232C) 
   uaa-ifaceno == 0)
   return (UMATCH_NONE);




Re: WPA Enterprise on OpenBSD

2013-01-28 Thread Mark Kettenis
 Date: Sun, 27 Jan 2013 18:17:13 +
 From: Stuart Henderson s...@spacehopper.org
 
 On 2013/01/27 17:33, Stuart Henderson wrote:
  I will merge this with my port diff to update to 2.0 and send out
  a diff soon.
 
 I haven't tested WPA enterprise, but I have tested wired authentication
 with this version (TP-Link switch / MD5 / freeradius).
 
 I made a start at enabling the privilege separation code, but haven't
 finished that yet, so the diff is in place but it's still disabled
 for now.
 
 This diff also enables smartcard support via pcsc-lite - this could
 be made a flavour instead if people prefer to avoid it pulling in an
 LGPL dependency (libusb1) but have kept it simple for now.

Looks like you and Gregor duplicated some effort.  Anyway, this looks
fine with to me.  I'll submit my diff upstream later today.

 Index: Makefile
 ===
 RCS file: /cvs/ports/security/wpa_supplicant/Makefile,v
 retrieving revision 1.5
 diff -u -p -r1.5 Makefile
 --- Makefile  19 Jan 2012 16:14:11 -  1.5
 +++ Makefile  27 Jan 2013 18:13:11 -
 @@ -2,7 +2,7 @@
  
  COMMENT= IEEE 802.1X supplicant
  
 -DISTNAME=wpa_supplicant-0.7.3
 +DISTNAME=wpa_supplicant-2.0
  CATEGORIES=  security net
  
  HOMEPAGE=http://hostap.epitest.fi/wpa_supplicant/
 @@ -15,7 +15,9 @@ PERMIT_PACKAGE_FTP= Yes
  PERMIT_DISTFILES_CDROM=  Yes
  PERMIT_DISTFILES_FTP=Yes
  
 -WANTLIB += c ssl crypto pcap
 +WANTLIB += c ssl crypto pcap pcsclite pthread
 +
 +LIB_DEPENDS= security/pcsc-lite
  
  MASTER_SITES=http://hostap.epitest.fi/releases/
  
 @@ -26,15 +28,14 @@ MAKE_FLAGS=   V=1
  
  WRKSRC=  ${WRKDIST}/wpa_supplicant
  
 -MAN5=wpa_supplicant.conf.5
 -MAN8=wpa_background.8 wpa_cli.8 wpa_passphrase.8 wpa_supplicant.8
 -
  EXAMPLEDIR=  ${PREFIX}/share/examples/wpa_supplicant
  
  post-extract:
 - cp ${FILESDIR}/config ${WRKSRC}/.config
 + @${SUBST_CMD} -c ${FILESDIR}/config ${WRKSRC}/.config
 + @cp ${FILESDIR}/driver_openbsd.c ${WRKSRC}/../src/drivers/
  
  post-install:
 + @#${INSTALL_PROGRAM} ${WRKBUILD}/wpa_priv ${PREFIX}/sbin
   ${INSTALL_MAN} ${WRKBUILD}/doc/docbook/*.5 ${PREFIX}/man/man5/
   ${INSTALL_MAN} ${WRKBUILD}/doc/docbook/*.8 ${PREFIX}/man/man8/
   ${INSTALL_DATA_DIR} ${EXAMPLEDIR}
 Index: distinfo
 ===
 RCS file: /cvs/ports/security/wpa_supplicant/distinfo,v
 retrieving revision 1.2
 diff -u -p -r1.2 distinfo
 --- distinfo  19 Jan 2012 16:14:11 -  1.2
 +++ distinfo  27 Jan 2013 18:13:11 -
 @@ -1,5 +1,2 @@
 -MD5 (wpa_supplicant-0.7.3.tar.gz) = 9RbxkThKmlRuP1FFwIrd2g==
 -RMD160 (wpa_supplicant-0.7.3.tar.gz) = 4i8EQNZMlD5LCIbu+jQY516gG2A=
 -SHA1 (wpa_supplicant-0.7.3.tar.gz) = ylHbiTH6vzhjUsh0IvPmL7RMP+M=
 -SHA256 (wpa_supplicant-0.7.3.tar.gz) = 
 0M1QyqhTRszDdtzaXtPCWO7xmpOzyt450ldgEYrVlEM=
 -SIZE (wpa_supplicant-0.7.3.tar.gz) = 1638224
 +SHA256 (wpa_supplicant-2.0.tar.gz) = 
 LBFWCfu1Ij1ROBCEpclERVqK/NqB1YQXP/VbojM3ngk=
 +SIZE (wpa_supplicant-2.0.tar.gz) = 2044281
 Index: files/config
 ===
 RCS file: /cvs/ports/security/wpa_supplicant/files/config,v
 retrieving revision 1.1
 diff -u -p -r1.1 config
 --- files/config  19 Jan 2012 16:14:11 -  1.1
 +++ files/config  27 Jan 2013 18:13:11 -
 @@ -1,19 +1,36 @@
 +# $OpenBSD$
 +# see defconfig and README for notes
 +
 +CFLAGS += -I${LOCALBASE}/include/PCSC
 +LIBS += -L${LOCALBASE}/lib
 +
 +CONFIG_BACKEND=file
  CONFIG_CTRL_IFACE=y
  CONFIG_DRIVER_WIRED=y
 +CONFIG_DRIVER_OPENBSD=y
  CONFIG_IEEE8021X_EAPOL=y
 +CONFIG_PEERKEY=y
 +
  CONFIG_EAP_MD5=y
  CONFIG_EAP_MSCHAPV2=y
  CONFIG_EAP_TLS=y
  CONFIG_EAP_PEAP=y
  CONFIG_EAP_TTLS=y
 +CONFIG_EAP_FAST=y
  CONFIG_EAP_GTC=y
  CONFIG_EAP_OTP=y
 -CONFIG_EAP_AKA=y
  CONFIG_EAP_PSK=y
  CONFIG_EAP_SAKE=y
  CONFIG_EAP_GPSK=y
  CONFIG_EAP_PAX=y
  CONFIG_EAP_LEAP=y
 +CONFIG_EAP_IKEV2=y
 +
 +CONFIG_EAP_AKA=y
  CONFIG_EAP_SIM=y
 -#CONFIG_EAP_FAST=n
 -CONFIG_L2_PACKET=freebsd
 +CONFIG_PCSC=y
 +CONFIG_SMARTCARD=y
 +
 +# privilege separation, see README.
 +# WIP: not yet tested.
 +# CONFIG_PRIVSEP=y
 Index: files/driver_openbsd.c
 ===
 RCS file: files/driver_openbsd.c
 diff -N files/driver_openbsd.c
 --- /dev/null 1 Jan 1970 00:00:00 -
 +++ files/driver_openbsd.c27 Jan 2013 18:13:11 -
 @@ -0,0 +1,136 @@
 +/*
 + * Driver interaction with OpenBSD net80211 layer
 + * Copyright (c) 2013, Mark Kettenis
 + *
 + * This software may be distributed under the terms of the BSD license.
 + * See README for more details.
 + */
 +
 +#include includes.h
 +#include sys/ioctl.h
 +
 +#include net/if.h
 +#include net80211/ieee80211.h
 +#include net80211/ieee80211_crypto.h
 +#include net80211/ieee80211_ioctl.h
 +
 +#include common.h
 +#include driver.h
 +
 +struct openbsd_driver_data {
 

Re: WPA Enterprise on OpenBSD

2013-01-28 Thread Stuart Henderson
On 2013/01/28 11:29, Mark Kettenis wrote:
 Looks like you and Gregor duplicated some effort.

Yes (I had already done the update to 2.0 and was waiting on an OK).



Re: WPA Enterprise on OpenBSD

2013-01-28 Thread Gregor Best
On Mon, Jan 28, 2013 at 11:29:21AM +0100, Mark Kettenis wrote:
 [...]
 Looks like you and Gregor duplicated some effort.  Anyway, this looks
 fine with to me.  I'll submit my diff upstream later today.
 [...]

That's okay, my diff to the port only contains a version bump to 2.0 and
the WPA enterprise patch. I guess using Stuart's effort would be better.

-- 
Gregor Best



Re: WPA Enterprise on OpenBSD

2013-01-28 Thread Mark Kettenis
 Date: Mon, 28 Jan 2013 11:29:21 +0100 (CET)
 From: Mark Kettenis mark.kette...@xs4all.nl
 
  Date: Sun, 27 Jan 2013 18:17:13 +
  From: Stuart Henderson s...@spacehopper.org
  
  On 2013/01/27 17:33, Stuart Henderson wrote:
   I will merge this with my port diff to update to 2.0 and send out
   a diff soon.
  
  I haven't tested WPA enterprise, but I have tested wired authentication
  with this version (TP-Link switch / MD5 / freeradius).
  
  I made a start at enabling the privilege separation code, but haven't
  finished that yet, so the diff is in place but it's still disabled
  for now.
  
  This diff also enables smartcard support via pcsc-lite - this could
  be made a flavour instead if people prefer to avoid it pulling in an
  LGPL dependency (libusb1) but have kept it simple for now.
 
 Looks like you and Gregor duplicated some effort.  Anyway, this looks
 fine with to me.  I'll submit my diff upstream later today.

BTW, the patch for os_internal.c can be dropped.  Our unsetenv(3) has
been standards compliant since 2009.



Re: [PATCH] Support for virtio random device

2013-01-28 Thread Stefan Fritsch

On Sun, 27 Jan 2013, Damien Miller wrote:


On Fri, 25 Jan 2013, Stefan Fritsch wrote:


Hi,

qemu 1.3 has added a virtio entropy device. Here is a driver for it.
Comments?
OKs?

As the entropy reserve of the host may not be unlimited, the OpenBSD guest
should only ask for entropy when it actually needs it. Would it make sense to
add an API that allows a driver to determine how full the entropy queue is?
This could also be used by some hardware drivers to avoid polling for entropy
if not necessary. E.g. amdpm does the polling in every timer tick, which is
wasteful.


I don't think such an API is necessary.

For this particular case, I agree with Kettenis that if qemu allows exhaustion
of the hypervisor's PRNG using this call then the bug lies with qemu.


Qemu can do rate limiting, so it can prevent the host's entropy from being 
drained. But then guests that actually have need of lots of good entropy 
won't be able to get it.



That being said, if you want to avoid this bug then reading a largeish
seed once at system boot and stirring it into the PRNG would be sufficient
to ensure the PRNG pool is unpredictable to an adversary who tries to guess
its state.


That's more or less what the driver I posted does. But with the API to 
query the random queue's state it could do better than that.




Workaround for an rsu(4) bug

2013-01-28 Thread Mark Kettenis
When working on the WPA-Enterprise stuff, I actually ran into an issue
with the rsu(4) I was using.  It seems there is a problem with
submitting the join BSS command when an RSN information element is
included, which makes the command never complete.  The crucial bit
seems to be that this changes the length of the command to something
the firmware doesn't like.  The code rounds the length up to the next
multiple of 8, but it seems the firmware wants it to be at least a
multiple of 16.  The easiest fix seems to be to just send the entire
buffer that we allocate for the command.  This will transfer more
bytes than strictly necessary, but this command isn't sent invoked
very often so I don't think this will be a problem.  This diff might
fix issues with WPA-PSK as well.

ok?


Index: if_rsu.c
===
RCS file: /cvs/src/sys/dev/usb/if_rsu.c,v
retrieving revision 1.14
diff -u -p -r1.14 if_rsu.c
--- if_rsu.c3 Jul 2011 15:47:17 -   1.14
+++ if_rsu.c28 Jan 2013 15:23:46 -
@@ -1078,7 +1078,7 @@ rsu_join_bss(struct rsu_softc *sc, struc
bss-len = htole32(((frm - buf) + 3)  ~3);
DPRINTF((sending join bss command to %s chan %d\n,
ether_sprintf(bss-macaddr), letoh32(bss-config.dsconfig)));
-   return (rsu_fw_cmd(sc, R92S_CMD_JOIN_BSS, buf, frm - buf));
+   return (rsu_fw_cmd(sc, R92S_CMD_JOIN_BSS, buf, sizeof(buf)));
 }
 
 int



Re: PATCH: merge.c white space cleanup

2013-01-28 Thread Miod Vallat
 Usually whitespace diffs are not that well liked, they make for
 annoying differences, introduce noise and require more effort to review
 for questionable gain.
 
 Otoh this file is quite bad. It makes my vim light up all red.

That's why you should stick to vi and not the emacs-in-a-vi-disguise
bloatware known as vim.

 I'm still torn on this. Anyone else care to comment?

If this file is to be changed, then PLEASE fix the logic to get rid of
the gotos.

I did this more than 10 years ago (see diff below), but never dared to
expose it to enough real-word testcases to be confident in this.
Reviewers welcome. Be warned it might not apply cleanly anymore...

Index: merge.c
===
RCS file: /cvs/src/lib/libc/stdlib/merge.c,v
retrieving revision 1.5
diff -u -r1.5 merge.c
--- merge.c 2002/02/17 19:42:24 1.5
+++ merge.c 2002/12/19 02:12:41
@@ -1,3 +1,4 @@
+/* $OpenBSD$   */
 /*-
  * Copyright (c) 1992, 1993
  * The Regents of the University of California.  All rights reserved.
@@ -52,7 +53,7 @@
  * (The default is pairwise merging.)
  */
 
-#include sys/types.h
+#include sys/param.h
 
 #include errno.h
 #include stdlib.h
@@ -63,33 +64,30 @@
 
 #define ISIZE sizeof(int)
 #define PSIZE sizeof(u_char *)
-#define ICOPY_LIST(src, dst, last) \
-   do  \
-   *(int*)dst = *(int*)src, src += ISIZE, dst += ISIZE;\
-   while(src  last)
-#define ICOPY_ELT(src, dst, i) \
-   do  \
-   *(int*) dst = *(int*) src, src += ISIZE, dst += ISIZE;  \
-   while (i -= ISIZE)
+#define ICOPY_LIST(src, dst, last) \
+   do {\
+   *(int*)dst = *(int*)src, src += ISIZE, dst += ISIZE;\
+   } while(src  last)
+#define ICOPY_ELT(src, dst, i) \
+   do {\
+   *(int*) dst = *(int*) src, src += ISIZE, dst += ISIZE;  \
+   } while (i -= ISIZE)
 
 #define CCOPY_LIST(src, dst, last) \
-   do  \
+   do {\
*dst++ = *src++;\
-   while (src  last)
+   } while (src  last)
 #define CCOPY_ELT(src, dst, i) \
-   do  \
+   for (; i; i--) {\
*dst++ = *src++;\
-   while (i -= 1)
+   }

 /*
  * Find the next possible pointer head.  (Trickery for forcing an array
  * to do double duty as a linked list when objects do not align with word
  * boundaries.
  */
-/* Assumption: PSIZE is a power of 2. */
-#define EVAL(p) (u_char **)\
-   ((u_char *)0 +  \
-   (((u_char *)p + PSIZE - 1 - (u_char *) 0)  ~(PSIZE - 1)))
+#define EVAL(p)(u_char **)roundup((long)p, PSIZE)
 
 /*
  * Arguments are as for qsort.
@@ -165,7 +163,14 @@
t = p;
if (i == size)
big = 0; 
-   goto FASTCASE;
+
+   while (i  size)
+   if ((*cmp)(q,
+   p = b + (i = 1))
+   = sense)
+   t = p;
+   else
+   b = p;
} else
b = p;
while (t  b+size) {
@@ -175,14 +180,7 @@
else
b = p;
}
-   goto COPY;
-FASTCASE:  while (i  size)
-   if ((*cmp)(q,
-   p = b + (i = 1)) = sense)
-   t = p;
-   else
-   b = p;
-COPY:  b = t;
+   b = t;
}
i = size;
if (q == f1) {
@@ -231,21 +229,19 @@
 
 #defineswap(a, b) {\
 

Re: PATCH: merge.c white space cleanup

2013-01-28 Thread Marc Espie
On Mon, Jan 28, 2013 at 07:03:24PM +, Miod Vallat wrote:
  Usually whitespace diffs are not that well liked, they make for
  annoying differences, introduce noise and require more effort to review
  for questionable gain.
  
  Otoh this file is quite bad. It makes my vim light up all red.
 
 That's why you should stick to vi and not the emacs-in-a-vi-disguise
 bloatware known as vim.

Lol.

Give me a vi with multiple windows, and with visual, and I will consider
changing editors.



Re: PATCH: merge.c white space cleanup

2013-01-28 Thread Miod Vallat
 Give me a vi with multiple windows, and with visual, and I will consider
 changing editors.

If you need multiple windows, simply open several {rxvt,xterm,whatever}
windows and run vi in them.



Re: PATCH: merge.c white space cleanup

2013-01-28 Thread Matthias Kilian
On Mon, Jan 28, 2013 at 08:45:19PM +0100, Marc Espie wrote:
   Otoh this file is quite bad. It makes my vim light up all red.
  
  That's why you should stick to vi and not the emacs-in-a-vi-disguise
  bloatware known as vim.
 
 Lol.
 
 Give me a vi with multiple windows, and with visual, and I will consider
 changing editors.

vi with visual sounds like a tautology to me ;-)

Ciao,
Kili



Rapoo V7 Keyboard Driver

2013-01-28 Thread Daniel Bolgheroni
Hi tech@,

anyone with a patch lurking around to work with a Rapoo V7 keyboard?

Linux has a workaround, but don't know if works:

https://github.com/Golevka/rapoov7-keyboard-driver

The dmesg for the kbd is:

uhidev1 at uhub5 port 1 configuration 1 interface 0 Holtek USB Gaming 
Keyboard rev 1.10/2.10 addr 3
uhidev1: iclass 3/1
ukbd0 at uhidev1: 8 variable keys, 6 key codes
wskbd1 at ukbd0 mux 1
wskbd1: connecting to wsdisplay0
uhidev2 at uhub5 port 1 configuration 1 interface 1 Holtek USB Gaming 
Keyboard rev 1.10/2.10 addr 3
uhidev2: iclass 3/0, 6 report ids
ums1 at uhidev2 reportid 1: 5 buttons, Z dir
wsmouse2 at ums1 mux 0
uhid0 at uhidev2 reportid 2: input=1, output=0, feature=0
uhid1 at uhidev2 reportid 3: input=2, output=0, feature=0
ukbd1 at uhidev2 reportid 4: 56 variable keys, 0 key codes
wskbd2 at ukbd1 mux 1
wskbd2: connecting to wsdisplay0
ukbd2 at uhidev2 reportid 5: 56 variable keys, 0 key codes
wskbd3 at ukbd2 mux 1
wskbd3: connecting to wsdisplay0
uhid2 at uhidev2 reportid 6: input=2, output=0, feature=0
uhidev3 at uhub5 port 1 configuration 1 interface 2 Holtek USB Gaming 
Keyboard rev 1.10/2.10 addr 3
uhidev3: no input interrupt endpoint

Thank you.



The complete dmesg:
OpenBSD 5.2-current (GENERIC.MP) #20: Mon Jan 21 17:23:23 MST 2013
t...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 3184132096 (3036MB)
avail mem = 3076943872 (2934MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.5 @ 0xfc480 (33 entries)
bios0: vendor American Megatrends Inc. version 200.T02 date 10/26/2010
bios0: POSITIVO POSITIVO MOBILE
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP APIC MCFG SLIC ECDT DBGP BOOT OEMB HPET GSCI ATKG SSDT
acpi0: wakeup devices USB0(S3) USB1(S3) USB2(S3) USB5(S3) EUSB(S3) USB3(S3) 
USB4(S3) USB6(S3) USBE(S3) HDAC(S3) P0P1(S4) P0P2(S3) P0P3(S3) WLAN(S3) 
P0P4(S3) P0P7(S4) GLAN(S4) P0P8(S3) SLPB(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Pentium(R) Dual-Core CPU T4500 @ 2.30GHz, 2640.47 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,EST,TM2,SSSE3,CX16,xTPR,PDCM,XSAVE,NXE,LONG,LAHF,PERF
cpu0: 1MB 64b/line 4-way L2 cache
cpu0: apic clock running at 200MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Pentium(R) Dual-Core CPU T4500 @ 2.30GHz, 2200.08 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,EST,TM2,SSSE3,CX16,xTPR,PDCM,XSAVE,NXE,LONG,LAHF,PERF
cpu1: 1MB 64b/line 4-way L2 cache
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 24 pins
acpimcfg0 at acpi0 addr 0xe000, bus 0-255
acpiec0 at acpi0
acpihpet0 at acpi0: 14318179 Hz
acpi0: unable to load \\_SB_.PCI0._INI.USBT
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (P0P1)
acpiprt2 at acpi0: bus 1 (P0P2)
acpiprt3 at acpi0: bus 2 (P0P3)
acpiprt4 at acpi0: bus 3 (P0P4)
acpiprt5 at acpi0: bus 5 (P0P7)
acpicpu0 at acpi0: C2, C1, PSS
acpicpu1 at acpi0: C2, C1, PSS
acpitz0 at acpi0: critical temperature is 110 degC
acpiac0 at acpi0: AC unit in unknown state
acpibat0 at acpi0: BAT0 not present
acpiasus at acpi0 not configured
acpibtn0 at acpi0: SLPB
acpibtn1 at acpi0: LID_
cpu0: Enhanced SpeedStep 2640 MHz: speeds: 2300, 1600, 1200 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 Intel GM45 Host rev 0x09
vga1 at pci0 dev 2 function 0 Intel GM45 Video rev 0x09
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
intagp0 at vga1
agp0 at intagp0: aperture at 0xd000, size 0x1000
inteldrm0 at vga1: apic 2 int 16
drm0 at inteldrm0
Intel GM45 Video rev 0x09 at pci0 dev 2 function 1 not configured
uhci0 at pci0 dev 26 function 0 Intel 82801I USB rev 0x03: apic 2 int 16
uhci1 at pci0 dev 26 function 1 Intel 82801I USB rev 0x03: apic 2 int 17
uhci2 at pci0 dev 26 function 2 Intel 82801I USB rev 0x03: apic 2 int 19
ehci0 at pci0 dev 26 function 7 Intel 82801I USB rev 0x03: apic 2 int 18
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 Intel EHCI root hub rev 2.00/1.00 addr 1
azalia0 at pci0 dev 27 function 0 Intel 82801I HD Audio rev 0x03: msi
azalia0: codecs: Realtek ALC269, Intel/0x2802, using Realtek ALC269
audio0 at azalia0
ppb0 at pci0 dev 28 function 0 Intel 82801I PCIE rev 0x03: msi
pci1 at ppb0 bus 1
ppb1 at pci0 dev 28 function 1 Intel 82801I PCIE rev 0x03: msi
pci2 at ppb1 bus 2
athn0 at pci2 dev 0 function 0 Atheros AR2427 rev 0x01: apic 2 int 17
athn0: AR9285 rev 2 (1T1R), ROM rev 13, address 48:5d:60:a2:e0:6a
ppb2 at pci0 dev 28 function 2 Intel 82801I PCIE rev 0x03: msi
pci3 at ppb2 bus 3
ppb3 at pci0 dev 28 function 5 Intel 82801I PCIE rev 0x03: msi
pci4 at ppb3 bus 5
re0 at pci4 dev 0 function 0 Realtek 8168 rev 0x03: RTL8168D/8111D (0x2800), 
apic 2 int 17, 

Re: Rapoo V7 Keyboard Driver

2013-01-28 Thread Mike Larkin
On Mon, Jan 28, 2013 at 06:50:28PM -0200, Daniel Bolgheroni wrote:
 Hi tech@,
 
 anyone with a patch lurking around to work with a Rapoo V7 keyboard?
 
 Linux has a workaround, but don't know if works:
 
 https://github.com/Golevka/rapoov7-keyboard-driver
 
 The dmesg for the kbd is:
 
 uhidev1 at uhub5 port 1 configuration 1 interface 0 Holtek USB Gaming 
 Keyboard rev 1.10/2.10 addr 3
 uhidev1: iclass 3/1
 ukbd0 at uhidev1: 8 variable keys, 6 key codes
 wskbd1 at ukbd0 mux 1
 wskbd1: connecting to wsdisplay0
 uhidev2 at uhub5 port 1 configuration 1 interface 1 Holtek USB Gaming 
 Keyboard rev 1.10/2.10 addr 3
 uhidev2: iclass 3/0, 6 report ids
 ums1 at uhidev2 reportid 1: 5 buttons, Z dir
 wsmouse2 at ums1 mux 0
 uhid0 at uhidev2 reportid 2: input=1, output=0, feature=0
 uhid1 at uhidev2 reportid 3: input=2, output=0, feature=0
 ukbd1 at uhidev2 reportid 4: 56 variable keys, 0 key codes
 wskbd2 at ukbd1 mux 1
 wskbd2: connecting to wsdisplay0
 ukbd2 at uhidev2 reportid 5: 56 variable keys, 0 key codes
 wskbd3 at ukbd2 mux 1
 wskbd3: connecting to wsdisplay0
 uhid2 at uhidev2 reportid 6: input=2, output=0, feature=0
 uhidev3 at uhub5 port 1 configuration 1 interface 2 Holtek USB Gaming 
 Keyboard rev 1.10/2.10 addr 3
 uhidev3: no input interrupt endpoint
 
 Thank you.
 

I fixed a variety of mechanical gaming keyboard last year, looks like this is
yet another example of a company doing things slightly different and causing
the usb kbd driver fits.

I'd think you probably won't find much help unless you're willing to donate
the kb to someone for testing. Or buy one for someone. Awfully hard to fix
this sort of thing without access to the hardware.

-ml

 
 
 The complete dmesg:
 OpenBSD 5.2-current (GENERIC.MP) #20: Mon Jan 21 17:23:23 MST 2013
 t...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
 real mem = 3184132096 (3036MB)
 avail mem = 3076943872 (2934MB)
 mainbus0 at root
 bios0 at mainbus0: SMBIOS rev. 2.5 @ 0xfc480 (33 entries)
 bios0: vendor American Megatrends Inc. version 200.T02 date 10/26/2010
 bios0: POSITIVO POSITIVO MOBILE
 acpi0 at bios0: rev 2
 acpi0: sleep states S0 S3 S4 S5
 acpi0: tables DSDT FACP APIC MCFG SLIC ECDT DBGP BOOT OEMB HPET GSCI ATKG SSDT
 acpi0: wakeup devices USB0(S3) USB1(S3) USB2(S3) USB5(S3) EUSB(S3) USB3(S3) 
 USB4(S3) USB6(S3) USBE(S3) HDAC(S3) P0P1(S4) P0P2(S3) P0P3(S3) WLAN(S3) 
 P0P4(S3) P0P7(S4) GLAN(S4) P0P8(S3) SLPB(S4)
 acpitimer0 at acpi0: 3579545 Hz, 24 bits
 acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
 cpu0 at mainbus0: apid 0 (boot processor)
 cpu0: Pentium(R) Dual-Core CPU T4500 @ 2.30GHz, 2640.47 MHz
 cpu0: 
 FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,EST,TM2,SSSE3,CX16,xTPR,PDCM,XSAVE,NXE,LONG,LAHF,PERF
 cpu0: 1MB 64b/line 4-way L2 cache
 cpu0: apic clock running at 200MHz
 cpu1 at mainbus0: apid 1 (application processor)
 cpu1: Pentium(R) Dual-Core CPU T4500 @ 2.30GHz, 2200.08 MHz
 cpu1: 
 FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,EST,TM2,SSSE3,CX16,xTPR,PDCM,XSAVE,NXE,LONG,LAHF,PERF
 cpu1: 1MB 64b/line 4-way L2 cache
 ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 24 pins
 acpimcfg0 at acpi0 addr 0xe000, bus 0-255
 acpiec0 at acpi0
 acpihpet0 at acpi0: 14318179 Hz
 acpi0: unable to load \\_SB_.PCI0._INI.USBT
 acpiprt0 at acpi0: bus 0 (PCI0)
 acpiprt1 at acpi0: bus -1 (P0P1)
 acpiprt2 at acpi0: bus 1 (P0P2)
 acpiprt3 at acpi0: bus 2 (P0P3)
 acpiprt4 at acpi0: bus 3 (P0P4)
 acpiprt5 at acpi0: bus 5 (P0P7)
 acpicpu0 at acpi0: C2, C1, PSS
 acpicpu1 at acpi0: C2, C1, PSS
 acpitz0 at acpi0: critical temperature is 110 degC
 acpiac0 at acpi0: AC unit in unknown state
 acpibat0 at acpi0: BAT0 not present
 acpiasus at acpi0 not configured
 acpibtn0 at acpi0: SLPB
 acpibtn1 at acpi0: LID_
 cpu0: Enhanced SpeedStep 2640 MHz: speeds: 2300, 1600, 1200 MHz
 pci0 at mainbus0 bus 0
 pchb0 at pci0 dev 0 function 0 Intel GM45 Host rev 0x09
 vga1 at pci0 dev 2 function 0 Intel GM45 Video rev 0x09
 wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
 wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
 intagp0 at vga1
 agp0 at intagp0: aperture at 0xd000, size 0x1000
 inteldrm0 at vga1: apic 2 int 16
 drm0 at inteldrm0
 Intel GM45 Video rev 0x09 at pci0 dev 2 function 1 not configured
 uhci0 at pci0 dev 26 function 0 Intel 82801I USB rev 0x03: apic 2 int 16
 uhci1 at pci0 dev 26 function 1 Intel 82801I USB rev 0x03: apic 2 int 17
 uhci2 at pci0 dev 26 function 2 Intel 82801I USB rev 0x03: apic 2 int 19
 ehci0 at pci0 dev 26 function 7 Intel 82801I USB rev 0x03: apic 2 int 18
 usb0 at ehci0: USB revision 2.0
 uhub0 at usb0 Intel EHCI root hub rev 2.00/1.00 addr 1
 azalia0 at pci0 dev 27 function 0 Intel 82801I HD Audio rev 0x03: msi
 azalia0: codecs: Realtek ALC269, Intel/0x2802, using Realtek ALC269
 audio0 at azalia0
 

Re: Rapoo V7 Keyboard Driver

2013-01-28 Thread Stuart Henderson
On 2013/01/28 14:20, Mike Larkin wrote:
 On Mon, Jan 28, 2013 at 06:50:28PM -0200, Daniel Bolgheroni wrote:
  Hi tech@,
  
  anyone with a patch lurking around to work with a Rapoo V7 keyboard?
  
  Linux has a workaround, but don't know if works:
  
  https://github.com/Golevka/rapoov7-keyboard-driver
  
  The dmesg for the kbd is:
  
  ukbd1 at uhidev2 reportid 4: 56 variable keys, 0 key codes
   ^^^
I think it's probably related to this.

The workaround seems to set the keyboard to a simpler boot protocol
which probably doesn't do the n-key rollover stuff; it might be worth
playing with this.

Index: uhidev.c
===
RCS file: /cvs/src/sys/dev/usb/uhidev.c,v
retrieving revision 1.42
diff -u -p -u -7 -r1.42 uhidev.c
--- uhidev.c3 Jul 2011 15:47:17 -   1.42
+++ uhidev.c28 Jan 2013 22:52:00 -
@@ -126,14 +126,15 @@ uhidev_attach(struct device *parent, str
const void *descptr;
usbd_status err;
 
sc-sc_udev = uaa-device;
sc-sc_iface = iface;
id = usbd_get_interface_descriptor(iface);
 
+   (void)usbd_set_protocol(iface, 0);
(void)usbd_set_idle(iface, 0, 0);
 #if 0
 
qflags = usbd_get_quirks(sc-sc_udev)-uq_flags;
if ((qflags  UQ_NO_SET_PROTO) == 0 
id-bInterfaceSubClass != UISUBCLASS_BOOT)
(void)usbd_set_protocol(iface, 1);

The other workaround I saw mentioned for these new keyboards was to
plug them into a passive USB-PS/2 adapter (if the keyboard supports
this), and then plug that into an active PS/2 - USB adapter. Again
you lose any of the more complicated features.

 I'd think you probably won't find much help unless you're willing to donate
 the kb to someone for testing. Or buy one for someone. Awfully hard to fix
 this sort of thing without access to the hardware.

yep.



Re: Rapoo V7 Keyboard Driver

2013-01-28 Thread Mike Larkin
On Mon, Jan 28, 2013 at 10:54:33PM +, Stuart Henderson wrote:
 On 2013/01/28 14:20, Mike Larkin wrote:
  On Mon, Jan 28, 2013 at 06:50:28PM -0200, Daniel Bolgheroni wrote:
   Hi tech@,
   
   anyone with a patch lurking around to work with a Rapoo V7 keyboard?
   
   Linux has a workaround, but don't know if works:
   
   https://github.com/Golevka/rapoov7-keyboard-driver
   
   The dmesg for the kbd is:
   
   ukbd1 at uhidev2 reportid 4: 56 variable keys, 0 key codes
^^^
 I think it's probably related to this.
 
 The workaround seems to set the keyboard to a simpler boot protocol
 which probably doesn't do the n-key rollover stuff; it might be worth
 playing with this.
 
 Index: uhidev.c
 ===
 RCS file: /cvs/src/sys/dev/usb/uhidev.c,v
 retrieving revision 1.42
 diff -u -p -u -7 -r1.42 uhidev.c
 --- uhidev.c  3 Jul 2011 15:47:17 -   1.42
 +++ uhidev.c  28 Jan 2013 22:52:00 -
 @@ -126,14 +126,15 @@ uhidev_attach(struct device *parent, str
   const void *descptr;
   usbd_status err;
  
   sc-sc_udev = uaa-device;
   sc-sc_iface = iface;
   id = usbd_get_interface_descriptor(iface);
  
 + (void)usbd_set_protocol(iface, 0);
   (void)usbd_set_idle(iface, 0, 0);
  #if 0
  
   qflags = usbd_get_quirks(sc-sc_udev)-uq_flags;
   if ((qflags  UQ_NO_SET_PROTO) == 0 
   id-bInterfaceSubClass != UISUBCLASS_BOOT)
   (void)usbd_set_protocol(iface, 1);
 
 The other workaround I saw mentioned for these new keyboards was to
 plug them into a passive USB-PS/2 adapter (if the keyboard supports
 this), and then plug that into an active PS/2 - USB adapter. Again
 you lose any of the more complicated features.
 
  I'd think you probably won't find much help unless you're willing to donate
  the kb to someone for testing. Or buy one for someone. Awfully hard to fix
  this sort of thing without access to the hardware.
 
 yep.
 

The diff above might work but when I tried something akin to that last year
when implementing support for the Monoprice keyboard (similar mechanical
'gaming' style keyboard), the boot protocol only allowed one key pressed at 
a time. That meant no Shift/Ctrl/Alt which made things somewhat difficult.

-ml



Add support for dprintf(3) / vdprintf(3)

2013-01-28 Thread Brad Smith
Here is a diff to add support for the POSIX functions dprintf(3)
and vdprintf(3).


Index: lib/libc/shlib_version
===
RCS file: /cvs/src/lib/libc/shlib_version,v
retrieving revision 1.146
diff -u -p -r1.146 shlib_version
--- lib/libc/shlib_version  3 Dec 2012 20:08:33 -   1.146
+++ lib/libc/shlib_version  23 Jan 2013 06:15:32 -
@@ -1,4 +1,4 @@
 major=66
-minor=1
+minor=2
 # note: If changes were made to include/thread_private.h or if system
 # calls were added/changed then librthread/shlib_version also be updated.
Index: include/stdio.h
===
RCS file: /cvs/src/include/stdio.h,v
retrieving revision 1.42
diff -u -p -r1.42 stdio.h
--- include/stdio.h 21 Mar 2012 23:44:35 -  1.42
+++ include/stdio.h 23 Jan 2013 06:15:32 -
@@ -212,6 +212,9 @@ __END_DECLS
  */
 __BEGIN_DECLS
 voidclearerr(FILE *);
+#if __POSIX_VISIBLE = 200809
+int dprintf(int, const char * __restrict, ...);
+#endif
 int fclose(FILE *);
 int feof(FILE *);
 int ferror(FILE *);
@@ -272,6 +275,9 @@ int  ungetc(int, FILE *);
 int vfprintf(FILE *, const char *, __va_list);
 int vprintf(const char *, __va_list);
 int vsprintf(char *, const char *, __va_list);
+#if __POSIX_VISIBLE = 200809
+int vdprintf(int, const char * __restrict, __va_list);
+#endif
 
 #if __ISO_C_VISIBLE = 1999 || __BSD_VISIBLE
 int snprintf(char *, size_t, const char *, ...)
Index: lib/libc/stdio/Makefile.inc
===
RCS file: /cvs/src/lib/libc/stdio/Makefile.inc,v
retrieving revision 1.22
diff -u -p -r1.22 Makefile.inc
--- lib/libc/stdio/Makefile.inc 21 Mar 2012 23:44:35 -  1.22
+++ lib/libc/stdio/Makefile.inc 23 Jan 2013 06:15:32 -
@@ -19,7 +19,7 @@ SRCS+=asprintf.c clrerr.c fclose.c fdop
putwc.c putwchar.c ungetwc.c \
fwprintf.c swprintf.c vfwprintf.c vswprintf.c vwprintf.c wprintf.c \
fwscanf.c swscanf.c vfwscanf.c vswscanf.c vwscanf.c wscanf.c \
-   getdelim.c getline.c
+   getdelim.c getline.c dprintf.c vdprintf.c
 
 MAN+=  fclose.3 ferror.3 fflush.3 fgetln.3 fgets.3 fopen.3 fputs.3 \
fread.3 fseek.3 funopen.3 getc.3 mktemp.3 perror.3 printf.3 putc.3 \
@@ -43,7 +43,8 @@ MLINKS+=mktemp.3 mkdtemp.3
 MLINKS+=mktemp.3 mkstemps.3
 MLINKS+=printf.3 fprintf.3 printf.3 snprintf.3 printf.3 sprintf.3 \
printf.3 vfprintf.3 printf.3 vprintf.3 printf.3 vsnprintf.3 \
-   printf.3 vsprintf.3 printf.3 asprintf.3 printf.3 vasprintf.3
+   printf.3 vsprintf.3 printf.3 asprintf.3 printf.3 vasprintf.3 \
+   printf.3 dprintf.3 printf.3 vdprintf.3
 MLINKS+=putc.3 fputc.3 putc.3 putchar.3 putc.3 putw.3
 MLINKS+=scanf.3 fscanf.3 scanf.3 sscanf.3 scanf.3 vfscanf.3 scanf.3 vscanf.3 \
scanf.3 vsscanf.3
Index: lib/libc/stdio/dprintf.c
===
RCS file: lib/libc/stdio/dprintf.c
diff -N lib/libc/stdio/dprintf.c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ lib/libc/stdio/dprintf.c23 Jan 2013 06:15:32 -
@@ -0,0 +1,48 @@
+/* $OpenBSD$   */
+/* $FreeBSD: src/lib/libc/stdio/dprintf.c,v 1.2 2012/11/17 01:49:39 svnexp 
Exp $   */
+
+/*-
+ * Copyright (c) 2009 David Schultz d...@freebsd.org
+ * All rights reserved.
+ *
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include stdio.h
+#include stdarg.h
+
+int
+dprintf(int fd, const char * __restrict fmt, ...)

fix dpms issues on ivy bridge

2013-01-28 Thread Jonathan Gray
The following changes mostly based on what has happened in
the upstream drm code seems to resolve problems with screen corruption
on power saving/dpms on ivy bridge with ums here.  Testing on ironlake/
sandy bridge/ivy bridge (aka Core i*) to make sure this doesn't break
anything appreciated.

- remove a workaround which was in itself causing issues
- switch the order of disabling fdi rx  tx
- disable DPLL_SEL when disabling the crtc
- add a few extra delays

Index: i830_display.c
===
RCS file: /cvs/xenocara/driver/xf86-video-intel/src/i830_display.c,v
retrieving revision 1.16
diff -u -p -r1.16 i830_display.c
--- i830_display.c  15 Jan 2013 06:31:43 -  1.16
+++ i830_display.c  29 Jan 2013 02:24:21 -
@@ -1535,16 +1535,6 @@ static void ivb_manual_fdi_link_train(xf
INREG(fdi_rx_reg);
 
usleep(150);
-
-   if (HAS_PCH_CPT(intel)) {
-   temp = INREG(SOUTH_CHICKEN1);
-   temp |= FDI_PHASE_SYNC_OVR(pipe);
-   OUTREG(SOUTH_CHICKEN1, temp); /* once to unlock... */
-   temp |= FDI_PHASE_SYNC_EN(pipe);
-   OUTREG(SOUTH_CHICKEN1, temp); /* then again to enable */
-   INREG(SOUTH_CHICKEN1);
-   usleep(150);
-   }

for (i = 0; i  4; i++) {
temp = INREG(fdi_tx_reg);
@@ -1862,11 +1852,6 @@ ironlake_crtc_disable(xf86CrtcPtr crtc)
OUTREG(pf_win_size, 0);
INREG(pf_win_size);
 
-   ErrorF(FDI TX disable\n);
-   temp = INREG(fdi_tx_reg);
-   OUTREG(fdi_tx_reg, temp  ~FDI_TX_ENABLE);
-   INREG(fdi_tx_reg);
-
ErrorF(FDI RX disable\n);
temp = INREG(fdi_rx_reg);
temp = ~(0x07  16);
@@ -1876,14 +1861,13 @@ ironlake_crtc_disable(xf86CrtcPtr crtc)
 
usleep(100);
 
-   ErrorF(FDI TX train 1 preload\n);
-   /* still set train pattern 1 */
+   ErrorF(FDI TX disable\n);
temp = INREG(fdi_tx_reg);
-   temp = ~FDI_LINK_TRAIN_NONE;
-   temp |= FDI_LINK_TRAIN_PATTERN_1;
-   OUTREG(fdi_tx_reg, temp);
+   OUTREG(fdi_tx_reg, temp  ~FDI_TX_ENABLE);
INREG(fdi_tx_reg);
 
+   usleep(100);
+
ErrorF(FDI RX train 1 preload\n);
temp = INREG(fdi_rx_reg);
if (HAS_PCH_CPT(intel)) {
@@ -1898,6 +1882,16 @@ ironlake_crtc_disable(xf86CrtcPtr crtc)
 
usleep(100);
 
+   ErrorF(FDI TX train 1 preload\n);
+   /* still set train pattern 1 */
+   temp = INREG(fdi_tx_reg);
+   temp = ~FDI_LINK_TRAIN_NONE;
+   temp |= FDI_LINK_TRAIN_PATTERN_1;
+   OUTREG(fdi_tx_reg, temp);
+   INREG(fdi_tx_reg);
+
+   usleep(100);
+
if (i830PipeHasType(crtc, I830_OUTPUT_LVDS)) {
ErrorF(LVDS port force off\n);
while ((temp = INREG(PCH_LVDS))  PORT_ENABLE) {
@@ -1933,6 +1927,25 @@ ironlake_crtc_disable(xf86CrtcPtr crtc)
OUTREG(transconf_reg, temp);
INREG(transconf_reg);
usleep(100);
+
+   if (HAS_PCH_CPT(intel)) {
+   /* disable DPLL_SEL */
+   temp = INREG(PCH_DPLL_SEL);
+   switch (pipe) {
+   case 0:
+   temp = ~(TRANSA_DPLL_ENABLE | TRANSA_DPLLB_SEL);
+   break;
+   case 1:
+   temp = ~(TRANSB_DPLL_ENABLE | TRANSB_DPLLB_SEL);
+   break;
+   case 2:
+   /* C shares PLL A or B */
+   temp = ~(TRANSC_DPLL_ENABLE | TRANSC_DPLLB_SEL);
+   break;
+   }
+   OUTREG(PCH_DPLL_SEL, temp);
+   INREG(PCH_DPLL_SEL);
+   }
 
ErrorF(PCH DPLL disable\n);
/* disable PCH DPLL */



Re: Add support for dprintf(3) / vdprintf(3)

2013-01-28 Thread Philip Guenther
On Mon, 28 Jan 2013, Brad Smith wrote:
 Here is a diff to add support for the POSIX functions dprintf(3)
 and vdprintf(3).

Having poked at it a bit, I think the vdprintf.c below may be better.  By 
using its own write callback, it avoids the SHRT_MAX limit on the fd, and 
it removes the fcntl() dance to check the mode on the fd as it is 
unnecessary: the write callback will diagnose that correctly (by failing 
with EBADF) when the data is written.

Philip


---
/*  $OpenBSD$   */
/*  $FreeBSD: src/lib/libc/stdio/vdprintf.c,v 1.4 2012/11/17 01:49:40 
svnexp Exp $ */

/*-
 * Copyright (c) 2009 David Schultz d...@freebsd.org
 * All rights reserved.
 *
 * Copyright (c) 2011 The FreeBSD Foundation
 * All rights reserved.
 * Portions of this software were developed by David Chisnall
 * under sponsorship from the FreeBSD Foundation.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *notice, this list of conditions and the following disclaimer in the
 *documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#include errno.h
#include stdarg.h
#include stdio.h
#include string.h
#include unistd.h

#include local.h

static int
__dwrite(void *cookie, const char *buf, int n)
{
int *fdp = cookie;
return (write(*fdp, buf, n));
}

int
vdprintf(int fd, const char * __restrict fmt, va_list ap)
{
FILE f;
struct __sfileext fext;
unsigned char buf[BUFSIZ];
int ret;

_FILEEXT_SETUP(f, fext);

f._p = buf;
f._w = sizeof(buf);
f._flags = __SWR;
f._file = -1;
f._bf._base = buf;
f._bf._size = sizeof(buf);
f._cookie = fd;
f._write = __dwrite;

if ((ret = __vfprintf(f, fmt, ap))  0)
return ret;

return fflush(f) ? EOF : ret;
}