From owner-freebsd-mobile@FreeBSD.ORG Mon Mar 12 15:18:40 2012 Return-Path: Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 28B7F106566C for ; Mon, 12 Mar 2012 15:18:40 +0000 (UTC) (envelope-from Andre.Albsmeier@siemens.com) Received: from thoth.sbs.de (thoth.sbs.de [192.35.17.2]) by mx1.freebsd.org (Postfix) with ESMTP id B41978FC1A for ; Mon, 12 Mar 2012 15:18:39 +0000 (UTC) Received: from mail2.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.13.6/8.13.6) with ESMTP id q2CFDxbC023200 for ; Mon, 12 Mar 2012 16:13:59 +0100 Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.40.130]) by mail2.siemens.de (8.13.6/8.13.6) with ESMTP id q2CFDwQr027139 for ; Mon, 12 Mar 2012 16:13:58 +0100 Received: (from localhost) by curry.mchp.siemens.de (8.14.5/8.14.5) id q2CFDwxM079334; Date: Mon, 12 Mar 2012 16:13:58 +0100 From: Andre Albsmeier To: freebsd-mobile@freebsd.org Message-ID: <20120312151358.GA26109@bali> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Echelon: X-Advice: Drop that crappy M$-Outlook, I'm tired of your viruses! User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Andre.Albsmeier@siemens.com Subject: [Patch] Reflect state of rfkill switch in a sysctl for ath based card X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Mar 2012 15:18:40 -0000 Hello all, my laptop (FSC S7020) got this rfkill switch for the normally used Intel 2200 WLAN card. The state of this switch can be seen through the dev.iwi.0.radio sysctl. With my new Atheros based card (Wistron CM9) this never worked although the state of the switch was properly honoured by the card. In case anyone is interested: The following patch brings this functionality to the ath driver of 7.4-STABLE and works at least on the above mentioned hardware. Comments and suggestions (apart from style fixes;-)) are welcome... -Andre --- sys/dev/ath/if_ath.c.ORI 2010-11-17 18:30:14.000000000 +0100 +++ sys/dev/ath/if_ath.c 2012-03-02 13:47:26.000000000 +0100 @@ -6074,6 +6074,15 @@ return !ath_hal_settpcts(sc->sc_ah, tpcts) ? EINVAL : 0; } +static int ath_sysctl_radio( SYSCTL_HANDLER_ARGS ) +{ + struct ath_softc* sc = arg1; + int val; + + val = ath_hal_gpioget( sc->sc_ah, sc->sc_rfsilentpin ) ^ sc->sc_rfsilentpol; + return sysctl_handle_int( oidp, &val, 0, req ); +} + static void ath_sysctlattach(struct ath_softc *sc) { @@ -6162,6 +6171,7 @@ SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "rfkill", CTLTYPE_INT | CTLFLAG_RW, sc, 0, ath_sysctl_rfkill, "I", "enable/disable RF kill switch"); + SYSCTL_ADD_PROC( ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "radio", CTLTYPE_INT | CTLFLAG_RD, sc, 0, ath_sysctl_radio, "I", "radio transmitter switch state (0=off, 1=on)"); } sc->sc_monpass = HAL_RXERR_DECRYPT | HAL_RXERR_MIC; SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,